|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\NABTransact\Message; |
| 4 | + |
| 5 | +use Omnipay\Tests\TestCase; |
| 6 | + |
| 7 | +class SecureXMLAuthorizeRequestTest extends TestCase |
| 8 | +{ |
| 9 | + public function setUp() |
| 10 | + { |
| 11 | + $this->request = new SecureXMLAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 12 | + |
| 13 | + $this->request->initialize( |
| 14 | + array( |
| 15 | + 'merchantId' => 'XYZ0010', |
| 16 | + 'transactionPassword' => 'abcd1234', |
| 17 | + 'testMode' => true, |
| 18 | + 'amount' => '12.00', |
| 19 | + 'transactionId' => '1234', |
| 20 | + 'card' => array( |
| 21 | + 'number' => '4444333322221111', |
| 22 | + 'expiryMonth' => '10', |
| 23 | + 'expiryYear' => '2030', |
| 24 | + 'cvv' => '123', |
| 25 | + 'cardHolderName' => 'Sujip Thapa', |
| 26 | + ), |
| 27 | + ) |
| 28 | + ); |
| 29 | + } |
| 30 | + |
| 31 | + public function testSendSuccess() |
| 32 | + { |
| 33 | + $data = array(); |
| 34 | + |
| 35 | + $data['RequestType'] = 'Payment'; |
| 36 | + $data['statusDescription'] = 'Normal'; |
| 37 | + $data['statusCode'] = '000'; |
| 38 | + $data['apiVersion'] = 'xml-4.2'; |
| 39 | + $data['txnType'] = '10'; |
| 40 | + $data['txnSource'] = '23'; |
| 41 | + $data['amount'] = '12.00'; |
| 42 | + $data['currency'] = 'AUD'; |
| 43 | + $data['approved'] = 'Yes'; |
| 44 | + $data['responseCode'] = '00'; |
| 45 | + $data['responseText'] = 'Approved'; |
| 46 | + $data['txnID'] = '1234'; |
| 47 | + $data['cardDescription'] = 'Visa'; |
| 48 | + $data['expiryDate'] = '10/30'; |
| 49 | + $data['cardType'] = '6'; |
| 50 | + |
| 51 | + $response = new SecureXMLResponse($this->getMockRequest(), $data); |
| 52 | + |
| 53 | + $response = $this->request->send(); |
| 54 | + |
| 55 | + $data = $response->getData(); |
| 56 | + |
| 57 | + $this->assertInstanceOf('Omnipay\NABTransact\Message\SecureXMLResponse', $response); |
| 58 | + |
| 59 | + $this->assertTrue($response->isSuccessful()); |
| 60 | + $this->assertFalse($response->isRedirect()); |
| 61 | + $this->assertSame('23', $response->getTransactionSource()); |
| 62 | + $this->assertSame('AUD', $response->getTransactionCurrency()); |
| 63 | + $this->assertSame('1200', $response->getTransactionAmount()); |
| 64 | + $this->assertNotNull($response->getSettlementDate()); |
| 65 | + $this->assertNotNull($response->getTransactionId()); |
| 66 | + $this->assertSame('Approved', $response->getMessage()); |
| 67 | + $this->assertSame('00', $response->getCode()); |
| 68 | + $this->assertSame('10', (string) $data->Payment->TxnList->Txn->txnType); |
| 69 | + } |
| 70 | + |
| 71 | + public function testSetMessageId() |
| 72 | + { |
| 73 | + $this->request->setMessageId('8af793f9af34bea0cf40f5fc011e0c'); |
| 74 | + $this->assertSame('8af793f9af34bea0cf40f5fc011e0c', $this->request->getMessageId()); |
| 75 | + } |
| 76 | + |
| 77 | + public function testAutogeneratedMessageId() |
| 78 | + { |
| 79 | + $this->assertNotNull($this->request->getMessageId()); |
| 80 | + $this->assertSame(30, strlen($this->request->getMessageId())); |
| 81 | + } |
| 82 | +} |
0 commit comments