22
33namespace Omnipay \NABTransact \Message ;
44
5+ use Omnipay \NABTransact \Enums \TransactionType ;
6+
57/**
68 * NABTransact Direct Post Abstract Request.
79 */
@@ -22,14 +24,22 @@ abstract class DirectPostAbstractRequest extends AbstractRequest
2224 */
2325 public function generateFingerprint (array $ data )
2426 {
25- $ hash = implode ( ' | ' , [
27+ $ hashable = [
2628 $ data ['EPS_MERCHANT ' ],
2729 $ this ->getTransactionPassword (),
2830 $ data ['EPS_TXNTYPE ' ],
2931 $ data ['EPS_REFERENCEID ' ],
3032 $ data ['EPS_AMOUNT ' ],
3133 $ data ['EPS_TIMESTAMP ' ],
32- ]);
34+ ];
35+
36+ if ($ this ->getHasEMV3DSEnabled ()) {
37+ $ hashable = array_merge (
38+ $ hashable , [$ data ['EPS_ORDERID ' ]]
39+ );
40+ }
41+
42+ $ hash = implode ('| ' , $ hashable );
3343
3444 return hash_hmac ('sha256 ' , $ hash , $ this ->getTransactionPassword ());
3545 }
@@ -43,15 +53,50 @@ public function getBaseData()
4353
4454 $ data ['EPS_MERCHANT ' ] = $ this ->getMerchantId ();
4555 $ data ['EPS_TXNTYPE ' ] = $ this ->txnType ;
46- $ data ['EPS_IP ' ] = $ this ->getClientIp ();
47- $ data ['EPS_AMOUNT ' ] = $ this ->getAmount ();
4856 $ data ['EPS_REFERENCEID ' ] = $ this ->getTransactionId ();
57+ $ data ['EPS_AMOUNT ' ] = $ this ->getAmount ();
4958 $ data ['EPS_TIMESTAMP ' ] = gmdate ('YmdHis ' );
50- $ data ['EPS_FINGERPRINT ' ] = $ this ->generateFingerprint ($ data );
5159 $ data ['EPS_RESULTURL ' ] = $ this ->getReturnUrl ();
52- $ data ['EPS_CALLBACKURL ' ] = $ this ->getNotifyUrl () ?: $ this -> getReturnUrl ();
60+ $ data ['EPS_IP ' ] = $ this ->getClientIp ();
5361 $ data ['EPS_REDIRECT ' ] = 'TRUE ' ;
54- $ data ['EPS_CURRENCY ' ] = $ this ->getCurrency ();
62+
63+ if ($ this ->getNotifyUrl ()) {
64+ $ data ['EPS_CALLBACKURL ' ] = $ this ->getNotifyUrl ();
65+ }
66+
67+ if ($ currency = $ this ->getCurrency ()) {
68+ $ data ['EPS_CURRENCY ' ] = $ currency ;
69+ }
70+
71+ $ card = $ this ->getCard ();
72+
73+ if ($ billingPostcode = $ card ->getBillingPostcode ()) {
74+ $ data ['EPS_ZIPCODE ' ] = $ billingPostcode ;
75+ }
76+
77+ if ($ billingCity = $ card ->getBillingCity ()) {
78+ $ data ['EPS_TOWN ' ] = $ billingCity ;
79+ }
80+
81+ if ($ billingCountry = $ card ->getBillingCountry ()) {
82+ $ data ['EPS_BILLINGCOUNTRY ' ] = $ billingCountry ;
83+ }
84+
85+ if ($ shippingCountry = $ card ->getShippingCountry ()) {
86+ $ data ['EPS_DELIVERYCOUNTRY ' ] = $ shippingCountry ;
87+ }
88+
89+ if ($ emailAddress = $ card ->getEmail ()) {
90+ $ data ['EPS_EMAILADDRESS ' ] = $ emailAddress ;
91+ }
92+
93+ if ($ this ->getHasEMV3DSEnabled ()) {
94+ $ data ['EPS_ORDERID ' ] = $ this ->getTransactionReference ();
95+
96+ $ data ['EPS_TXNTYPE ' ] = TransactionType::PAYMENT_3DS_EMV3DS ;
97+ }
98+
99+ $ data ['EPS_FINGERPRINT ' ] = $ this ->generateFingerprint ($ data );
55100
56101 return $ data ;
57102 }
0 commit comments