/** * @covers \Magento\Paypal\Model\Hostedpro::initialize * @magentoDataFixture Magento/Paypal/_files/order_hostedpro.php */ public function testInitialize() { /** @var \Magento\Sales\Model\Order $order */ $order = $this->objectManager->create(Order::class); $order->loadByIncrementId('100000001'); $payment = $order->getPayment(); $this->model->setInfoInstance($payment); $this->api->expects(static::once())->method('call')->willReturn(['EMAILLINK' => 'https://securepayments.sandbox.paypal.com/webapps/HostedSoleSolutionApp/webflow/']); $state = $this->objectManager->create(DataObject::class); $this->model->initialize(Config::PAYMENT_ACTION_AUTH, $state); static::assertEquals(Order::STATE_PENDING_PAYMENT, $state->getState()); static::assertEquals(Order::STATE_PENDING_PAYMENT, $state->getStatus()); static::assertFalse($state->getIsNotified()); }
/** * Set shipping options to api * @param \Magento\Paypal\Model\Cart $cart * @param \Magento\Quote\Model\Quote\Address|null $address * @return void */ private function setShippingOptions(PaypalCart $cart, Address $address = null) { // for included tax always disable line items (related to paypal amount rounding problem) $this->_api->setIsLineItemsEnabled($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS)); // add shipping options if needed and line items are available $cartItems = $cart->getAllItems(); if ($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS) && $this->_config->getValue(PaypalConfig::TRANSFER_SHIPPING_OPTIONS) && !empty($cartItems)) { if (!$this->_quote->getIsVirtual()) { $options = $this->_prepareShippingOptions($address, true); if ($options) { $this->_api->setShippingOptionsCallbackUrl($this->_coreUrl->getUrl('*/*/shippingOptionsCallback', ['quote_id' => $this->_quote->getId()]))->setShippingOptions($options); } } } }
/** * Set create billing agreement flag to api call * * @return $this */ protected function _setBillingAgreementRequest() { if (!$this->_customerId || $this->_quote->hasNominalItems()) { return $this; } $isRequested = $this->_isBARequested || $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); if (!($this->_config->getConfigValue('allow_ba_signup') == PaypalConfig::EC_BA_SIGNUP_AUTO || $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) { return $this; } if (!$this->_agreementFactory->create()->needToCreateForCustomer($this->_customerId)) { return $this; } $this->_api->setBillingType($this->_api->getBillingAgreementType()); return $this; }
/** * Import direct payment results to payment * * @param \Magento\Paypal\Model\Api\Nvp $api * @param Payment $payment * @return void */ protected function _importResultToPayment($api, $payment) { $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0); $this->_pro->importPaymentInfo($api, $payment); }
/** * Import refund results to payment * * @param \Magento\Paypal\Model\Api\Nvp $api * @param \Magento\Sales\Model\Order\Payment $payment * @param bool $canRefundMore * @return void */ protected function _importRefundResultToPayment($api, $payment, $canRefundMore) { $payment->setTransactionId($api->getRefundTransactionId())->setIsTransactionClosed(1)->setShouldCloseParentTransaction(!$canRefundMore); $this->importPaymentInfo($api, $payment); }
/** * Import payment info to payment * * @param Api\Nvp $api * @param \Magento\Sales\Model\Order\Payment $payment * @return void */ protected function _importToPayment($api, $payment) { $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0)->setAdditionalInformation(Express\Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT, $api->getRedirectRequired() || $api->getRedirectRequested())->setIsTransactionPending($api->getIsPaymentPending())->setTransactionAdditionalInfo(Payflow\Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId()); $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); $this->_paypalInfoFactory->create()->importToPayment($api, $payment); }
/** * Import payment info to payment * * @param Nvp $api * @param Payment $payment * @return void */ protected function _importToPayment($api, $payment) { $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)->setAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_REDIRECT, $api->getRedirectRequired()); if ($api->getBillingAgreementId()) { $payment->setBillingAgreementData(['billing_agreement_id' => $api->getBillingAgreementId(), 'method_code' => \Magento\Paypal\Model\Config::METHOD_BILLING_AGREEMENT]); } $this->_pro->importPaymentInfo($api, $payment); }
public function testGetDebugReplacePrivateDataKeys() { $debugReplacePrivateDataKeys = $this->_invokeNvpProperty($this->model, '_debugReplacePrivateDataKeys'); $this->assertEquals($debugReplacePrivateDataKeys, $this->model->getDebugReplacePrivateDataKeys()); }
/** * Checking negative line items * * @param array $request * @param int $i * @return null|true */ protected function _exportLineItems(array &$request, $i = 0) { $requestBefore = $request; $result = parent::_exportLineItems($request, $i); if ($this->getIsLineItemsEnabled() && $this->_cart->hasNegativeItemAmount()) { $this->_lineItemTotalExportMap = array(Cart::AMOUNT_TAX => 'TAXAMT', Cart::AMOUNT_SHIPPING => 'FREIGHTAMT', 'amount' => 'PAYMENTREQUEST_0_ITEMAMT'); $this->_lineItemExportItemsFormat = array('name' => 'L_PAYMENTREQUEST_0_NAME%d', 'qty' => 'L_PAYMENTREQUEST_0_QTY%d', 'amount' => 'L_PAYMENTREQUEST_0_AMT%d'); $request = $requestBefore; $result = parent::_exportLineItems($request, $i); /** @var Nvp $paypalNvp */ $paypalNvp = $this->nvpFactory->create(); $this->_doCaptureResponse = $paypalNvp->_doCaptureResponse; $this->_refundTransactionResponse = $paypalNvp->_refundTransactionResponse; $this->_getTransactionDetailsResponse = $paypalNvp->_getTransactionDetailsResponse; $this->_paymentInformationResponse = $paypalNvp->_paymentInformationResponse; $this->_headers[] = 'PAYPAL-NVP: Y'; $this->_setSpecificForNegativeLineItems(); } return $result; }
/** * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Paypal\Model\Api\ProcessableExceptionFactory $processableExceptionFactory * @param \Magento\Framework\Model\ExceptionFactory $frameworkExceptionFactory * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory * @param \Magento\RecurringPayment\Model\QuoteImporter $quoteImporter * @param array $data */ public function __construct(\Magento\Customer\Helper\Address $customerAddress, \Magento\Framework\Logger $logger, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Paypal\Model\Api\ProcessableExceptionFactory $processableExceptionFactory, \Magento\Framework\Model\ExceptionFactory $frameworkExceptionFactory, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\RecurringPayment\Model\QuoteImporter $quoteImporter, array $data = array()) { parent::__construct($customerAddress, $logger, $localeResolver, $regionFactory, $logAdapterFactory, $countryFactory, $processableExceptionFactory, $frameworkExceptionFactory, $curlFactory, $data); $this->_quoteImporter = $quoteImporter; }
/** * Import refund results to payment * * @param \Magento\Paypal\Model\Api\Nvp $api * @param \Magento\Sales\Model\Order\Payment $payment * @param bool $canRefundMore * @return void */ protected function _importRefundResultToPayment($api, $payment, $canRefundMore) { $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(1)->setShouldCloseParentTransaction(!$canRefundMore)->setTransactionAdditionalInfo(self::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId()); $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); $this->_infoFactory->create()->importToPayment($api, $payment); }
public function testCallGetExpressCheckoutDetails() { $this->curl->expects($this->once())->method('read')->will($this->returnValue("\r\n" . 'ACK=Success&SHIPTONAME=Ship%20To%20Name')); $this->model->callGetExpressCheckoutDetails(); $this->assertEquals('Ship To Name', $this->model->getExportedShippingAddress()->getData('firstname')); }