예제 #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;
 }
예제 #2
0
 /**
  * Get the Secure Token from Paypal for TR
  *
  * @param Quote $quote
  *
  * @return DataObject
  * @throws \Exception
  */
 public function requestToken(Quote $quote)
 {
     $request = $this->transparent->buildBasicRequest();
     $request->setTrxtype(Payflowpro::TRXTYPE_AUTH_ONLY);
     $request->setVerbosity('HIGH');
     $request->setAmt(0);
     $request->setCreatesecuretoken('Y');
     $request->setSecuretokenid($this->mathRandom->getUniqueHash());
     $request->setReturnurl($this->url->getUrl('paypal/transparent/response'));
     $request->setErrorurl($this->url->getUrl('paypal/transparent/response'));
     $request->setCancelurl($this->url->getUrl('paypal/transparent/cancel'));
     $request->setDisablereceipt('TRUE');
     $request->setSilenttran('TRUE');
     $this->transparent->fillCustomerContacts($quote, $request);
     $result = $this->transparent->postRequest($request, $this->transparent->getConfig());
     return $result;
 }
예제 #3
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);
 }
예제 #4
0
 /**
  * Validate data
  *
  * @param DataObject|Object $response
  * @param Transparent $transparentModel
  * @return bool
  */
 public function validate(DataObject $response, Transparent $transparentModel)
 {
     $config = $transparentModel->getConfig();
     foreach ($this->avsCheck as $fieldName => $settingName) {
         if ($config->getValue($settingName) == static::CONFIG_ON && strtolower((string) $response->getData($fieldName)) === static::RESPONSE_NO) {
             $response->setRespmsg($this->errorsMessages[$settingName]);
             return false;
         }
     }
     return true;
 }
예제 #5
0
 /**
  * Validate data
  *
  * @param DataObject $response
  * @param Transparent $transparentModel
  * @return bool
  */
 public function validate(DataObject $response, Transparent $transparentModel)
 {
     if ($transparentModel->getConfig()->getValue(static::CONFIG_NAME) === static::CONFIG_OFF) {
         return true;
     }
     if ($this->isMatchCvv($response)) {
         return true;
     }
     if ($this->isNotMatchCvv($response)) {
         $response->setRespmsg(static::ERROR_MESSAGE);
         return false;
     }
     if ($this->isCvvDoNotExists($response)) {
         return true;
     }
     $response->setRespmsg(static::ERROR_MESSAGE);
     return false;
 }