Skip to content

Commit 3cdeb3b

Browse files
20201119 deployment
1 parent f8c9a6e commit 3cdeb3b

14 files changed

+373
-50
lines changed

src/Builders/Secure3dBuilder.php

Lines changed: 173 additions & 17 deletions
Large diffs are not rendered by default.

src/ConfiguredServices.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function __construct()
4040
$this->secure3dProviders = array();
4141
}
4242

43-
protected function getSecure3dProvider(Secure3dVersion $version)
43+
public function getSecure3dProvider($version)
4444
{
45-
if (in_array($version, $this->secure3dProviders)) {
45+
if (array_key_exists($version, $this->secure3dProviders)) {
4646
return $this->secure3dProviders[$version];
4747
} elseif ($version == Secure3dVersion::ANY) {
4848
$provider = $this->secure3dProviders[Secure3dVersion::TWO];
@@ -55,7 +55,7 @@ protected function getSecure3dProvider(Secure3dVersion $version)
5555
}
5656
}
5757

58-
protected function setSecure3dProvider(Secure3dVersion $version, ISecure3dProvider $provider)
58+
public function setSecure3dProvider($version, $provider)
5959
{
6060
$this->secure3dProviders[$version] = $provider;
6161
}

src/Entities/Enums/AuthenticationSource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ class AuthenticationSource extends Enum
99
const BROWSER = "BROWSER";
1010
const STORED_RECURRING = "STORED_RECURRING";
1111
const MOBILE_SDK = "MOBILE_SDK";
12+
const MERCHANT_INITIATED = "MERCHANT_INITIATED";
1213
}

