Exemple #1
0
 /**
  * @param Payment $payment
  * @param string $token
  * @throws LocalizedException
  * @return void
  */
 protected function createPaymentToken(Payment $payment, $token)
 {
     /** @var PaymentTokenInterface $paymentToken */
     $paymentToken = $this->paymentTokenFactory->create();
     $paymentToken->setGatewayToken($token);
     $paymentToken->setTokenDetails(json_encode($payment->getAdditionalInformation(Transparent::CC_DETAILS)));
     $paymentToken->setExpiresAt($this->getExpirationDate($payment));
     $this->getPaymentExtensionAttributes($payment)->setVaultPaymentToken($paymentToken);
 }
Exemple #2
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Payment $payment
  * @param float $amount
  * @return $this
  */
 protected function _placeOrder(Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
     $billingAgreement = $this->_agreementFactory->create()->load($payment->getAdditionalInformation(\Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID));
     $cart = $this->_cartFactory->create(array('salesModel' => $order));
     $proConfig = $this->_pro->getConfig();
     $api = $this->_pro->getApi()->setReferenceId($billingAgreement->getReferenceId())->setPaymentAction($proConfig->getConfigValue('paymentAction'))->setAmount($amount)->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/'))->setPaypalCart($cart)->setIsLineItemsEnabled($proConfig->getConfigValue('lineItemsEnabled'))->setInvNum($order->getIncrementId());
     // call api and import transaction and other payment information
     $api->callDoReferenceTransaction();
     $this->_pro->importPaymentInfo($api, $payment);
     $api->callGetTransactionDetails();
     $this->_pro->importPaymentInfo($api, $payment);
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
     if ($api->getBillingAgreementId()) {
         $order->addRelatedObject($billingAgreement);
         $billingAgreement->setIsObjectChanged(true);
         $billingAgreement->addOrderRelation($order);
     }
     return $this;
 }
Exemple #3
0
 /**
  * Place an order with authorization or capture action
  *
  * @param Payment $payment
  * @param float $amount
  * @return $this
  */
 protected function _placeOrder(Payment $payment, $amount)
 {
     $order = $payment->getOrder();
     // prepare api call
     $token = $payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $cart = $this->_cartFactory->create(['salesModel' => $order]);
     $api = $this->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->getValue('paymentAction'))->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/'))->setInvNum($order->getIncrementId())->setCurrencyCode($order->getBaseCurrencyCode())->setPaypalCart($cart)->setIsLineItemsEnabled($this->_pro->getConfig()->getValue('lineItemsEnabled'));
     if ($order->getIsVirtual()) {
         $api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
     } else {
         $api->setAddress($order->getShippingAddress());
         $api->setBillingAddress($order->getBillingAddress());
     }
     // call api and get details from it
     $api->callDoExpressCheckoutPayment();
     $this->_importToPayment($api, $payment);
     return $this;
 }
 /**
  * Return secure hash value for silent post request
  *
  * @param \Magento\Sales\Model\Order\Payment $payment
  * @return string
  */
 protected function _getSecureSilentPostHash($payment)
 {
     return $payment->getAdditionalInformation($this->_secureSilentPostHashKey);
 }
 /**
  * {@inheritdoc}
  */
 public function getAdditionalInformation($key = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getAdditionalInformation');
     if (!$pluginInfo) {
         return parent::getAdditionalInformation($key);
     } else {
         return $this->___callPlugins('getAdditionalInformation', func_get_args(), $pluginInfo);
     }
 }