22
33namespace Omnipay \NABTransact \Message ;
44
5+ use Omnipay \NABTransact \Enums \TransactionType ;
6+
57/**
68 * NABTransact Direct Post Abstract Request.
79 */
@@ -22,14 +24,23 @@ 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 ,
39+ [$ data ['EPS_ORDERID ' ]]
40+ );
41+ }
42+
43+ $ hash = implode ('| ' , $ hashable );
3344
3445 return hash_hmac ('sha256 ' , $ hash , $ this ->getTransactionPassword ());
3546 }
@@ -43,15 +54,50 @@ public function getBaseData()
4354
4455 $ data ['EPS_MERCHANT ' ] = $ this ->getMerchantId ();
4556 $ data ['EPS_TXNTYPE ' ] = $ this ->txnType ;
46- $ data ['EPS_IP ' ] = $ this ->getClientIp ();
47- $ data ['EPS_AMOUNT ' ] = $ this ->getAmount ();
4857 $ data ['EPS_REFERENCEID ' ] = $ this ->getTransactionId ();
58+ $ data ['EPS_AMOUNT ' ] = $ this ->getAmount ();
4959 $ data ['EPS_TIMESTAMP ' ] = gmdate ('YmdHis ' );
50- $ data ['EPS_FINGERPRINT ' ] = $ this ->generateFingerprint ($ data );
5160 $ data ['EPS_RESULTURL ' ] = $ this ->getReturnUrl ();
52- $ data ['EPS_CALLBACKURL ' ] = $ this ->getNotifyUrl () ?: $ this -> getReturnUrl ();
61+ $ data ['EPS_IP ' ] = $ this ->getClientIp ();
5362 $ data ['EPS_REDIRECT ' ] = 'TRUE ' ;
54- $ data ['EPS_CURRENCY ' ] = $ this ->getCurrency ();
63+
64+ if ($ this ->getNotifyUrl ()) {
65+ $ data ['EPS_CALLBACKURL ' ] = $ this ->getNotifyUrl ();
66+ }
67+
68+ if ($ currency = $ this ->getCurrency ()) {
69+ $ data ['EPS_CURRENCY ' ] = $ currency ;
70+ }
71+
72+ $ card = $ this ->getCard ();
73+
74+ if ($ billingPostcode = $ card ->getBillingPostcode ()) {
75+ $ data ['EPS_ZIPCODE ' ] = $ billingPostcode ;
76+ }
77+
78+ if ($ billingCity = $ card ->getBillingCity ()) {
79+ $ data ['EPS_TOWN ' ] = $ billingCity ;
80+ }
81+
82+ if ($ billingCountry = $ card ->getBillingCountry ()) {
83+ $ data ['EPS_BILLINGCOUNTRY ' ] = $ billingCountry ;
84+ }
85+
86+ if ($ shippingCountry = $ card ->getShippingCountry ()) {
87+ $ data ['EPS_DELIVERYCOUNTRY ' ] = $ shippingCountry ;
88+ }
89+
90+ if ($ emailAddress = $ card ->getEmail ()) {
91+ $ data ['EPS_EMAILADDRESS ' ] = $ emailAddress ;
92+ }
93+
94+ if ($ this ->getHasEMV3DSEnabled ()) {
95+ $ data ['EPS_ORDERID ' ] = $ this ->getTransactionReference ();
96+
97+ $ data ['EPS_TXNTYPE ' ] = TransactionType::PAYMENT_3DS_EMV3DS ;
98+ }
99+
100+ $ data ['EPS_FINGERPRINT ' ] = $ this ->generateFingerprint ($ data );
55101
56102 return $ data ;
57103 }
0 commit comments