public function testGetDataWithCard() { $this->request->initialize(array('amount' => '10.00', 'currency' => 'AUD', 'transactionId' => '111', 'description' => 'Order Description', 'returnUrl' => 'https://www.example.com/return', 'cancelUrl' => 'https://www.example.com/cancel', 'notifyUrl' => 'https://www.example.com/notify', 'subject' => '*****@*****.**', 'headerImageUrl' => 'https://www.example.com/header.jpg', 'noShipping' => 2, 'allowNote' => 1)); $card = new CreditCard(array('name' => 'John Doe', 'address1' => '123 NW Blvd', 'address2' => 'Lynx Lane', 'city' => 'Topeka', 'state' => 'KS', 'country' => 'USA', 'postcode' => '66605', 'phone' => '555-555-5555', 'email' => '*****@*****.**')); $this->request->setCard($card); $expected = array('METHOD' => 'SetExpressCheckout', 'VERSION' => ExpressAuthorizeRequest::API_VERSION, 'USER' => null, 'PWD' => null, 'SIGNATURE' => null, 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization', 'SOLUTIONTYPE' => null, 'LANDINGPAGE' => null, 'NOSHIPPING' => 2, 'ALLOWNOTE' => 1, 'PAYMENTREQUEST_0_AMT' => '10.00', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'AUD', 'PAYMENTREQUEST_0_INVNUM' => '111', 'PAYMENTREQUEST_0_DESC' => 'Order Description', 'RETURNURL' => 'https://www.example.com/return', 'CANCELURL' => 'https://www.example.com/cancel', 'PAYMENTREQUEST_0_NOTIFYURL' => 'https://www.example.com/notify', 'SUBJECT' => '*****@*****.**', 'HDRIMG' => 'https://www.example.com/header.jpg', 'PAYMENTREQUEST_0_SHIPTONAME' => 'John Doe', 'PAYMENTREQUEST_0_SHIPTOSTREET' => '123 NW Blvd', 'PAYMENTREQUEST_0_SHIPTOSTREET2' => 'Lynx Lane', 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Topeka', 'PAYMENTREQUEST_0_SHIPTOSTATE' => 'KS', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'USA', 'PAYMENTREQUEST_0_SHIPTOZIP' => '66605', 'PAYMENTREQUEST_0_SHIPTOPHONENUM' => '555-555-5555', 'EMAIL' => '*****@*****.**'); $this->assertEquals($expected, $this->request->getData()); }
public function testGetDataWithExtraOrderDetails() { $this->request->initialize(array('amount' => '10.00', 'currency' => 'AUD', 'transactionId' => '111', 'description' => 'Order Description', 'returnUrl' => 'https://www.example.com/return', 'cancelUrl' => 'https://www.example.com/cancel', 'subject' => '*****@*****.**', 'headerImageUrl' => 'https://www.example.com/header.jpg', 'noShipping' => 0, 'allowNote' => 0, 'addressOverride' => 0, 'brandName' => 'Dunder Mifflin Paper Company, Inc.', 'taxAmount' => '2.00', 'shippingAmount' => '5.00', 'handlingAmount' => '1.00', 'shippingDiscount' => '-1.00', 'insuranceAmount' => '3.00')); $data = $this->request->getData(); $this->assertSame('2.00', $data['PAYMENTREQUEST_0_TAXAMT']); $this->assertSame('5.00', $data['PAYMENTREQUEST_0_SHIPPINGAMT']); $this->assertSame('1.00', $data['PAYMENTREQUEST_0_HANDLINGAMT']); $this->assertSame('-1.00', $data['PAYMENTREQUEST_0_SHIPDISCAMT']); $this->assertSame('3.00', $data['PAYMENTREQUEST_0_INSURANCEAMT']); }
public function testBadCallbackConfiguration() { $baseData = array('amount' => '10.00', 'currency' => 'AUD', 'transactionId' => '111', 'description' => 'Order Description', 'returnUrl' => 'https://www.example.com/return', 'cancelUrl' => 'https://www.example.com/cancel', 'subject' => '*****@*****.**', 'headerImageUrl' => 'https://www.example.com/header.jpg', 'allowNote' => 0, 'addressOverride' => 0, 'brandName' => 'Dunder Mifflin Paper Company, Incy.'); $this->request->initialize(array_merge($baseData, array('callback' => 'https://www.example.com/calculate-shipping'))); // from the docblock on this exception - // Thrown when a request is invalid or missing required fields. // callback has been set but no shipping options so expect one of these: $this->setExpectedException('\\Omnipay\\Common\\Exception\\InvalidRequestException'); $this->request->getData(); }