Ejemplo n.º 1
0
 /**
  * process payment form
  *
  * @param string $paymentId
  * @param array $formData
  * @param Mopt_PayonePaymentHelper $paymentHelper
  * @return array payment data 
  */
 public function processPaymentForm($paymentId, $formData, $paymentHelper)
 {
     if ($paymentHelper->isPayoneCreditcard($paymentId)) {
         return $this->proccessCreditCard($formData);
     }
     if ($paymentHelper->isPayoneSofortuerberweisung($paymentId)) {
         return $this->proccessSofortueberweisung($formData);
     }
     if ($paymentHelper->isPayoneGiropay($paymentId)) {
         return $this->proccessGiropay($formData);
     }
     if ($paymentHelper->isPayoneEPS($paymentId)) {
         return $this->proccessEps($formData);
     }
     if ($paymentHelper->isPayoneIDeal($paymentId)) {
         return $this->proccessIdeal($formData);
     }
     if ($paymentHelper->isPayoneDebitnote($paymentId)) {
         return $this->proccessDebitNote($formData);
     }
     if ($paymentHelper->isPayoneKlarnaInstallment($paymentId)) {
         return $this->proccessKlarnaInstallment($formData);
     }
     if ($paymentHelper->isPayoneKlarna($paymentId)) {
         return $this->proccessKlarna($formData);
     }
     return array();
 }
Ejemplo n.º 2
0
 /**
  * Recurring payment action method.
  */
 public function recurringAction()
 {
     if (!$this->getAmount() || $this->getOrderNumber()) {
         $this->redirect(array('controller' => 'checkout'));
         return;
     }
     $orderId = $this->Request()->getParam('orderId');
     Shopware()->Session()->moptPayment = $this->getPaymentDataFromOrder($orderId);
     if ($this->moptPayonePaymentHelper->isPayoneCreditcard($this->getPaymentShortName())) {
         Shopware()->Session()->moptOverwriteEcommerceMode = Payone_Api_Enum_Ecommercemode::INTERNET;
     }
     $action = 'mopt_payone__' . $this->moptPayonePaymentHelper->getActionFromPaymentName($this->getPaymentShortName());
     $response = $this->{$action}();
     $errorMessage = false;
     if ($response->isRedirect()) {
         $errorMessage = 'Tried to use redirect payment for abo order';
     }
     $session = Shopware()->Session();
     if ($response->getStatus() == 'ERROR') {
         $errorMessage = $response->getErrorcode();
     }
     if (!$errorMessage) {
         //extract possible clearing data
         $clearingData = $this->moptPayoneMain->getPaymentHelper()->extractClearingDataFromResponse($response);
         //save order
         $orderNr = $this->saveOrder($response->getTxid(), $session->paymentReference);
         //get order id
         $sql = 'SELECT `id` FROM `s_order` WHERE ordernumber = ?';
         $orderId = Shopware()->Db()->fetchOne($sql, $orderNr);
         if ($clearingData) {
             $sql = 'UPDATE `s_order_attributes`' . 'SET mopt_payone_txid=?, mopt_payone_is_authorized=?, ' . 'mopt_payone_clearing_data=? WHERE orderID = ?';
             Shopware()->Db()->query($sql, array($response->getTxid(), $session->moptIsAuthorized, json_encode($clearingData), $orderId));
         } else {
             $sql = 'UPDATE `s_order_attributes`' . 'SET mopt_payone_txid=?, mopt_payone_is_authorized=? WHERE orderID = ?';
             Shopware()->Db()->query($sql, array($response->getTxid(), $session->moptIsAuthorized, $orderId));
         }
         if (Shopware()->Session()->moptPayment) {
             $this->saveTransactionPaymentData($orderId, Shopware()->Session()->moptPayment);
         }
         unset($session->moptPayment);
         unset($session->moptIsAuthorized);
     }
     if ($this->Request()->isXmlHttpRequest()) {
         if ($errorMessage) {
             $data = array('success' => false, 'message' => $errorMessage);
         } else {
             $data = array('success' => true, 'data' => array(array('orderNumber' => $orderNr, 'transactionId' => $response->getTxid())));
         }
         echo Zend_Json::encode($data);
     } else {
         if ($errorMessage) {
             $this->View()->errormessage = $this->moptPayoneMain->getPaymentHelper()->moptGetErrorMessageFromErrorCodeViaSnippet(false, $response->getErrorcode());
             $this->forward('error');
         } else {
             $this->redirect(array('controller' => 'checkout', 'action' => 'finish', 'sUniqueID' => $session->paymentReference));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * returns params to capture orders
  *
  * @param object $order
  * @param array $postionIds
  * @param bool $finalize
  * @param bool $includeShipment
  * @return \Payone_Api_Request_Parameter_Capture_Business 
  */
 public function buildOrderCapture($order, $postionIds, $finalize, $includeShipment = false)
 {
     $paymentName = $order->getPayment()->getName();
     $params = $this->getAuthParameters($order->getPayment()->getId());
     $params['txid'] = $order->getTransactionId();
     $params['sequencenumber'] = $this->getParamSequencenumber($order);
     $params['amount'] = $this->getParamCaptureAmount($order, $postionIds, $includeShipment);
     $params['currency'] = $order->getCurrency();
     //create business object (used for settleaccount param)
     $business = new Payone_Api_Request_Parameter_Capture_Business();
     if ($this->payonePaymentHelper->isPayonePayInAdvance($paymentName) || $this->payonePaymentHelper->isPayoneInstantBankTransfer($paymentName)) {
         $business->setSettleaccount($finalize ? Payone_Api_Enum_Settleaccount::YES : Payone_Api_Enum_Settleaccount::NO);
     } else {
         $business->setSettleaccount($finalize ? Payone_Api_Enum_Settleaccount::YES : Payone_Api_Enum_Settleaccount::AUTO);
     }
     $params['business'] = $business;
     return $params;
 }