/**
  * @param InfoInterface $payment
  * @param float $amount
  * @return $this
  * @throws LocalizedException
  */
 public function capture(InfoInterface $payment, $amount)
 {
     parent::capture($payment, $amount);
     $customerId = $payment->getOrder()->getCustomerId();
     $customer = $this->customerRepository->getById($customerId);
     $openpayCustomerId = $customer->getCustomAttribute('openpay_customer_id')->getValue();
     $cardId = $payment->getAdditionalInformation('customer_card_id');
     $deviceSessionId = $payment->getAdditionalInformation('device_session_id');
     $order = $payment->getOrder();
     $currency = $order->getOrderCurrencyCode();
     $useOrderId = $this->getConfigData('useOrderId');
     $paymentLeyend = $this->getConfigData('paymentLeyend');
     $orderId = $order->getIncrementId();
     $params = ['source_id' => $cardId, 'method' => self::OPENPAY_PAYMENT_METHOD_CARD, 'amount' => $amount, 'currency' => $currency, 'description' => __($paymentLeyend)->getText(), 'order_id' => $useOrderId ? $orderId : null, 'device_session_id' => $deviceSessionId];
     try {
         $transaction = $this->chargeAdapter->chargeCustomerCard($openpayCustomerId, $params);
         $payment->setTransactionId($transaction->getId())->setIsTransactionClosed(0);
         $this->openpayCustomerRepository->clearCustomerCache($openpayCustomerId);
     } catch (OpenpayException $e) {
         $this->debugData(['request' => $params, 'exception' => $e->getMessage()]);
         $this->_logger->error(__('Payment capturing error.'));
         throw new LocalizedException(new Phrase('[' . $e->getErrorCode() . ']' . $e->getMessage()));
     }
     return $this;
 }
예제 #2
0
 public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
 {
     parent::capture($payment, $amount);
     /* collect data */
     assert($payment instanceof \Magento\Sales\Model\Order\Payment);
     /** @var \Magento\Sales\Model\Order $order */
     $order = $payment->getOrder();
     $orderId = $order->getId();
     $customerId = $order->getCustomerId();
     /* perform payment */
     $req = new \Praxigento\Wallet\Service\Operation\Request\PayForSaleOrder();
     $req->setCustomerId($customerId);
     $req->setOrderId($orderId);
     $req->setBaseAmountToPay($amount);
     $resp = $this->callOperation->payForSaleOrder($req);
     /* TODO: add transaction ID to payment */
     $operId = $resp->getOperationId();
     $payment->setTransactionId($operId);
     return $this;
 }
 /**
  * @param InfoInterface $payment
  * @param float $amount
  * @return $this
  * @throws LocalizedException
  */
 public function capture(InfoInterface $payment, $amount)
 {
     parent::capture($payment, $amount);
     $customerId = $payment->getOrder()->getCustomerId();
     $customer = $this->customerRepository->getById($customerId);
     $openpayCustomerId = $customer->getCustomAttribute('openpay_customer_id')->getValue();
     $order = $payment->getOrder();
     $useOrderId = $this->getConfigData('useOrderId');
     $paymentLeyend = $this->getConfigData('paymentLeyend');
     $orderId = $order->getIncrementId();
     $params = ['customer_id' => $openpayCustomerId, 'amount' => $amount, 'description' => __($paymentLeyend)->getText(), 'order_id' => $useOrderId ? $orderId : null];
     try {
         $transaction = $this->feeAdapter->chargeFee($params);
         $payment->setTransactionId($transaction->getId())->setIsTransactionClosed(0);
         $this->openpayCustomerRepository->clearCustomerCache($openpayCustomerId);
     } catch (OpenpayException $e) {
         $this->debugData(['request' => $params, 'exception' => $e->getMessage()]);
         $this->_logger->error(__('Payment capturing error.'));
         throw new LocalizedException(new Phrase('[' . $e->getErrorCode() . ']' . $e->getMessage()));
     }
     return $this;
 }
예제 #4
0
 public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
 {
     parent::capture($payment, $amount);
     $txn = $payment->getAuthorizationTransaction();
     if ($txn) {
         try {
             $data = array('Merchant_ID' => urlencode($this->getConfigData('merchant')), 'Billnumber' => urlencode($txn->getTxnId()), 'Language' => urlencode('EN'), 'Login' => urlencode($this->getConfigData('api_login')), 'Password' => urlencode($this->getConfigData('api_password')));
             $xml = $this->callAssist(self::CHARGE_URL, $data);
             if ((int) $xml['firstcode'] || (int) $xml['secondcode']) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('error in call'));
             }
             if ('AS000' != (string) $xml->orders->order->responsecode) {
                 throw new \Magento\Framework\Exception\LocalizedException($this->getAssistErrors((string) $xml->orders->order->responsecode));
             }
             /*
             if (Mage::helper('assist')->isServiceSecured()) {
                 $y = implode("", array(
                             $this->getConfigData('merchant'),
                             (string)$xml->orders->order->ordernumber,
                             (string)$xml->orders->order->orderamount,
                             (string)$xml->orders->order->ordercurrency,
                             (string)$xml->orders->order->orderstate,
                             (string)$xml->orders->order->packetdate
                         ));
                 $keyFile = Mage::getBaseDir('var') . DS . self::PEM_DIR . DS . $this->getConfigData('assist_key');
                 if ((string)$xml->orders->order->signature != $this->sign($y, $keyFile)) {
                     Mage::throwException('Incorrect Signature.');
                 }
             }
             */
             // success
             $payment->setTransactionId($txn->getTxnId())->setIsTransactionClosed(false);
             $payment->setIsTransactionApproved(true);
             $this->_debugger->debug(var_export($xml, true));
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             $this->_debugger->debug($e->getMessage());
             throw $e;
         }
     } else {
         if (!$this->getAssistCaptureResponse()) {
             $message = __('Captured amount of %s offline. ASSIST does not support invoicing via web service.', $amount);
             $this->getOrder()->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, true, $message);
         }
     }
     $this->_debugger->debug('capture');
     return $this;
 }
예제 #5
0
 /**
  * Capture on Adyen
  *
  * @param \Magento\Payment\Model\InfoInterface $payment
  * @param float $amount
  */
 public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
 {
     parent::capture($payment, $amount);
     $this->_paymentRequest->capture($payment, $amount);
     return $this;
 }