From dfeb46bfa14d854e4ac7c61803bcd8792cfeb054 Mon Sep 17 00:00:00 2001 From: Sujip Thapa Date: Fri, 25 Nov 2016 15:32:54 +0545 Subject: [PATCH 1/8] Added DirectPost v2 --- src/DirectPostGateway.php | 100 ++++++++++++++++++ src/Message/DirectPostAbstractRequest.php | 19 ++++ src/Message/DirectPostAuthorizeRequest.php | 85 +++++++++++++++ src/Message/DirectPostAuthorizeResponse.php | 61 +++++++++++ .../DirectPostCompletePurchaseRequest.php | 54 ++++++++++ .../DirectPostCompletePurchaseResponse.php | 46 ++++++++ src/Message/DirectPostPurchaseRequest.php | 14 +++ tests/DirectPostGatewayTest.php | 48 +++++++++ .../DirectPostAuthorizeRequestTest.php | 55 ++++++++++ .../DirectPostCompletePurchaseRequestTest.php | 96 +++++++++++++++++ 10 files changed, 578 insertions(+) create mode 100644 src/DirectPostGateway.php create mode 100644 src/Message/DirectPostAbstractRequest.php create mode 100644 src/Message/DirectPostAuthorizeRequest.php create mode 100644 src/Message/DirectPostAuthorizeResponse.php create mode 100644 src/Message/DirectPostCompletePurchaseRequest.php create mode 100644 src/Message/DirectPostCompletePurchaseResponse.php create mode 100644 src/Message/DirectPostPurchaseRequest.php create mode 100644 tests/DirectPostGatewayTest.php create mode 100644 tests/Message/DirectPostAuthorizeRequestTest.php create mode 100644 tests/Message/DirectPostCompletePurchaseRequestTest.php diff --git a/src/DirectPostGateway.php b/src/DirectPostGateway.php new file mode 100644 index 0000000..03d5105 --- /dev/null +++ b/src/DirectPostGateway.php @@ -0,0 +1,100 @@ + '', + 'transactionPassword' => '', + 'testMode' => false, + ); + } + + /** + * @return mixed + */ + public function getMerchantId() + { + return $this->getParameter('merchantId'); + } + + /** + * @param $value + * @return mixed + */ + public function setMerchantId($value) + { + return $this->setParameter('merchantId', $value); + } + + /** + * @return mixed + */ + public function getTransactionPassword() + { + return $this->getParameter('transactionPassword'); + } + + /** + * @param $value + * @return mixed + */ + public function setTransactionPassword($value) + { + return $this->setParameter('transactionPassword', $value); + } + + /** + * @param array $parameters + * @return mixed + */ + public function authorize(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NABTransact\Message\DirectPostAuthorizeRequest', $parameters); + } + + /** + * @param array $parameters + * @return mixed + */ + public function completeAuthorize(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest', $parameters); + } + + /** + * @param array $parameters + * @return mixed + */ + public function purchase(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NABTransact\Message\DirectPostPurchaseRequest', $parameters); + } + + /** + * @param array $parameters + * @return mixed + */ + public function completePurchase(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest', $parameters); + } +} diff --git a/src/Message/DirectPostAbstractRequest.php b/src/Message/DirectPostAbstractRequest.php new file mode 100644 index 0000000..3723dae --- /dev/null +++ b/src/Message/DirectPostAbstractRequest.php @@ -0,0 +1,19 @@ +validate('amount', 'returnUrl', 'card'); + + $data = array(); + $data['EPS_MERCHANT'] = $this->getMerchantId(); + $data['EPS_TXNTYPE'] = $this->txnType; + $data['EPS_IP'] = $this->getClientIp(); + $data['EPS_AMOUNT'] = $this->getAmount(); + $data['EPS_REFERENCEID'] = $this->getTransactionId(); + $data['EPS_TIMESTAMP'] = gmdate('YmdHis'); + $data['EPS_FINGERPRINT'] = $this->generateFingerprint($data); + $data['EPS_RESULTURL'] = $this->getReturnUrl(); + $data['EPS_CALLBACKURL'] = $this->getNotifyUrl() ?: $this->getReturnUrl(); + $data['EPS_REDIRECT'] = 'TRUE'; + $data['EPS_CURRENCY'] = $this->getCurrency(); + + $data = array_replace($data, $this->getCardData()); + + return $data; + } + + /** + * @param array $data + */ + public function generateFingerprint(array $data) + { + $hash = implode( + '|', + array( + $data['EPS_MERCHANT'], + $this->getTransactionPassword(), + $data['EPS_TXNTYPE'], + $data['EPS_REFERENCEID'], + $data['EPS_AMOUNT'], + $data['EPS_TIMESTAMP'], + ) + ); + + return sha1($hash); + } + + /** + * @param $data + * @return mixed + */ + public function sendData($data) + { + return $this->response = new DirectPostAuthorizeResponse($this, $data, $this->getEndpoint()); + } + + /** + * @return mixed + */ + protected function getCardData() + { + $this->getCard()->validate(); + + $data = array(); + + $data['EPS_CARDNUMBER'] = $this->getCard()->getNumber(); + $data['EPS_EXPIRYMONTH'] = $this->getCard()->getExpiryMonth(); + $data['EPS_EXPIRYYEAR'] = $this->getCard()->getExpiryYear(); + $data['EPS_CCV'] = $this->getCard()->getCvv(); + + return $data; + } +} diff --git a/src/Message/DirectPostAuthorizeResponse.php b/src/Message/DirectPostAuthorizeResponse.php new file mode 100644 index 0000000..9eee7fd --- /dev/null +++ b/src/Message/DirectPostAuthorizeResponse.php @@ -0,0 +1,61 @@ +request = $request; + $this->data = $data; + $this->redirectUrl = $redirectUrl; + } + + public function isSuccessful() + { + return false; + } + + public function isRedirect() + { + return true; + } + + /** + * @return mixed + */ + public function getRedirectUrl() + { + return $this->redirectUrl; + } + + public function getRedirectMethod() + { + return 'POST'; + } + + /** + * @return mixed + */ + public function getRedirectData() + { + return $this->getData(); + } +} diff --git a/src/Message/DirectPostCompletePurchaseRequest.php b/src/Message/DirectPostCompletePurchaseRequest.php new file mode 100644 index 0000000..3b145c9 --- /dev/null +++ b/src/Message/DirectPostCompletePurchaseRequest.php @@ -0,0 +1,54 @@ +httpRequest->query->all(); + + if ($this->generateResponseFingerprint($data) !== $this->httpRequest->query->get('fingerprint')) { + throw new InvalidRequestException('Invalid fingerprint'); + } + + return $data; + } + + /** + * @param $data + */ + public function generateResponseFingerprint($data) + { + $fields = implode( + '|', + array( + $data['merchant'], + $this->getTransactionPassword(), + $data['refid'], + $this->getAmount(), + $data['timestamp'], + $data['summarycode'], + ) + ); + + return sha1($fields); + } + + /** + * @param $data + * @return mixed + */ + public function sendData($data) + { + return $this->response = new DirectPostCompletePurchaseResponse($this, $data); + } +} diff --git a/src/Message/DirectPostCompletePurchaseResponse.php b/src/Message/DirectPostCompletePurchaseResponse.php new file mode 100644 index 0000000..c52440a --- /dev/null +++ b/src/Message/DirectPostCompletePurchaseResponse.php @@ -0,0 +1,46 @@ +data['summarycode']) && $this->data['summarycode'] == 1; + } + + /** + * @return mixed + */ + public function getMessage() + { + if (isset($this->data['restext'])) { + return $this->data['restext']; + } + } + + /** + * @return mixed + */ + public function getCode() + { + if (isset($this->data['rescode'])) { + return $this->data['rescode']; + } + } + + /** + * @return mixed + */ + public function getTransactionReference() + { + if (isset($this->data['txnid'])) { + return $this->data['txnid']; + } + } +} diff --git a/src/Message/DirectPostPurchaseRequest.php b/src/Message/DirectPostPurchaseRequest.php new file mode 100644 index 0000000..eb86e13 --- /dev/null +++ b/src/Message/DirectPostPurchaseRequest.php @@ -0,0 +1,14 @@ +gateway = new DirectPostGateway($this->getHttpClient(), $this->getHttpRequest()); + $this->gateway->setMerchantId('XYZ0010'); + } + + public function testAuthorize() + { + $request = $this->gateway->authorize(array('amount' => '10.00')); + + $this->assertInstanceOf('\Omnipay\NABTransact\Message\DirectPostAuthorizeRequest', $request); + $this->assertSame('10.00', $request->getAmount()); + } + + public function testCompleteAuthorize() + { + $request = $this->gateway->completeAuthorize(array('amount' => '10.00')); + + $this->assertInstanceOf('\Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest', $request); + $this->assertSame('10.00', $request->getAmount()); + } + + public function testPurchase() + { + $request = $this->gateway->purchase(array('amount' => '10.00')); + + $this->assertInstanceOf('\Omnipay\NABTransact\Message\DirectPostPurchaseRequest', $request); + $this->assertSame('10.00', $request->getAmount()); + } + + public function testCompletePurchase() + { + $request = $this->gateway->completePurchase(array('amount' => '10.00')); + + $this->assertInstanceOf('\Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest', $request); + $this->assertSame('10.00', $request->getAmount()); + } +} diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php new file mode 100644 index 0000000..eb3905c --- /dev/null +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -0,0 +1,55 @@ +request = new DirectPostAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); + + $this->request->initialize( + array( + 'merchantId' => 'foo', + 'transactionPassword' => 'bar', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', + 'expiryMonth' => '6', + 'expiryYear' => '2030', + 'cvv' => '123', + ), + ) + ); + } + + public function testFingerprint() + { + $data = $this->request->getData(); + $data['EPS_TIMESTAMP'] = '20130416123332'; + + $this->assertSame('46b6a59173c9fea66f71b8679558837895f0bce8', $this->request->generateFingerprint($data)); + } + + public function testSend() + { + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostAuthorizeResponse', $response); + $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertNull($response->getMessage()); + $this->assertNull($response->getCode()); + + $this->assertSame('https://transact.nab.com.au/live/directpostv2/authorise', $response->getRedirectUrl()); + $this->assertSame('POST', $response->getRedirectMethod()); + + $data = $response->getData(); + $this->assertArrayHasKey('EPS_FINGERPRINT', $data); + $this->assertSame('1', $data['EPS_TXNTYPE']); + } +} diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php new file mode 100644 index 0000000..90d40cb --- /dev/null +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -0,0 +1,96 @@ +request = new DirectPostCompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + } + + public function testGenerateResponseFingerprint() + { + $this->request->initialize(array( + 'amount' => '465.18', + 'transactionPassword' => 'abc123', + )); + + $data = array( + 'timestamp' => '20130602102927', + 'merchant' => 'ABC0030', + 'refid' => '222', + 'summarycode' => '2', + ); + + $this->assertSame('0516a31bf96ad89c354266afb9bd4be43aaf853f', $this->request->generateResponseFingerprint($data)); + } + + public function testSuccess() + { + $this->request->initialize(array( + 'amount' => '355.00', + 'transactionPassword' => 'abc123', + )); + + $this->getHttpRequest()->query->replace(array( + 'timestamp' => '20130602112954', + 'callback_status_code' => '', + 'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce', + 'txnid' => '205861', + 'merchant' => 'ABC0030', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '032016', + 'settdate' => '20130602', + 'refid' => '226', + 'pan' => '444433...111', + 'summarycode' => '1', + )); + + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse', $response); + + $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertSame('205861', $response->getTransactionReference()); + $this->assertSame('Approved', $response->getMessage()); + $this->assertSame('00', $response->getCode()); + } + + public function testFailure() + { + $this->request->initialize(array( + 'amount' => '465.18', + 'transactionPassword' => 'abc123', + )); + + $this->getHttpRequest()->query->replace(array( + 'timestamp' => '20130602102927', + 'callback_status_code' => '', + 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', + 'txnid' => '205833', + 'merchant' => 'ABC0030', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '052016', + 'settdate' => '20130602', + 'refid' => '222', + 'pan' => '444433...111', + 'summarycode' => '2', + )); + + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse', $response); + + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertSame('205833', $response->getTransactionReference()); + $this->assertSame('Customer Dispute', $response->getMessage()); + $this->assertSame('18', $response->getCode()); + } +} \ No newline at end of file From 04e30ef3858ef6e2e5afed0a0665a2195aa5c340 Mon Sep 17 00:00:00 2001 From: sudiptpa Date: Fri, 25 Nov 2016 09:48:18 +0000 Subject: [PATCH 2/8] Applied fixes from StyleCI --- src/DirectPostGateway.php | 12 +++- src/Message/DirectPostAbstractRequest.php | 2 +- src/Message/DirectPostAuthorizeRequest.php | 3 +- src/Message/DirectPostAuthorizeResponse.php | 2 +- .../DirectPostCompletePurchaseRequest.php | 3 +- .../DirectPostCompletePurchaseResponse.php | 2 +- src/Message/DirectPostPurchaseRequest.php | 2 +- .../DirectPostAuthorizeRequestTest.php | 14 ++--- .../DirectPostCompletePurchaseRequestTest.php | 58 +++++++++---------- 9 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/DirectPostGateway.php b/src/DirectPostGateway.php index 03d5105..2df2f2d 100644 --- a/src/DirectPostGateway.php +++ b/src/DirectPostGateway.php @@ -5,7 +5,7 @@ use Omnipay\Common\AbstractGateway; /** - * NABTransact Direct Post Gateway + * NABTransact Direct Post Gateway. */ class DirectPostGateway extends AbstractGateway { @@ -22,9 +22,9 @@ public function getName() public function getDefaultParameters() { return array( - 'merchantId' => '', + 'merchantId' => '', 'transactionPassword' => '', - 'testMode' => false, + 'testMode' => false, ); } @@ -38,6 +38,7 @@ public function getMerchantId() /** * @param $value + * * @return mixed */ public function setMerchantId($value) @@ -55,6 +56,7 @@ public function getTransactionPassword() /** * @param $value + * * @return mixed */ public function setTransactionPassword($value) @@ -64,6 +66,7 @@ public function setTransactionPassword($value) /** * @param array $parameters + * * @return mixed */ public function authorize(array $parameters = array()) @@ -73,6 +76,7 @@ public function authorize(array $parameters = array()) /** * @param array $parameters + * * @return mixed */ public function completeAuthorize(array $parameters = array()) @@ -82,6 +86,7 @@ public function completeAuthorize(array $parameters = array()) /** * @param array $parameters + * * @return mixed */ public function purchase(array $parameters = array()) @@ -91,6 +96,7 @@ public function purchase(array $parameters = array()) /** * @param array $parameters + * * @return mixed */ public function completePurchase(array $parameters = array()) diff --git a/src/Message/DirectPostAbstractRequest.php b/src/Message/DirectPostAbstractRequest.php index 3723dae..0446427 100644 --- a/src/Message/DirectPostAbstractRequest.php +++ b/src/Message/DirectPostAbstractRequest.php @@ -3,7 +3,7 @@ namespace Omnipay\NABTransact\Message; /** - * NABTransact Direct Post Abstract Request + * NABTransact Direct Post Abstract Request. */ abstract class DirectPostAbstractRequest extends AbstractRequest { diff --git a/src/Message/DirectPostAuthorizeRequest.php b/src/Message/DirectPostAuthorizeRequest.php index 6c81ced..30f63ea 100644 --- a/src/Message/DirectPostAuthorizeRequest.php +++ b/src/Message/DirectPostAuthorizeRequest.php @@ -3,7 +3,7 @@ namespace Omnipay\NABTransact\Message; /** - * NABTransact Direct Post Authorize Request + * NABTransact Direct Post Authorize Request. */ class DirectPostAuthorizeRequest extends DirectPostAbstractRequest { @@ -59,6 +59,7 @@ public function generateFingerprint(array $data) /** * @param $data + * * @return mixed */ public function sendData($data) diff --git a/src/Message/DirectPostAuthorizeResponse.php b/src/Message/DirectPostAuthorizeResponse.php index 9eee7fd..03c3f3d 100644 --- a/src/Message/DirectPostAuthorizeResponse.php +++ b/src/Message/DirectPostAuthorizeResponse.php @@ -7,7 +7,7 @@ use Omnipay\Common\Message\RequestInterface; /** - * NABTransact Direct Post Authorize Response + * NABTransact Direct Post Authorize Response. */ class DirectPostAuthorizeResponse extends AbstractResponse implements RedirectResponseInterface { diff --git a/src/Message/DirectPostCompletePurchaseRequest.php b/src/Message/DirectPostCompletePurchaseRequest.php index 3b145c9..c83ee13 100644 --- a/src/Message/DirectPostCompletePurchaseRequest.php +++ b/src/Message/DirectPostCompletePurchaseRequest.php @@ -5,7 +5,7 @@ use Omnipay\Common\Exception\InvalidRequestException; /** - * NABTransact Direct Post Complete Purchase Request + * NABTransact Direct Post Complete Purchase Request. */ class DirectPostCompletePurchaseRequest extends DirectPostAbstractRequest { @@ -45,6 +45,7 @@ public function generateResponseFingerprint($data) /** * @param $data + * * @return mixed */ public function sendData($data) diff --git a/src/Message/DirectPostCompletePurchaseResponse.php b/src/Message/DirectPostCompletePurchaseResponse.php index c52440a..c59972b 100644 --- a/src/Message/DirectPostCompletePurchaseResponse.php +++ b/src/Message/DirectPostCompletePurchaseResponse.php @@ -5,7 +5,7 @@ use Omnipay\Common\Message\AbstractResponse; /** - * NABTransact Direct Post Complete Purchase Response + * NABTransact Direct Post Complete Purchase Response. */ class DirectPostCompletePurchaseResponse extends AbstractResponse { diff --git a/src/Message/DirectPostPurchaseRequest.php b/src/Message/DirectPostPurchaseRequest.php index eb86e13..34a33a3 100644 --- a/src/Message/DirectPostPurchaseRequest.php +++ b/src/Message/DirectPostPurchaseRequest.php @@ -3,7 +3,7 @@ namespace Omnipay\NABTransact\Message; /** - * NABTransact Direct Post Purchase Request + * NABTransact Direct Post Purchase Request. */ class DirectPostPurchaseRequest extends DirectPostAuthorizeRequest { diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php index eb3905c..6244b88 100644 --- a/tests/Message/DirectPostAuthorizeRequestTest.php +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', + 'merchantId' => 'foo', 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.abc.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2030', - 'cvv' => '123', + 'expiryYear' => '2030', + 'cvv' => '123', ), ) ); diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php index 90d40cb..fe8fcfe 100644 --- a/tests/Message/DirectPostCompletePurchaseRequestTest.php +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -14,14 +14,14 @@ public function setUp() public function testGenerateResponseFingerprint() { $this->request->initialize(array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abc123', )); $data = array( - 'timestamp' => '20130602102927', - 'merchant' => 'ABC0030', - 'refid' => '222', + 'timestamp' => '20130602102927', + 'merchant' => 'ABC0030', + 'refid' => '222', 'summarycode' => '2', ); @@ -31,23 +31,23 @@ public function testGenerateResponseFingerprint() public function testSuccess() { $this->request->initialize(array( - 'amount' => '355.00', + 'amount' => '355.00', 'transactionPassword' => 'abc123', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602112954', + 'timestamp' => '20130602112954', 'callback_status_code' => '', - 'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce', - 'txnid' => '205861', - 'merchant' => 'ABC0030', - 'restext' => 'Approved', - 'rescode' => '00', - 'expirydate' => '032016', - 'settdate' => '20130602', - 'refid' => '226', - 'pan' => '444433...111', - 'summarycode' => '1', + 'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce', + 'txnid' => '205861', + 'merchant' => 'ABC0030', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '032016', + 'settdate' => '20130602', + 'refid' => '226', + 'pan' => '444433...111', + 'summarycode' => '1', )); $response = $this->request->send(); @@ -64,23 +64,23 @@ public function testSuccess() public function testFailure() { $this->request->initialize(array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abc123', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602102927', + 'timestamp' => '20130602102927', 'callback_status_code' => '', - 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', - 'txnid' => '205833', - 'merchant' => 'ABC0030', - 'restext' => 'Customer Dispute', - 'rescode' => '18', - 'expirydate' => '052016', - 'settdate' => '20130602', - 'refid' => '222', - 'pan' => '444433...111', - 'summarycode' => '2', + 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', + 'txnid' => '205833', + 'merchant' => 'ABC0030', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '052016', + 'settdate' => '20130602', + 'refid' => '222', + 'pan' => '444433...111', + 'summarycode' => '2', )); $response = $this->request->send(); @@ -93,4 +93,4 @@ public function testFailure() $this->assertSame('Customer Dispute', $response->getMessage()); $this->assertSame('18', $response->getCode()); } -} \ No newline at end of file +} From 2036ac4b2e355bff7c0a7e508c72be9a7fb31c70 Mon Sep 17 00:00:00 2001 From: Sujip Thapa Date: Fri, 25 Nov 2016 15:40:02 +0545 Subject: [PATCH 3/8] Added more tests --- .../Message/DirectPostPurchaseRequestTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/Message/DirectPostPurchaseRequestTest.php diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php new file mode 100644 index 0000000..74b34dc --- /dev/null +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -0,0 +1,55 @@ +request = new DirectPostPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + + $this->request->initialize( + array( + 'merchantId' => 'foo', + 'transactionPassword' => 'bar', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', + 'expiryMonth' => '6', + 'expiryYear' => '2020', + 'cvv' => '123', + ), + ) + ); + } + + public function testFingerprint() + { + $data = $this->request->getData(); + $data['EPS_TIMESTAMP'] = '20130416123332'; + + $this->assertSame('652856e75b04c5916a41082e04c9390961497f65', $this->request->generateFingerprint($data)); + } + + public function testSend() + { + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostAuthorizeResponse', $response); + $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertNull($response->getMessage()); + $this->assertNull($response->getCode()); + + $this->assertSame('https://transact.nab.com.au/live/directpostv2/authorise', $response->getRedirectUrl()); + $this->assertSame('POST', $response->getRedirectMethod()); + + $data = $response->getData(); + $this->assertArrayHasKey('EPS_FINGERPRINT', $data); + $this->assertSame('0', $data['EPS_TXNTYPE']); + } +} From 48bb575e0ee9e3095c9c0d14b4d5e288a5a5d0ec Mon Sep 17 00:00:00 2001 From: sudiptpa Date: Fri, 25 Nov 2016 09:56:03 +0000 Subject: [PATCH 4/8] Applied fixes from StyleCI --- tests/Message/DirectPostPurchaseRequestTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php index 74b34dc..fcbb7a2 100644 --- a/tests/Message/DirectPostPurchaseRequestTest.php +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', + 'merchantId' => 'foo', 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.example.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2020', - 'cvv' => '123', + 'expiryYear' => '2020', + 'cvv' => '123', ), ) ); From 0a5f683ec4f1c7c7ed99a1b4356e50a122582b8b Mon Sep 17 00:00:00 2001 From: Sujip Thapa Date: Fri, 25 Nov 2016 18:56:51 +0545 Subject: [PATCH 5/8] Fixed some tests --- .../DirectPostAuthorizeRequestTest.php | 14 +-- .../DirectPostCompletePurchaseRequestTest.php | 91 +++++++++++-------- .../Message/DirectPostPurchaseRequestTest.php | 23 ++--- 3 files changed, 70 insertions(+), 58 deletions(-) diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php index 6244b88..eb3905c 100644 --- a/tests/Message/DirectPostAuthorizeRequestTest.php +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', + 'merchantId' => 'foo', 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.abc.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2030', - 'cvv' => '123', + 'expiryYear' => '2030', + 'cvv' => '123', ), ) ); diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php index fe8fcfe..2a4f16e 100644 --- a/tests/Message/DirectPostCompletePurchaseRequestTest.php +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -13,50 +13,61 @@ public function setUp() public function testGenerateResponseFingerprint() { - $this->request->initialize(array( - 'amount' => '465.18', - 'transactionPassword' => 'abc123', - )); + $this->request->initialize( + array( + 'amount' => '465.18', + 'transactionPassword' => 'abcd1234', + ) + ); $data = array( - 'timestamp' => '20130602102927', - 'merchant' => 'ABC0030', - 'refid' => '222', + 'timestamp' => '20161125123332', + 'merchant' => 'XYZ0010', + 'refid' => '222', 'summarycode' => '2', ); - $this->assertSame('0516a31bf96ad89c354266afb9bd4be43aaf853f', $this->request->generateResponseFingerprint($data)); + $this->assertSame('79200d1df5dc3f914a90ce476fdef317d224629f', + $this->request->generateResponseFingerprint($data)); } public function testSuccess() { - $this->request->initialize(array( - 'amount' => '355.00', - 'transactionPassword' => 'abc123', - )); + $this->request->initialize( + array( + 'amount' => '12.00', + 'transactionPassword' => 'abcd1234', + 'transactionId' => 'ORDER-ZYX8', + ) + ); - $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602112954', - 'callback_status_code' => '', - 'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce', - 'txnid' => '205861', - 'merchant' => 'ABC0030', - 'restext' => 'Approved', - 'rescode' => '00', - 'expirydate' => '032016', - 'settdate' => '20130602', - 'refid' => '226', - 'pan' => '444433...111', - 'summarycode' => '1', - )); + $this->getHttpRequest()->query->replace( + array( + 'timestamp' => '20161125130241', + 'callback_status_code' => '-1', + 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', + 'txnid' => '271337', + 'merchant' => 'XYZ0010', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '20161126', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '1', + ) + ); $response = $this->request->send(); - $this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse', $response); + $this->assertInstanceOf( + 'Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse', + $response + ); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); - $this->assertSame('205861', $response->getTransactionReference()); + $this->assertSame('271337', $response->getTransactionReference()); $this->assertSame('Approved', $response->getMessage()); $this->assertSame('00', $response->getCode()); } @@ -64,23 +75,23 @@ public function testSuccess() public function testFailure() { $this->request->initialize(array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abc123', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602102927', + 'timestamp' => '20130602102927', 'callback_status_code' => '', - 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', - 'txnid' => '205833', - 'merchant' => 'ABC0030', - 'restext' => 'Customer Dispute', - 'rescode' => '18', - 'expirydate' => '052016', - 'settdate' => '20130602', - 'refid' => '222', - 'pan' => '444433...111', - 'summarycode' => '2', + 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', + 'txnid' => '205833', + 'merchant' => 'ABC0030', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '052016', + 'settdate' => '20130602', + 'refid' => '222', + 'pan' => '444433...111', + 'summarycode' => '2', )); $response = $this->request->send(); diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php index fcbb7a2..38898f2 100644 --- a/tests/Message/DirectPostPurchaseRequestTest.php +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', - 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.example.com/return', - 'card' => array( - 'number' => '4444333322221111', - 'expiryMonth' => '6', - 'expiryYear' => '2020', - 'cvv' => '123', + 'merchantId' => 'XYZ0010', + 'transactionPassword' => 'abcd1234', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', + 'expiryMonth' => '06', + 'expiryYear' => '2020', + 'cvv' => '123', ), ) ); @@ -29,9 +29,10 @@ public function setUp() public function testFingerprint() { $data = $this->request->getData(); - $data['EPS_TIMESTAMP'] = '20130416123332'; + $data['EPS_TIMESTAMP'] = '20161125123332'; - $this->assertSame('652856e75b04c5916a41082e04c9390961497f65', $this->request->generateFingerprint($data)); + $this->assertSame('cbb64e71e360dba6337f22a00bdf0d0b89a7a568', + $this->request->generateFingerprint($data)); } public function testSend() From 397971fff6c73d3a40843c43f3aad71b58d24d52 Mon Sep 17 00:00:00 2001 From: sudiptpa Date: Fri, 25 Nov 2016 13:12:33 +0000 Subject: [PATCH 6/8] Apply fixes from StyleCI --- .../DirectPostAuthorizeRequestTest.php | 14 ++--- .../DirectPostCompletePurchaseRequestTest.php | 58 +++++++++---------- .../Message/DirectPostPurchaseRequestTest.php | 14 ++--- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php index eb3905c..6244b88 100644 --- a/tests/Message/DirectPostAuthorizeRequestTest.php +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', + 'merchantId' => 'foo', 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.abc.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2030', - 'cvv' => '123', + 'expiryYear' => '2030', + 'cvv' => '123', ), ) ); diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php index 2a4f16e..987f2da 100644 --- a/tests/Message/DirectPostCompletePurchaseRequestTest.php +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -15,15 +15,15 @@ public function testGenerateResponseFingerprint() { $this->request->initialize( array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abcd1234', ) ); $data = array( - 'timestamp' => '20161125123332', - 'merchant' => 'XYZ0010', - 'refid' => '222', + 'timestamp' => '20161125123332', + 'merchant' => 'XYZ0010', + 'refid' => '222', 'summarycode' => '2', ); @@ -35,26 +35,26 @@ public function testSuccess() { $this->request->initialize( array( - 'amount' => '12.00', + 'amount' => '12.00', 'transactionPassword' => 'abcd1234', - 'transactionId' => 'ORDER-ZYX8', + 'transactionId' => 'ORDER-ZYX8', ) ); $this->getHttpRequest()->query->replace( array( - 'timestamp' => '20161125130241', + 'timestamp' => '20161125130241', 'callback_status_code' => '-1', - 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', - 'txnid' => '271337', - 'merchant' => 'XYZ0010', - 'restext' => 'Approved', - 'rescode' => '00', - 'expirydate' => '20161126', - 'settdate' => '20161126', - 'refid' => 'ORDER-ZYX8', - 'pan' => '444433...111', - 'summarycode' => '1', + 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', + 'txnid' => '271337', + 'merchant' => 'XYZ0010', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '20161126', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '1', ) ); @@ -75,23 +75,23 @@ public function testSuccess() public function testFailure() { $this->request->initialize(array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abc123', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602102927', + 'timestamp' => '20130602102927', 'callback_status_code' => '', - 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', - 'txnid' => '205833', - 'merchant' => 'ABC0030', - 'restext' => 'Customer Dispute', - 'rescode' => '18', - 'expirydate' => '052016', - 'settdate' => '20130602', - 'refid' => '222', - 'pan' => '444433...111', - 'summarycode' => '2', + 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', + 'txnid' => '205833', + 'merchant' => 'ABC0030', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '052016', + 'settdate' => '20130602', + 'refid' => '222', + 'pan' => '444433...111', + 'summarycode' => '2', )); $response = $this->request->send(); diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php index 38898f2..1d0bab5 100644 --- a/tests/Message/DirectPostPurchaseRequestTest.php +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'XYZ0010', + 'merchantId' => 'XYZ0010', 'transactionPassword' => 'abcd1234', - 'amount' => '12.00', - 'returnUrl' => 'https://www.example.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '06', - 'expiryYear' => '2020', - 'cvv' => '123', + 'expiryYear' => '2020', + 'cvv' => '123', ), ) ); From cba93b695a6a2f4ab7150ca53e6e5324ee856458 Mon Sep 17 00:00:00 2001 From: Sujip Thapa Date: Sat, 26 Nov 2016 11:35:20 +0545 Subject: [PATCH 7/8] Some test fixes --- .../DirectPostCompletePurchaseResponse.php | 10 ++- .../DirectPostAuthorizeRequestTest.php | 20 +++--- .../DirectPostCompletePurchaseRequestTest.php | 64 +++++++++---------- .../Message/DirectPostPurchaseRequestTest.php | 14 ++-- 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/Message/DirectPostCompletePurchaseResponse.php b/src/Message/DirectPostCompletePurchaseResponse.php index c59972b..3e52d59 100644 --- a/src/Message/DirectPostCompletePurchaseResponse.php +++ b/src/Message/DirectPostCompletePurchaseResponse.php @@ -9,9 +9,17 @@ */ class DirectPostCompletePurchaseResponse extends AbstractResponse { + /** + * @return mixed + */ public function isSuccessful() { - return isset($this->data['summarycode']) && $this->data['summarycode'] == 1; + return $this->summaryCode() && (int) $this->getCode() == 00; + } + + public function summaryCode() + { + return isset($this->data['summarycode']) && (int) $this->data['summarycode'] == 1; } /** diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php index 6244b88..2ad9d1c 100644 --- a/tests/Message/DirectPostAuthorizeRequestTest.php +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'foo', - 'transactionPassword' => 'bar', - 'amount' => '12.00', - 'returnUrl' => 'https://www.abc.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'merchantId' => 'XYZ0010', + 'transactionPassword' => 'abcd1234', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2030', - 'cvv' => '123', + 'expiryYear' => '2030', + 'cvv' => '123', ), ) ); @@ -29,9 +29,9 @@ public function setUp() public function testFingerprint() { $data = $this->request->getData(); - $data['EPS_TIMESTAMP'] = '20130416123332'; + $data['EPS_TIMESTAMP'] = '20161126053143'; - $this->assertSame('46b6a59173c9fea66f71b8679558837895f0bce8', $this->request->generateFingerprint($data)); + $this->assertSame('687bb11413254824e3f854be330b5b5f2efaaf6d', $this->request->generateFingerprint($data)); } public function testSend() diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php index 987f2da..03a505e 100644 --- a/tests/Message/DirectPostCompletePurchaseRequestTest.php +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -15,15 +15,15 @@ public function testGenerateResponseFingerprint() { $this->request->initialize( array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abcd1234', ) ); $data = array( - 'timestamp' => '20161125123332', - 'merchant' => 'XYZ0010', - 'refid' => '222', + 'timestamp' => '20161125123332', + 'merchant' => 'XYZ0010', + 'refid' => '222', 'summarycode' => '2', ); @@ -35,26 +35,26 @@ public function testSuccess() { $this->request->initialize( array( - 'amount' => '12.00', + 'amount' => '12.00', 'transactionPassword' => 'abcd1234', - 'transactionId' => 'ORDER-ZYX8', + 'transactionId' => 'ORDER-ZYX8', ) ); $this->getHttpRequest()->query->replace( array( - 'timestamp' => '20161125130241', + 'timestamp' => '20161125130241', 'callback_status_code' => '-1', - 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', - 'txnid' => '271337', - 'merchant' => 'XYZ0010', - 'restext' => 'Approved', - 'rescode' => '00', - 'expirydate' => '20161126', - 'settdate' => '20161126', - 'refid' => 'ORDER-ZYX8', - 'pan' => '444433...111', - 'summarycode' => '1', + 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', + 'txnid' => '271337', + 'merchant' => 'XYZ0010', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '20161126', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '1', ) ); @@ -75,23 +75,23 @@ public function testSuccess() public function testFailure() { $this->request->initialize(array( - 'amount' => '465.18', - 'transactionPassword' => 'abc123', + 'amount' => '465.18', + 'transactionPassword' => 'abcd1234', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20130602102927', - 'callback_status_code' => '', - 'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f', - 'txnid' => '205833', - 'merchant' => 'ABC0030', - 'restext' => 'Customer Dispute', - 'rescode' => '18', - 'expirydate' => '052016', - 'settdate' => '20130602', - 'refid' => '222', - 'pan' => '444433...111', - 'summarycode' => '2', + 'timestamp' => '20161126051715', + 'callback_status_code' => '404', + 'fingerprint' => 'cd75e2ef38cf63a2fa390024539acc7691eebc1d', + 'txnid' => '274279', + 'merchant' => 'XYZ0010', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '102030', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '2', )); $response = $this->request->send(); @@ -100,7 +100,7 @@ public function testFailure() $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); - $this->assertSame('205833', $response->getTransactionReference()); + $this->assertSame('274279', $response->getTransactionReference()); $this->assertSame('Customer Dispute', $response->getMessage()); $this->assertSame('18', $response->getCode()); } diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php index 1d0bab5..38898f2 100644 --- a/tests/Message/DirectPostPurchaseRequestTest.php +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'XYZ0010', + 'merchantId' => 'XYZ0010', 'transactionPassword' => 'abcd1234', - 'amount' => '12.00', - 'returnUrl' => 'https://www.example.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '06', - 'expiryYear' => '2020', - 'cvv' => '123', + 'expiryYear' => '2020', + 'cvv' => '123', ), ) ); From ff56ae83ddff5cd0410002b79dad92e4f48a06bb Mon Sep 17 00:00:00 2001 From: sudiptpa Date: Sat, 26 Nov 2016 05:50:50 +0000 Subject: [PATCH 8/8] Apply fixes from StyleCI --- .../DirectPostAuthorizeRequestTest.php | 14 ++--- .../DirectPostCompletePurchaseRequestTest.php | 58 +++++++++---------- .../Message/DirectPostPurchaseRequestTest.php | 14 ++--- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/Message/DirectPostAuthorizeRequestTest.php b/tests/Message/DirectPostAuthorizeRequestTest.php index 2ad9d1c..8c4ae33 100644 --- a/tests/Message/DirectPostAuthorizeRequestTest.php +++ b/tests/Message/DirectPostAuthorizeRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'XYZ0010', + 'merchantId' => 'XYZ0010', 'transactionPassword' => 'abcd1234', - 'amount' => '12.00', - 'returnUrl' => 'https://www.abc.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.abc.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '6', - 'expiryYear' => '2030', - 'cvv' => '123', + 'expiryYear' => '2030', + 'cvv' => '123', ), ) ); diff --git a/tests/Message/DirectPostCompletePurchaseRequestTest.php b/tests/Message/DirectPostCompletePurchaseRequestTest.php index 03a505e..50601fd 100644 --- a/tests/Message/DirectPostCompletePurchaseRequestTest.php +++ b/tests/Message/DirectPostCompletePurchaseRequestTest.php @@ -15,15 +15,15 @@ public function testGenerateResponseFingerprint() { $this->request->initialize( array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abcd1234', ) ); $data = array( - 'timestamp' => '20161125123332', - 'merchant' => 'XYZ0010', - 'refid' => '222', + 'timestamp' => '20161125123332', + 'merchant' => 'XYZ0010', + 'refid' => '222', 'summarycode' => '2', ); @@ -35,26 +35,26 @@ public function testSuccess() { $this->request->initialize( array( - 'amount' => '12.00', + 'amount' => '12.00', 'transactionPassword' => 'abcd1234', - 'transactionId' => 'ORDER-ZYX8', + 'transactionId' => 'ORDER-ZYX8', ) ); $this->getHttpRequest()->query->replace( array( - 'timestamp' => '20161125130241', + 'timestamp' => '20161125130241', 'callback_status_code' => '-1', - 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', - 'txnid' => '271337', - 'merchant' => 'XYZ0010', - 'restext' => 'Approved', - 'rescode' => '00', - 'expirydate' => '20161126', - 'settdate' => '20161126', - 'refid' => 'ORDER-ZYX8', - 'pan' => '444433...111', - 'summarycode' => '1', + 'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f', + 'txnid' => '271337', + 'merchant' => 'XYZ0010', + 'restext' => 'Approved', + 'rescode' => '00', + 'expirydate' => '20161126', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '1', ) ); @@ -75,23 +75,23 @@ public function testSuccess() public function testFailure() { $this->request->initialize(array( - 'amount' => '465.18', + 'amount' => '465.18', 'transactionPassword' => 'abcd1234', )); $this->getHttpRequest()->query->replace(array( - 'timestamp' => '20161126051715', + 'timestamp' => '20161126051715', 'callback_status_code' => '404', - 'fingerprint' => 'cd75e2ef38cf63a2fa390024539acc7691eebc1d', - 'txnid' => '274279', - 'merchant' => 'XYZ0010', - 'restext' => 'Customer Dispute', - 'rescode' => '18', - 'expirydate' => '102030', - 'settdate' => '20161126', - 'refid' => 'ORDER-ZYX8', - 'pan' => '444433...111', - 'summarycode' => '2', + 'fingerprint' => 'cd75e2ef38cf63a2fa390024539acc7691eebc1d', + 'txnid' => '274279', + 'merchant' => 'XYZ0010', + 'restext' => 'Customer Dispute', + 'rescode' => '18', + 'expirydate' => '102030', + 'settdate' => '20161126', + 'refid' => 'ORDER-ZYX8', + 'pan' => '444433...111', + 'summarycode' => '2', )); $response = $this->request->send(); diff --git a/tests/Message/DirectPostPurchaseRequestTest.php b/tests/Message/DirectPostPurchaseRequestTest.php index 38898f2..1d0bab5 100644 --- a/tests/Message/DirectPostPurchaseRequestTest.php +++ b/tests/Message/DirectPostPurchaseRequestTest.php @@ -12,15 +12,15 @@ public function setUp() $this->request->initialize( array( - 'merchantId' => 'XYZ0010', + 'merchantId' => 'XYZ0010', 'transactionPassword' => 'abcd1234', - 'amount' => '12.00', - 'returnUrl' => 'https://www.example.com/return', - 'card' => array( - 'number' => '4444333322221111', + 'amount' => '12.00', + 'returnUrl' => 'https://www.example.com/return', + 'card' => array( + 'number' => '4444333322221111', 'expiryMonth' => '06', - 'expiryYear' => '2020', - 'cvv' => '123', + 'expiryYear' => '2020', + 'cvv' => '123', ), ) );