Skip to content

Commit 392d4f8

Browse files
authored
Merge pull request #38 from sudiptpa/feature/adding-emv-3ds-order
Added new feature EMV 3DS Order
2 parents ed55a99 + d8f00dc commit 392d4f8

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

src/DirectPostGateway.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,9 @@ public function completePurchase(array $parameters = [])
7272
{
7373
return $this->createRequest('\Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest', $parameters);
7474
}
75+
76+
public function createEMV3DSOrder(array $parameters = [])
77+
{
78+
return $this->createRequest('\Omnipay\NABTransact\Message\EMV3DSOrderRequest', $parameters);
79+
}
7580
}

src/Message/EMV3DSOrderRequest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Omnipay\NABTransact\Message;
4+
5+
/**
6+
* NABTransact EMV 3DS Order Request.
7+
*/
8+
class EMV3DSOrderRequest extends DirectPostAuthorizeRequest
9+
{
10+
public $testEndpoint = 'https://demo.transact.nab.com.au/services/order-management/v2/payments/orders';
11+
12+
public $liveEndpoint = 'https://transact.nab.com.au/services/order-management/v2/payments/orders';
13+
14+
public function getData()
15+
{
16+
$this->validate('amount', 'currency', 'clientIp', 'merchantOrderReference');
17+
18+
return [
19+
'amount' => floor($this->getAmount() * 100),
20+
'currency' => $this->getCurrency(),
21+
'ip' => $this->getClientIp(),
22+
'merchantId' => $this->getMerchantId(),
23+
'merchantOrderReference' => $this->getTransactionReference(),
24+
'orderType' => 'PAYMENT',
25+
'intents' => [
26+
'THREED_SECURE',
27+
],
28+
];
29+
}
30+
31+
public function sendData($data)
32+
{
33+
$params = [
34+
'headers' => [
35+
'Accept' => '*/*',
36+
'Content-Type' => 'application/json; charset=UTF-8',
37+
'Authorization' => 'Basic '.base64_encode("{$this->getMerchantId()}:{$this->getTransactionPassword()}"),
38+
],
39+
'body' => json_encode($data),
40+
];
41+
42+
$response = $this->httpClient->post($this->getEndpoint(), $params)->send();
43+
44+
return $this->response = new EMV3DSOrderResponse($this, $response->json());
45+
}
46+
}

src/Message/EMV3DSOrderResponse.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Omnipay\NABTransact\Message;
4+
5+
use Omnipay\Common\Message\AbstractResponse;
6+
use Omnipay\Common\Message\RequestInterface;
7+
8+
/**
9+
* NABTransact EMV 3DS Order Response.
10+
*/
11+
class EMV3DSOrderResponse extends AbstractResponse
12+
{
13+
/**
14+
* @param RequestInterface $request
15+
* @param $data
16+
*/
17+
public function __construct(RequestInterface $request, $data)
18+
{
19+
parent::__construct($request, $data);
20+
}
21+
22+
public function getResponseData($key)
23+
{
24+
$data = $this->data;
25+
26+
return isset($data[$key]) ? $data[$key] : null;
27+
}
28+
29+
public function getOrderId()
30+
{
31+
return $this->getResponseData('orderId');
32+
}
33+
34+
public function getSimpleToken()
35+
{
36+
return $this->getResponseData('simpleToken');
37+
}
38+
39+
public function getOrderToken()
40+
{
41+
return $this->getResponseData('orderToken');
42+
}
43+
44+
public function getProviderClientId()
45+
{
46+
$data = $this->data;
47+
48+
return isset($data['threedSecure']['providerClientId'])
49+
? $data['threedSecure']['providerClientId']
50+
: null;
51+
}
52+
53+
public function getSessionId()
54+
{
55+
$data = $this->data;
56+
57+
return isset($data['threedSecure']['sessionId'])
58+
? $data['threedSecure']['sessionId']
59+
: null;
60+
}
61+
}

0 commit comments

Comments
 (0)