6 use Omnipay\Tests\TestCase;
8 class ExpressCompletePurchaseRequestTest
extends TestCase
15 public function setUp()
17 $client = $this->getHttpClient();
19 $request = $this->getHttpRequest();
20 $request->query->set(
'PayerID',
'Payer-1234');
21 $request->query->set(
'token',
'TOKEN1234');
28 $this->request->setAmount(
'1.23');
29 $this->request->setCurrency(
'USD');
30 $this->request->setTransactionId(
'ABC-123');
31 $this->request->setUsername(
'testuser');
32 $this->request->setPassword(
'testpass');
33 $this->request->setSignature(
'SIG');
34 $this->request->setSubject(
'SUB');
35 $this->request->setDescription(
'DESC');
36 $this->request->setNotifyUrl(
'https://www.example.com/notify');
37 $this->request->setMaxAmount(
'0.00');
38 $this->request->setTaxAmount(
'0.00');
39 $this->request->setShippingAmount(
'0.00');
40 $this->request->setHandlingAmount(
'0.00');
41 $this->request->setShippingDiscount(
'0.00');
42 $this->request->setInsuranceAmount(
'0.00');
45 $expected[
'METHOD'] =
'DoExpressCheckoutPayment';
46 $expected[
'PAYMENTREQUEST_0_PAYMENTACTION'] =
'Sale';
47 $expected[
'PAYMENTREQUEST_0_AMT'] =
'1.23';
48 $expected[
'PAYMENTREQUEST_0_CURRENCYCODE'] =
'USD';
49 $expected[
'PAYMENTREQUEST_0_INVNUM'] =
'ABC-123';
50 $expected[
'PAYMENTREQUEST_0_DESC'] =
'DESC';
51 $expected[
'PAYMENTREQUEST_0_NOTIFYURL'] =
'https://www.example.com/notify';
52 $expected[
'USER'] =
'testuser';
53 $expected[
'PWD'] =
'testpass';
54 $expected[
'SIGNATURE'] =
'SIG';
55 $expected[
'SUBJECT'] =
'SUB';
57 $expected[
'TOKEN'] =
'TOKEN1234';
58 $expected[
'PAYERID'] =
'Payer-1234';
59 $expected[
'MAXAMT'] =
'0.00';
60 $expected[
'PAYMENTREQUEST_0_TAXAMT'] =
'0.00';
61 $expected[
'PAYMENTREQUEST_0_SHIPPINGAMT'] =
'0.00';
62 $expected[
'PAYMENTREQUEST_0_HANDLINGAMT'] =
'0.00';
63 $expected[
'PAYMENTREQUEST_0_SHIPDISCAMT'] =
'0.00';
64 $expected[
'PAYMENTREQUEST_0_INSURANCEAMT'] =
'0.00';
66 $this->assertEquals($expected, $this->request->getData());
71 $this->request->setAmount(
'50.00');
72 $this->request->setCurrency(
'USD');
73 $this->request->setTransactionId(
'ABC-123');
74 $this->request->setUsername(
'testuser');
75 $this->request->setPassword(
'testpass');
76 $this->request->setSignature(
'SIG');
77 $this->request->setSubject(
'SUB');
78 $this->request->setDescription(
'DESC');
80 $this->request->setItems(array(
81 array(
'name' =>
'Floppy Disk',
'description' =>
'MS-DOS',
'quantity' => 2,
'price' => 10),
82 array(
'name' =>
'CD-ROM',
'description' =>
'Windows 95',
'quantity' => 1,
'price' => 40),
85 $data = $this->request->getData();
86 $this->assertSame(
'Floppy Disk', $data[
'L_PAYMENTREQUEST_0_NAME0']);
87 $this->assertSame(
'MS-DOS', $data[
'L_PAYMENTREQUEST_0_DESC0']);
88 $this->assertSame(2, $data[
'L_PAYMENTREQUEST_0_QTY0']);
89 $this->assertSame(
'10.00', $data[
'L_PAYMENTREQUEST_0_AMT0']);
91 $this->assertSame(
'CD-ROM', $data[
'L_PAYMENTREQUEST_0_NAME1']);
92 $this->assertSame(
'Windows 95', $data[
'L_PAYMENTREQUEST_0_DESC1']);
93 $this->assertSame(1, $data[
'L_PAYMENTREQUEST_0_QTY1']);
94 $this->assertSame(
'40.00', $data[
'L_PAYMENTREQUEST_0_AMT1']);