Esempio n. 1
0
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return ResultInterface|null
  * @throws LocalizedException
  * @throws InvalidTransitionException
  */
 public function execute(array $commandSubject)
 {
     /** @var double $amount */
     $amount = $commandSubject['amount'];
     /** @var PaymentDataObjectInterface $paymentDO */
     $paymentDO = $commandSubject['payment'];
     $payment = $paymentDO->getPayment();
     $storeId = $paymentDO->getOrder()->getStoreId();
     $this->payflowFacade->setStore($storeId);
     $request = $this->payflowFacade->buildBasicRequest();
     /** @var \Magento\Sales\Model\Order $order */
     $order = $payment->getOrder();
     $this->payflowFacade->addRequestOrderInfo($request, $order);
     $request = $this->payflowFacade->fillCustomerContacts($order, $request);
     /** @var \Magento\Vault\Api\Data\PaymentTokenInterface $token */
     $token = $payment->getExtensionAttributes()->getVaultPaymentToken();
     $request->setData('trxtype', Transparent::TRXTYPE_AUTH_ONLY);
     $request->setData('origid', $token->getGatewayToken());
     $request->setData('amt', $this->formatPrice($amount));
     $response = $this->payflowFacade->postRequest($request, $this->payflowFacade->getConfig());
     $this->payflowFacade->processErrors($response);
     try {
         $this->payflowFacade->getResponceValidator()->validate($response, $this->payflowFacade);
     } catch (LocalizedException $exception) {
         $payment->setParentTransactionId($response->getData(Transparent::PNREF));
         $this->payflowFacade->void($payment);
         throw new LocalizedException(__('Error processing payment, please try again later.'));
     }
     $this->payflowFacade->setTransStatus($payment, $response);
     return $this;
 }
Esempio n. 2
0
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return null|ResultInterface
  */
 public function execute(array $commandSubject)
 {
     /** @var double $amount */
     $amount = $commandSubject['amount'];
     /** @var PaymentDataObjectInterface $paymentDO */
     $paymentDO = $commandSubject['payment'];
     $payment = $paymentDO->getPayment();
     $storeId = $paymentDO->getOrder()->getStoreId();
     $this->payflowFacade->setStore($storeId);
     /** @var \Magento\Vault\Api\Data\PaymentTokenInterface $token */
     $token = $payment->getExtensionAttributes()->getVaultPaymentToken();
     $request = $this->payflowFacade->buildBasicRequest();
     $request->setAmt($this->formatPrice($amount));
     $request->setTrxtype(Transparent::TRXTYPE_SALE);
     $request->setOrigid($token->getGatewayToken());
     $this->payflowFacade->addRequestOrderInfo($request, $payment->getOrder());
     $response = $this->payflowFacade->postRequest($request, $this->payflowFacade->getConfig());
     $this->payflowFacade->processErrors($response);
     $this->payflowFacade->setTransStatus($payment, $response);
 }