payment process

This commit is contained in:
Etienne Roudeix
2013-09-19 15:59:16 +02:00
parent 3c02a9d23c
commit ec7d4471dc
5 changed files with 33 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\OrderEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\AddressQuery; use Thelia\Model\Base\AddressQuery;
use Thelia\Model\ModuleQuery;
use Thelia\Model\OrderStatus; use Thelia\Model\OrderStatus;
use Thelia\Model\Map\OrderTableMap; use Thelia\Model\Map\OrderTableMap;
use Thelia\Model\OrderAddress; use Thelia\Model\OrderAddress;
@@ -114,6 +115,8 @@ class Order extends BaseAction implements EventSubscriberInterface
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
$paymentModule = ModuleQuery::findPk($placedOrder->getPaymentModuleId());
/* fulfill order */ /* fulfill order */
$placedOrder->setCustomerId($customer->getId()); $placedOrder->setCustomerId($customer->getId());
$placedOrder->setCurrencyId($currency->getId()); $placedOrder->setCurrencyId($currency->getId());
@@ -162,21 +165,22 @@ class Order extends BaseAction implements EventSubscriberInterface
/* fulfill order_products and decrease stock // @todo dispatch event */ /* fulfill order_products and decrease stock // @todo dispatch event */
/* discount */ /* discount @todo */
/* postage */
$con->commit(); $con->commit();
/* T1style : dispatch mail event ? */
/* dispatch mail event */
/* clear session ? */ /* clear session ? */
/* call pay method */ /* call pay method */
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
$paymentModuleInstance = $paymentModuleReflection->newInstance();
$out = true; $paymentModuleInstance->setRequest($this->request);
$paymentModuleInstance->setDispatcher($this->dispatcher);
$paymentModuleInstance->pay();
} }
/** /**
@@ -184,6 +188,8 @@ class Order extends BaseAction implements EventSubscriberInterface
*/ */
public function setReference(OrderEvent $event) public function setReference(OrderEvent $event)
{ {
$x = true;
$this->setRef($this->generateRef()); $this->setRef($this->generateRef());
} }

View File

@@ -85,6 +85,13 @@ class OrderDelivery extends BaseForm
if(null === $module) { if(null === $module) {
$context->addViolation("Delivery module ID not found"); $context->addViolation("Delivery module ID not found");
} }
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
$context->addViolation(
sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $module->getCode())
);
}
} }
public function getName() public function getName()

View File

@@ -80,11 +80,18 @@ class OrderPayment extends BaseForm
->filterByType(BaseModule::PAYMENT_MODULE_TYPE) ->filterByType(BaseModule::PAYMENT_MODULE_TYPE)
->filterByActivate(1) ->filterByActivate(1)
->filterById($value) ->filterById($value)
->find(); ->findOne();
if(null === $module) { if(null === $module) {
$context->addViolation("Payment module ID not found"); $context->addViolation("Payment module ID not found");
} }
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
$context->addViolation(
sprintf("delivery module %s is not a Thelia\Module\PaymentModuleInterface", $module->getCode())
);
}
} }
public function getName() public function getName()

View File

@@ -17,10 +17,12 @@ class Order extends BaseOrder
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
/*public function postInsert(ConnectionInterface $con = null) public function preInsert(ConnectionInterface $con = null)
{ {
$this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this)); $this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this));
}*/
return true;
}
/** /**
* calculate the total amount * calculate the total amount

View File

@@ -56,7 +56,7 @@ class Cheque extends BaseModule implements PaymentModuleInterface
public function pay() public function pay()
{ {
// TODO: Implement pay() method. // no special process, waiting for the cheque.
} }
public function install() public function install()