22 use \PHPUnit_Framework_MockObject_MockObject as MockObject;
34 ApiProcessableException::API_INTERNAL_ERROR,
35 ApiProcessableException::API_UNABLE_PROCESS_PAYMENT_ERROR_CODE,
36 ApiProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL,
37 ApiProcessableException::API_UNABLE_TRANSACTION_COMPLETE,
38 ApiProcessableException::API_TRANSACTION_EXPIRED,
39 ApiProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED,
40 ApiProcessableException::API_COUNTRY_FILTER_DECLINE,
41 ApiProcessableException::API_MAXIMUM_AMOUNT_FILTER_DECLINE,
42 ApiProcessableException::API_OTHER_FILTER_DECLINE,
43 ApiProcessableException::API_ADDRESS_MATCH_FAIL
54 private $checkoutSession;
74 private $transactionBuilder;
79 private $eventManager;
83 $this->checkoutSession = $this->createPartialMock(
85 [
'getPaypalTransactionData',
'setPaypalTransactionData']
87 $this->transactionBuilder = $this->getMockForAbstractClass(
88 BuilderInterface::class,
94 $this->nvp = $this->createPartialMock(
97 'setProcessableErrors',
101 'callDoAuthorization',
105 $this->pro = $this->createPartialMock(
107 [
'setMethod',
'getApi',
'importPaymentInfo',
'resetApi']
109 $this->eventManager = $this->getMockBuilder(ManagerInterface::class)
110 ->setMethods([
'dispatch'])
111 ->getMockForAbstractClass();
113 $this->pro->expects($this->any())->method(
'getApi')->will($this->returnValue($this->nvp));
119 $this->nvp->expects($this->once())->method(
'setProcessableErrors')->with($this->errorCodes);
121 $this->model = $this->helper->getObject(
122 \
Magento\Paypal\Model\Express::class,
124 'data' => [$this->pro],
125 'checkoutSession' => $this->checkoutSession,
126 'transactionBuilder' => $this->transactionBuilder,
138 $transactionData = [
'TOKEN' =>
'EC-7NJ4634216284232D'];
139 $this->checkoutSession
140 ->method(
'getPaypalTransactionData')
141 ->willReturn($transactionData);
143 $order = $this->createPartialMock(Order::class, [
'setActionFlag']);
144 $order->method(
'setActionFlag')
148 $paymentModel = $this->createPartialMock(Payment::class, [
'getOrder']);
149 $paymentModel->method(
'getOrder')
152 $this->model = $this->helper->getObject(
153 \
Magento\Paypal\Model\Express::class,
155 'data' => [$this->pro],
156 'checkoutSession' => $this->checkoutSession,
160 $this->nvp->method(
'setData')
161 ->with($transactionData)
164 static::assertEquals($this->model, $this->model->order($paymentModel, 12.3));
169 $transportValue =
'something';
171 $extensionAttribute = $this->getMockForAbstractClass(
182 Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => $transportValue,
183 Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID => $transportValue,
184 Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN => $transportValue,
185 \
Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $extensionAttribute
190 $this->model = $this->helper->getObject(
191 \
Magento\Paypal\Model\Express::class,
193 'data' => [$this->pro],
194 'checkoutSession' => $this->checkoutSession,
195 'transactionBuilder' => $this->transactionBuilder,
196 'eventDispatcher' => $this->eventManager,
203 $this->parentAssignDataExpectation(
$data);
206 ->method(
'setAdditionalInformation')
208 [
Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT, $transportValue],
209 [
Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, $transportValue],
210 [
Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN, $transportValue]
213 $this->model->assignData(
$data);
227 $this->eventManager->expects(static::exactly(2))
232 'payment_method_assign_data_' . $this->model->getCode(),
236 'payment_method_assign_data',
const KEY_ADDITIONAL_DATA
const ACTION_FLAG_INVOICE
testSetApiProcessableErrors()