示例#1
0
 /**
  * @dataProvider addressesDataProvider
  */
 public function testSetOrderAddresses($billing, $shipping, $billingState, $state)
 {
     $payment = $this->getMock('Magento\\Sales\\Model\\Order\\Payment', ['__wakeup'], [], '', false);
     $order = $this->getMock('Magento\\Sales\\Model\\Order', ['getPayment', '__wakeup', 'getBillingAddress', 'getShippingAddress'], [], '', false);
     $order->expects($this->any())->method('getPayment')->will($this->returnValue($payment));
     $order->expects($this->any())->method('getBillingAddress')->will($this->returnValue($billing));
     $order->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shipping));
     $this->_model->setOrder($order);
     $this->assertEquals($billingState, $this->_model->getData('billing_state'));
     $this->assertEquals($state, $this->_model->getData('state'));
 }
示例#2
0
 public function testSetPaymentMethod()
 {
     $expectedData = ['paymentaction' => 'authorization', 'notify_url' => 'https://test.com/notifyurl', 'cancel_return' => 'https://test.com/cancelurl', 'return' => 'https://test.com/returnurl', 'lc' => 'US', 'template' => 'mobile-iframe', 'showBillingAddress' => 'false', 'showShippingAddress' => 'true', 'showBillingEmail' => 'false', 'showBillingPhone' => 'false', 'showCustomerName' => 'false', 'showCardInfo' => 'true', 'showHostedThankyouPage' => 'false'];
     $paymentMethodMock = $this->getMockBuilder('Magento\\Paypal\\Model\\Hostedpro')->disableOriginalConstructor()->setMethods([])->getMock();
     $paymentMethodMock->expects($this->once())->method('getConfigData')->with('payment_action')->willReturn('Authorization');
     $paymentMethodMock->expects($this->once())->method('getNotifyUrl')->willReturn('https://test.com/notifyurl');
     $paymentMethodMock->expects($this->once())->method('getCancelUrl')->willReturn('https://test.com/cancelurl');
     $paymentMethodMock->expects($this->once())->method('getReturnUrl')->willReturn('https://test.com/returnurl');
     $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn('en_US');
     $this->assertEquals($this->_model, $this->_model->setPaymentMethod($paymentMethodMock));
     $this->assertEquals('US', $this->_model->getData('lc'));
     $this->assertEquals($expectedData, $this->_model->getData());
 }
示例#3
0
 /**
  * Assert address details
  *
  * @param array $address
  * @param string $type
  */
 protected function assertAddress(array $address, $type = '')
 {
     $type = !empty($type) ? $type . '_' : '';
     static::assertEquals($address['firstname'], $this->model->getData($type . 'first_name'));
     static::assertEquals($address['lastname'], $this->model->getData($type . 'last_name'));
     static::assertEquals($address['city'], $this->model->getData($type . 'city'));
     static::assertEquals($address['region'], $this->model->getData($type . 'state'));
     static::assertEquals($address['country_id'], $this->model->getData($type . 'country'));
     static::assertEquals($address['postcode'], $this->model->getData($type . 'zip'));
     static::assertEquals($address['street'], $this->model->getData($type . 'address1'));
 }
示例#4
0
 /**
  * @covers \Magento\Paypal\Model\Hostedpro\Request::setAmount()
  */
 public function testSetAmountWithIncludedTax()
 {
     /** @var \Magento\Tax\Model\Config  $config */
     $config = $this->helper->getObject('Magento\\Tax\\Model\\Config');
     $config->setPriceIncludesTax(true);
     $this->taxData = $this->helper->getObject('Magento\\Tax\\Helper\\Data', ['taxConfig' => $config]);
     $this->_model = $this->helper->getObject('Magento\\Paypal\\Model\\Hostedpro\\Request', ['localeResolver' => $this->localeResolverMock, 'taxData' => $this->taxData]);
     static::assertTrue($this->taxData->getConfig()->priceIncludesTax());
     $amount = 19.65;
     $expectation = ['amount' => $amount, 'subtotal' => $amount];
     $payment = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $payment->expects(static::once())->method('getBaseAmountAuthorized')->willReturn($amount);
     $order->expects(static::once())->method('getPayment')->willReturn($payment);
     $this->_model->setAmount($order);
     static::assertEquals($expectation, $this->_model->getData());
 }
示例#5
0
 /**
  * Returns form URL from request to PayPal.
  *
  * @param \Magento\Paypal\Model\Hostedpro\Request $request
  * @return string|false
  */
 protected function _sendFormUrlRequest(\Magento\Paypal\Model\Hostedpro\Request $request)
 {
     $api = $this->_pro->getApi();
     $response = $api->call(self::BM_BUTTON_METHOD, $request->getRequestData());
     if (!isset($response['EMAILLINK'])) {
         return false;
     }
     return $response['EMAILLINK'];
 }