src/Entities/Enums/ChallengeRequestIndicator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ class ChallengeRequestIndicator extends Enum
1010
const NO_CHALLENGE_REQUESTED = "NO_CHALLENGE_REQUESTED";
1111
const CHALLENGE_PREFERRED = "CHALLENGE_PREFERRED";
1212
const CHALLENGE_MANDATED = "CHALLENGE_MANDATED";
13+
const NO_CHALLENGE_REQUESTED_TRANSACTION_RISK_ANALYSIS_PERFORMED = "NO_CHALLENGE_REQUESTED_TRANSACTION_RISK_ANALYSIS_PERFORMED";
14+
const NO_CHALLENGE_REQUESTED_DATA_SHARE_ONLY = "NO_CHALLENGE_REQUESTED_DATA_SHARE_ONLY";
15+
const NO_CHALLENGE_REQUESTED_SCA_ALREADY_PERFORMED = "NO_CHALLENGE_REQUESTED_SCA_ALREADY_PERFORMED";
16+
const NO_CHALLENGE_REQUESTED_WHITELIST = "NO_CHALLENGE_REQUESTED_WHITELIST";
17+
const CHALLENGE_REQUESTED_PROMPT_FOR_WHITELIST = "CHALLENGE_REQUESTED_PROMPT_FOR_WHITELIST";
1318
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
4+
namespace GlobalPayments\Api\Entities\Enums;
5+
6+
7+
use GlobalPayments\Api\Entities\Enum;
8+
9+
class DecoupledFlowRequest extends Enum
10+
{
11+
const DECOUPLED_PREFERRED = "DECOUPLED_PREFERRED";
12+
const DO_NOT_USE_DECOUPLED = "DO_NOT_USE_DECOUPLED";
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
4+
namespace GlobalPayments\Api\Entities\Enums;
5+
6+
7+
use GlobalPayments\Api\Entities\Enum;
8+
9+
class ExemptStatus extends Enum
10+
{
11+
const LOW_VALUE = "LOW_VALUE";
12+
const TRANSACTION_RISK_ANALYSIS = "TRANSACTION_RISK_ANALYSIS";
13+
const TRUSTED_MERCHANT = "TRUSTED_MERCHANT";
14+
const SECURE_CORPORATE_PAYMENT = "SECURE_CORPORATE_PAYMENT";
15+
const SCA_DELEGATION = "SCA_DELEGATION";
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
4+
namespace GlobalPayments\Api\Entities\Enums;
5+
6+
7+
use GlobalPayments\Api\Entities\Enum;
8+
9+
class MerchantInitiatedRequestType extends Enum
10+
{
11+
const RECURRING_TRANSACTION = "RECURRING_TRANSACTION";
12+
const INSTALLMENT_TRANSACTION = "INSTALLMENT_TRANSACTION";
13+
const ADD_CARD = "ADD_CARD";
14+
const MAINTAIN_CARD_INFORMATION = "MAINTAIN_CARD_INFORMATION";
15+
const ACCOUNT_VERIFICATION = "ACCOUNT_VERIFICATION";
16+
const SPLIT_OR_DELAYED_SHIPMENT = "SPLIT_OR_DELAYED_SHIPMENT";
17+
const TOP_UP = "TOP_UP";
18+
const MAIL_ORDER = "MAIL_ORDER";
19+
const TELEPHONE_ORDER = "TELEPHONE_ORDER";
20+
const WHITELIST_STATUS_CHECK = "WHITELIST_STATUS_CHECK";
21+
const OTHER_PAYMENT = "OTHER_PAYMENT";
22+
const BILLING_AGREEMENT = "BILLING_AGREEMENT";
23+
24+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
4+
namespace GlobalPayments\Api\Entities\Enums;
5+
6+
7+
class WhiteListStatus
8+
{
9+
const WHITELISTED = "WHITELISTED";
10+
const NOT_WHITELISTED = "NOT_WHITELISTED";
11+
}

src/Entities/ThreeDSecure.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class ThreeDSecure
1919
*/
2020
public $acsStartVersion;
2121

22+
/**
23+
* @var array
24+
*/
25+
public $acsInfoIndicator;
26+
2227
/**
2328
* The algorithm used
2429
*
@@ -107,6 +112,11 @@ public function setCurrency($value)
107112
$this->merchantData->add('currency', $this->currency, false);
108113
}
109114

115+
/**
116+
* @var string
117+
*/
118+
public $decoupledResponseIndicator;
119+
110120
/**
111121
* @var string
112122
*/
@@ -136,6 +146,13 @@ public function setCurrency($value)
136146
*/
137147
public $enrolled;
138148

149+
/**
150+
* The exempt status
151+
*
152+
* @var string
153+
*/
154+
public $exemptStatus;
155+
139156
/**
140157
* The URL of the Issuing Bank's ACS
141158
*
@@ -190,6 +207,11 @@ public function setMerchantData($merchantData)
190207
*/
191208
public $messageCategory;
192209

210+
/**
211+
* @var string
212+
*/
213+
public $messageExtensionData;
214+
193215
/**
194216
* @var string
195217
*/
@@ -303,6 +325,11 @@ public function setVersion($version)
303325
$this->merchantData->add('version', $version, false);
304326
}
305327

328+
/**
329+
* @var string
330+
*/
331+
public $whitelistStatus;
332+
306333
/**
307334
* Consumer authentication (3DSecure) transaction ID
308335
*
@@ -337,13 +364,15 @@ public function merge(ThreeDSecure $secureEcom)
337364
$this->challengeMandated = $this->mergeValue($this->challengeMandated, $secureEcom->challengeMandated);
338365
$this->criticalityIndicator = $this->mergeValue($this->criticalityIndicator, $secureEcom->criticalityIndicator);
339366
$this->currency = $this->mergeValue($this->currency, $secureEcom->currency);
367+
$this->decoupledResponseIndicator = $this->mergeValue($this->decoupledResponseIndicator, $secureEcom->decoupledResponseIndicator);
340368
$this->directoryServerTransactionId = $this->mergeValue($this->directoryServerTransactionId, $secureEcom->directoryServerTransactionId);
341369
$this->directoryServerEndVersion = $this->mergeValue($this->directoryServerEndVersion, $secureEcom->directoryServerEndVersion);
342370
$this->directoryServerStartVersion = $this->mergeValue($this->directoryServerStartVersion, $secureEcom->directoryServerStartVersion);
343371
$this->eci = $this->mergeValue($this->eci, $secureEcom->eci);
344372
$this->enrolled = $this->mergeValue($this->enrolled, $secureEcom->enrolled);
345373
$this->issuerAcsUrl = $this->mergeValue($this->issuerAcsUrl, $secureEcom->issuerAcsUrl);
346374
$this->messageCategory = $this->mergeValue($this->messageCategory, $secureEcom->messageCategory);
375+
$this->messageExtensionData = $this->mergeValue($this->messageExtensionData, $secureEcom->messageExtensionData);
347376
$this->messageExtensionId = $this->mergeValue($this->messageExtensionId, $secureEcom->messageExtensionId);
348377
$this->messageExtensionName = $this->mergeValue($this->messageExtensionName, $secureEcom->messageExtensionName);
349378
$this->messageVersion = $this->mergeValue($this->messageVersion, $secureEcom->messageVersion);
@@ -357,6 +386,7 @@ public function merge(ThreeDSecure $secureEcom)
357386
$this->status = $this->mergeValue($this->status, $secureEcom->status);
358387
$this->statusReason = $this->mergeValue($this->statusReason, $secureEcom->statusReason);
359388
$this->version = $this->mergeValue($this->version, $secureEcom->version);
389+
$this->whitelistStatus = $this->mergeValue($this->whitelistStatus, $secureEcom->whitelistStatus);
360390
$this->xid = $this->mergeValue($this->xid, $secureEcom->xid);
361391
}
362392
}

src/Gateways/Gp3DSProvider.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ public function processSecure3d(Secure3dBuilder $builder)
110110

111111
$hash = GenerationUtils::generateHash($this->sharedSecret, implode('.', [$timestamp, $this->merchantId, $hashValue]));
112112
$headers['Authorization'] = sprintf('securehash %s', $hash);
113+
$headers["X-GP-Version"] = "2.2.0";
113114

114115
$rawResponse = $this->doTransaction('POST', 'protocol-versions', json_encode($request), null, $headers);
115116
return $this->mapResponse($rawResponse);
116117
} elseif ($transType === TransactionType::VERIFY_SIGNATURE) {
117118
$hash = GenerationUtils::generateHash($this->sharedSecret, implode('.', [$timestamp, $this->merchantId, $builder->getServerTransactionId()]));
118119
$headers['Authorization'] = sprintf('securehash %s', $hash);
120+
$headers["X-GP-Version"] = "2.2.0";
119121

120122
$queryValues = [];
121123
$queryValues['merchant_id'] = $this->merchantId;
@@ -143,18 +145,22 @@ public function processSecure3d(Secure3dBuilder $builder)
143145
$request = $this->maybeSetKey($request, 'method_url_completion', $builder->getMethodUrlCompletion());
144146
$request = $this->maybeSetKey($request, 'merchant_contact_url', $this->merchantContactUrl);
145147
$request = $this->maybeSetKey($request, 'merchant_initiated_request_type', $builder->getMerchantInitiatedRequestType());
148+
$request = $this->maybeSetKey($request, 'whitelist_status', $builder->getWhitelistStatus());
149+
$request = $this->maybeSetKey($request, 'decoupled_flow_request', $builder->getDecoupledFlowRequest());
150+
$request = $this->maybeSetKey($request, 'decoupled_flow_timeout', $builder->getDecoupledFlowTimeout());
151+
$request = $this->maybeSetKey($request, 'decoupled_notification_url', $builder->getDecoupledNotificationUrl());
146152

147153
// card details
148154
$hashValue = '';
149155
$request['card_detail'] = [];
150156
if ($paymentMethod instanceof CreditCardData) {
151157
$cardData = $paymentMethod;
152158
$hashValue = $cardData->number;
153-
159+
154160
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'number', $cardData->number);
155161
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'scheme', strtoupper($cardData->getCardType()));
156162
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_month', $cardData->expMonth);
157-
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_year',
163+
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_year',
158164
substr(str_pad($cardData->expYear, 4, '0', STR_PAD_LEFT), 2, 2));
159165
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'full_name', $cardData->cardHolderName);
160166

@@ -312,7 +318,7 @@ public function processSecure3d(Secure3dBuilder $builder)
312318
$request['sdk_information'] = [];
313319
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'application_id', $builder->getApplicationId());
314320
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'ephemeral_public_key', $builder->getEphemeralPublicKey());
315-
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'maximum_timeout',
321+
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'maximum_timeout',
316322
(!empty($builder->getMaximumTimeout())) ? str_pad($builder->getMaximumTimeout(), 2, '0' , STR_PAD_LEFT) : '');
317323
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'reference_number', $builder->getReferenceNumber());
318324
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'sdk_trans_id', $builder->getSdkTransactionId());
@@ -328,6 +334,7 @@ public function processSecure3d(Secure3dBuilder $builder)
328334

329335
$hash = GenerationUtils::generateHash($this->sharedSecret, implode('.', [$timestamp, $this->merchantId, $hashValue, $secureEcom->serverTransactionId]));
330336
$headers['Authorization'] = sprintf('securehash %s', $hash);
337+
$headers["X-GP-Version"] = "2.2.0";
331338
$rawResponse = $this->doTransaction('POST', 'authentications', json_encode($request, JSON_UNESCAPED_SLASHES), null, $headers);
332339
return $this->mapResponse($rawResponse);
333340
}
@@ -360,6 +367,10 @@ private function mapResponse($rawResponse)
360367
$secureEcom->authenticationSource = isset($doc['authentication_source']) ? $doc['authentication_source'] : null;
361368
$secureEcom->messageCategory = isset($doc['message_category']) ? $doc['message_category'] : null;
362369
$secureEcom->messageVersion = isset($doc['message_version']) ? $doc['message_version'] : null;
370+
$secureEcom->acsInfoIndicator = isset($doc['acs_info_indicator']) ? $doc['acs_info_indicator'] : null;
371+
$secureEcom->decoupledResponseIndicator = isset($doc['decoupled_response_indicator']) ?
372+
$doc['decoupled_response_indicator'] : null;
373+
$secureEcom->whitelistStatus = isset($doc['whitelist_status']) ? $doc['whitelist_status'] : null;
363374

364375
// challenge mandated
365376
if (array_key_exists('challenge_mandated', $doc)) {
@@ -382,6 +393,8 @@ private function mapResponse($rawResponse)
382393
$secureEcom->criticalityIndicator =
383394
isset($doc['message_extension']['criticality_indicator']) ?
384395
$doc['message_extension']['criticality_indicator'] : null;
396+
$secureEcom->messageExtensionData = isset($doc['message_extension']['data']) ?
397+
$doc['message_extension']['data'] : null;
385398
$secureEcom->messageExtensionId =
386399
isset($doc['message_extension']['id']) ? $doc['message_extension']['id'] : null;
387400
$secureEcom->messageExtensionName =

0 commit comments

Comments
 (0)