1111
1212namespace Omnipay \PayPal \Message ;
1313
14+ use Omnipay \Common \CreditCard ;
1415use Omnipay \TestCase ;
1516
1617class ExpressAuthorizeRequestTest extends TestCase
@@ -29,7 +30,7 @@ public function setUp()
2930 );
3031 }
3132
32- public function testGetData ()
33+ public function testGetDataWithoutCard ()
3334 {
3435 $ this ->request ->initialize (array (
3536 'amount ' => '10.00 ' ,
@@ -56,6 +57,67 @@ public function testGetData()
5657 $ this ->assertSame ('https://www.example.com/header.jpg ' , $ data ['HDRIMG ' ]);
5758 }
5859
60+ public function testGetDataWitCard ()
61+ {
62+ $ this ->request ->initialize (array (
63+ 'amount ' => '10.00 ' ,
64+ 'currency ' => 'AUD ' ,
65+ 'transactionId ' => '111 ' ,
66+ 'description ' => 'Order Description ' ,
67+ 'returnUrl ' => 'https://www.example.com/return ' ,
68+ 'cancelUrl ' => 'https://www.example.com/cancel ' ,
69+ 'notifyUrl ' => 'https://www.example.com/notify ' ,
70+ 'subject ' => 'demo@example.com ' ,
71+ 'headerImageUrl ' => 'https://www.example.com/header.jpg ' ,
72+ ));
73+
74+ $ card = new CreditCard (array (
75+ 'name ' => 'John Doe ' ,
76+ 'address1 ' => '123 NW Blvd ' ,
77+ 'address2 ' => 'Lynx Lane ' ,
78+ 'city ' => 'Topeka ' ,
79+ 'state ' => 'KS ' ,
80+ 'country ' => 'USA ' ,
81+ 'postcode ' => '66605 ' ,
82+ 'phone ' => '555-555-5555 ' ,
83+ 'email ' => 'test@email.com ' ,
84+ ));
85+ $ this ->request ->setCard ($ card );
86+
87+ $ expected = array (
88+ 'METHOD ' => 'SetExpressCheckout ' ,
89+ 'VERSION ' => ExpressAuthorizeRequest::API_VERSION ,
90+ 'USER ' => null ,
91+ 'PWD ' => null ,
92+ 'SIGNATURE ' => null ,
93+ 'PAYMENTREQUEST_0_PAYMENTACTION ' => 'Authorization ' ,
94+ 'SOLUTIONTYPE ' => null ,
95+ 'LANDINGPAGE ' => null ,
96+ 'NOSHIPPING ' => 1 ,
97+ 'ALLOWNOTE ' => 0 ,
98+ 'PAYMENTREQUEST_0_AMT ' => '10.00 ' ,
99+ 'PAYMENTREQUEST_0_CURRENCYCODE ' => 'AUD ' ,
100+ 'PAYMENTREQUEST_0_INVNUM ' => '111 ' ,
101+ 'PAYMENTREQUEST_0_DESC ' => 'Order Description ' ,
102+ 'RETURNURL ' => 'https://www.example.com/return ' ,
103+ 'CANCELURL ' => 'https://www.example.com/cancel ' ,
104+ 'PAYMENTREQUEST_0_NOTIFYURL ' => 'https://www.example.com/notify ' ,
105+ 'SUBJECT ' => 'demo@example.com ' ,
106+ 'HDRIMG ' => 'https://www.example.com/header.jpg ' ,
107+ 'PAYMENTREQUEST_0_SHIPTONAME ' => 'John Doe ' ,
108+ 'PAYMENTREQUEST_0_SHIPTOSTREET ' => '123 NW Blvd ' ,
109+ 'PAYMENTREQUEST_0_SHIPTOSTREET2 ' => 'Lynx Lane ' ,
110+ 'PAYMENTREQUEST_0_SHIPTOCITY ' => 'Topeka ' ,
111+ 'PAYMENTREQUEST_0_SHIPTOSTATE ' => 'KS ' ,
112+ 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE ' => 'USA ' ,
113+ 'PAYMENTREQUEST_0_SHIPTOZIP ' => '66605 ' ,
114+ 'PAYMENTREQUEST_0_SHIPTOPHONENUM ' => '555-555-5555 ' ,
115+ 'EMAIL ' => 'test@email.com ' ,
116+ );
117+
118+ $ this ->assertEquals ($ expected , $ this ->request ->getData ());
119+ }
120+
59121 public function testHeaderImageUrl ()
60122 {
61123 $ this ->assertSame ($ this ->request , $ this ->request ->setHeaderImageUrl ('https://www.example.com/header.jpg ' ));
0 commit comments