Skip to content

Commit 36082a7

Browse files
committed
Added EMV 3DS Request, Response
1 parent d830e51 commit 36082a7

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

src/Message/EMV3DSOrderRequest.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,40 @@
77
*/
88
class EMV3DSOrderRequest extends DirectPostAuthorizeRequest
99
{
10-
//
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+
}
1146
}

src/Message/EMV3DSOrderResponse.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,59 @@
33
namespace Omnipay\NABTransact\Message;
44

55
use Omnipay\Common\Message\AbstractResponse;
6+
use Omnipay\Common\Message\RequestInterface;
67

78
/**
89
* NABTransact EMV 3DS Order Response.
910
*/
1011
class EMV3DSOrderResponse extends AbstractResponse
1112
{
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+
}
1361
}

0 commit comments

Comments
 (0)