|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\SagePay\Message; |
| 4 | + |
| 5 | +use Omnipay\Tests\TestCase; |
| 6 | + |
| 7 | +class DirectPurchaseRequestTest extends DirectAuthorizeRequestTest |
| 8 | +{ |
| 9 | + // VISA incurrs a surcharge of 2.5% when used. |
| 10 | + const SURCHARGE_XML = '<surcharges><surcharge>' |
| 11 | + . '<paymentType>VISA</paymentType><percentage>2.50</percentage>' |
| 12 | + . '</surcharge></surcharges>'; |
| 13 | + |
| 14 | + /** |
| 15 | + * @var DirectAuthorizeRequest |
| 16 | + */ |
| 17 | + protected $request; |
| 18 | + |
| 19 | + public function setUp() |
| 20 | + { |
| 21 | + parent::setUp(); |
| 22 | + |
| 23 | + $this->request = new DirectPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 24 | + |
| 25 | + $this->request->initialize( |
| 26 | + array( |
| 27 | + // Money as Omnipay 3.x Money object, combining currency and amount |
| 28 | + // Omnipay 3.0-RC2 no longer accepts a money object. |
| 29 | + 'amount' => '12.00', //Money::GBP(1200), |
| 30 | + 'currency' => 'GBP', |
| 31 | + 'transactionId' => '123', |
| 32 | + 'surchargeXml' => self::SURCHARGE_XML, |
| 33 | + 'card' => $this->getValidCard(), |
| 34 | + 'language' => 'EN', |
| 35 | + ) |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + public function testGetDataDefaults() |
| 40 | + { |
| 41 | + $data = $this->request->getData(); |
| 42 | + |
| 43 | + $this->assertSame('E', $data['AccountType']); |
| 44 | + $this->assertSame(0, $data['ApplyAVSCV2']); |
| 45 | + $this->assertSame(0, $data['Apply3DSecure']); |
| 46 | + |
| 47 | + $this->assertSame('PAYMENT', $data['TxType']); |
| 48 | + $this->assertSame('vspdirect-register', $this->request->getService()); |
| 49 | + |
| 50 | + // If we have not explicitly set the CreateToken flag, then it remains |
| 51 | + // undefined. This allows it to default when creating a transaction |
| 52 | + // according to whether we are using a single-use token or a more |
| 53 | + // permanent cardReference. |
| 54 | + |
| 55 | + $this->assertArrayNotHasKey('CreateToken', $data); |
| 56 | + |
| 57 | + $this->assertSame('EN', $data['Language']); |
| 58 | + } |
| 59 | +} |
0 commit comments