public function process(Customweb_Payment_Authorization_ITransaction $transaction) { $initialTransaction = $transaction->getTransactionContext()->getInitialTransaction(); $this->useInitialTransactionData($initialTransaction, $transaction); $transaction->setAuthorizationMethod(self::AUTHORIZATION_METHOD_NAME); $this->requestAuthorization($transaction); }
public function capture(Customweb_Payment_Authorization_ITransaction $transaction) { $transactionModel = $transaction->getTransactionContext()->getTransactionModel(); $order = $transactionModel->getOrder(); $transactionModel->setTransactionObject($transaction); $transactionModel->save(); $invoices = $order->getInvoiceCollection(); if ($invoices->count() == 1) { $invoice = $invoices->getFirstItem(); if ($invoice->canCapture()) { $invoice->capture(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); } } }
public function partialRefund(Customweb_Payment_Authorization_ITransaction $transaction, $items, $close) { $transactionModel = $transaction->getTransactionContext()->getTransactionModel(); $order = $transactionModel->getOrder(); $transactionModel->setTransactionObject($transaction); $transactionModel->save(); try { $data = array(); $orderItems = $order->getItemsCollection(); $totalRefund = 0; $totalOrder = 0; foreach ($items as $item) { switch ($item->getType()) { case Customweb_Payment_Authorization_IInvoiceItem::TYPE_PRODUCT: $orderItem = $orderItems->getItemByColumnValue('sku', $item->getSku()); if (!isset($data['qtys'][$orderItem->getId()])) { $data['qtys'][$orderItem->getId()] = $item->getQuantity(); } else { $data['qtys'][$orderItem->getId()] += $item->getQuantity(); } $totalRefund += $item->getAmountIncludingTax(); $totalOrder += $orderItem->getRowTotalInclTax(); break; case Customweb_Payment_Authorization_IInvoiceItem::TYPE_SHIPPING: if (!isset($data['shipping_amount'])) { $data['shipping_amount'] = $order->getShippingAmount(); } else { $data['shipping_amount'] += $order->getShippingAmount(); } $totalRefund += $item->getAmountIncludingTax(); $totalOrder += $order->getShippingAmount() + $order->getShippingTaxAmount(); break; } } if ($totalOrder > $totalRefund) { $data['adjustment_negative'] = $totalOrder - $totalRefund; } $this->createCreditmemo($order, $data); } catch (Exception $e) { Mage::helper('SaferpayCw')->logException($e); } }
/** * * @param Customweb_Payment_Authorization_ITransaction $transaction * @param Customweb_Saferpay_Configuration $configuration */ public function __construct(Customweb_Payment_Authorization_ITransaction $transaction, Customweb_Saferpay_Configuration $configuration, Customweb_DependencyInjection_IContainer $container) { parent::__construct($transaction->getTransactionContext(), $configuration, $container); $this->setTransaction($transaction); }
public function processAuthorization(Customweb_Payment_Authorization_ITransaction $transaction, array $parameters) { // Check if the CVC field is filled in in case of a alias transaction. if ($transaction->getTransactionState() == Customweb_Saferpay_Authorization_Transaction::STATE_INITIAL && $transaction->isUseExistingAlias() && !$this->isCardVerificationPossible($transaction->getTransactionContext()->getAlias(), $transaction->getTransactionContext()->getOrderContext(), $transaction->getPaymentCustomerContext(), $parameters)) { $message = Customweb_I18n_Translation::__("The CVC field is required."); $transaction->setAuthorizationFailed($message); } if (!$this->validateCustomParameters($transaction, $parameters)) { $reason = Customweb_I18n_Translation::__("Custom parameters have been altered. Fraud possible, aborting."); $transaction->setAuthorizationFailed($reason); } if ($transaction->isAuthorizationFailed()) { $this->redirect(null, $transaction, $this->getFailedUrl($transaction)); } elseif ($transaction->isAuthorized()) { $this->redirect(null, $transaction, $this->getSuccessUrl($transaction)); } else { switch ($transaction->getTransactionState()) { case Customweb_Saferpay_Authorization_Transaction::STATE_INITIAL: $this->processScdResponse($transaction, $parameters); break; case Customweb_Saferpay_Authorization_Transaction::STATE_3D_SECURE: if (!isset($parameters['DATA']) || empty($parameters['DATA'])) { return Customweb_Core_Http_Response::_("NO DATA parameter provided.")->setStatusCode(500); } $parameters = array_merge($parameters, $this->parseRequestParameters($parameters)); $this->process3DSecureResponse($transaction, $parameters); break; default: $this->redirect(null, $transaction, $this->getFailedUrl($transaction)); } } return $this->finalizeAuthorizationRequest($transaction); }