Skip to content

Commit

Permalink
20201119 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Nov 19, 2020
1 parent f8c9a6e commit 3cdeb3b
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 50 deletions.
190 changes: 173 additions & 17 deletions src/Builders/Secure3dBuilder.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/ConfiguredServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function __construct()
$this->secure3dProviders = array();
}

protected function getSecure3dProvider(Secure3dVersion $version)
public function getSecure3dProvider($version)
{
if (in_array($version, $this->secure3dProviders)) {
if (array_key_exists($version, $this->secure3dProviders)) {
return $this->secure3dProviders[$version];
} elseif ($version == Secure3dVersion::ANY) {
$provider = $this->secure3dProviders[Secure3dVersion::TWO];
Expand All @@ -55,7 +55,7 @@ protected function getSecure3dProvider(Secure3dVersion $version)
}
}

protected function setSecure3dProvider(Secure3dVersion $version, ISecure3dProvider $provider)
public function setSecure3dProvider($version, $provider)
{
$this->secure3dProviders[$version] = $provider;
}
Expand Down
1 change: 1 addition & 0 deletions src/Entities/Enums/AuthenticationSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class AuthenticationSource extends Enum
const BROWSER = "BROWSER";
const STORED_RECURRING = "STORED_RECURRING";
const MOBILE_SDK = "MOBILE_SDK";
const MERCHANT_INITIATED = "MERCHANT_INITIATED";
}
5 changes: 5 additions & 0 deletions src/Entities/Enums/ChallengeRequestIndicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ class ChallengeRequestIndicator extends Enum
const NO_CHALLENGE_REQUESTED = "NO_CHALLENGE_REQUESTED";
const CHALLENGE_PREFERRED = "CHALLENGE_PREFERRED";
const CHALLENGE_MANDATED = "CHALLENGE_MANDATED";
const NO_CHALLENGE_REQUESTED_TRANSACTION_RISK_ANALYSIS_PERFORMED = "NO_CHALLENGE_REQUESTED_TRANSACTION_RISK_ANALYSIS_PERFORMED";
const NO_CHALLENGE_REQUESTED_DATA_SHARE_ONLY = "NO_CHALLENGE_REQUESTED_DATA_SHARE_ONLY";
const NO_CHALLENGE_REQUESTED_SCA_ALREADY_PERFORMED = "NO_CHALLENGE_REQUESTED_SCA_ALREADY_PERFORMED";
const NO_CHALLENGE_REQUESTED_WHITELIST = "NO_CHALLENGE_REQUESTED_WHITELIST";
const CHALLENGE_REQUESTED_PROMPT_FOR_WHITELIST = "CHALLENGE_REQUESTED_PROMPT_FOR_WHITELIST";
}
13 changes: 13 additions & 0 deletions src/Entities/Enums/DecoupledFlowRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php


namespace GlobalPayments\Api\Entities\Enums;


use GlobalPayments\Api\Entities\Enum;

class DecoupledFlowRequest extends Enum
{
const DECOUPLED_PREFERRED = "DECOUPLED_PREFERRED";
const DO_NOT_USE_DECOUPLED = "DO_NOT_USE_DECOUPLED";
}
16 changes: 16 additions & 0 deletions src/Entities/Enums/ExemptStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php


namespace GlobalPayments\Api\Entities\Enums;


use GlobalPayments\Api\Entities\Enum;

class ExemptStatus extends Enum
{
const LOW_VALUE = "LOW_VALUE";
const TRANSACTION_RISK_ANALYSIS = "TRANSACTION_RISK_ANALYSIS";
const TRUSTED_MERCHANT = "TRUSTED_MERCHANT";
const SECURE_CORPORATE_PAYMENT = "SECURE_CORPORATE_PAYMENT";
const SCA_DELEGATION = "SCA_DELEGATION";
}
24 changes: 24 additions & 0 deletions src/Entities/Enums/MerchantInitiatedRequestType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php


namespace GlobalPayments\Api\Entities\Enums;


use GlobalPayments\Api\Entities\Enum;

class MerchantInitiatedRequestType extends Enum
{
const RECURRING_TRANSACTION = "RECURRING_TRANSACTION";
const INSTALLMENT_TRANSACTION = "INSTALLMENT_TRANSACTION";
const ADD_CARD = "ADD_CARD";
const MAINTAIN_CARD_INFORMATION = "MAINTAIN_CARD_INFORMATION";
const ACCOUNT_VERIFICATION = "ACCOUNT_VERIFICATION";
const SPLIT_OR_DELAYED_SHIPMENT = "SPLIT_OR_DELAYED_SHIPMENT";
const TOP_UP = "TOP_UP";
const MAIL_ORDER = "MAIL_ORDER";
const TELEPHONE_ORDER = "TELEPHONE_ORDER";
const WHITELIST_STATUS_CHECK = "WHITELIST_STATUS_CHECK";
const OTHER_PAYMENT = "OTHER_PAYMENT";
const BILLING_AGREEMENT = "BILLING_AGREEMENT";

}
11 changes: 11 additions & 0 deletions src/Entities/Enums/WhiteListStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php


namespace GlobalPayments\Api\Entities\Enums;


class WhiteListStatus
{
const WHITELISTED = "WHITELISTED";
const NOT_WHITELISTED = "NOT_WHITELISTED";
}
30 changes: 30 additions & 0 deletions src/Entities/ThreeDSecure.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class ThreeDSecure
*/
public $acsStartVersion;

/**
* @var array
*/
public $acsInfoIndicator;

/**
* The algorithm used
*
Expand Down Expand Up @@ -107,6 +112,11 @@ public function setCurrency($value)
$this->merchantData->add('currency', $this->currency, false);
}

/**
* @var string
*/
public $decoupledResponseIndicator;

/**
* @var string
*/
Expand Down Expand Up @@ -136,6 +146,13 @@ public function setCurrency($value)
*/
public $enrolled;

/**
* The exempt status
*
* @var string
*/
public $exemptStatus;

/**
* The URL of the Issuing Bank's ACS
*
Expand Down Expand Up @@ -190,6 +207,11 @@ public function setMerchantData($merchantData)
*/
public $messageCategory;

/**
* @var string
*/
public $messageExtensionData;

/**
* @var string
*/
Expand Down Expand Up @@ -303,6 +325,11 @@ public function setVersion($version)
$this->merchantData->add('version', $version, false);
}

/**
* @var string
*/
public $whitelistStatus;

/**
* Consumer authentication (3DSecure) transaction ID
*
Expand Down Expand Up @@ -337,13 +364,15 @@ public function merge(ThreeDSecure $secureEcom)
$this->challengeMandated = $this->mergeValue($this->challengeMandated, $secureEcom->challengeMandated);
$this->criticalityIndicator = $this->mergeValue($this->criticalityIndicator, $secureEcom->criticalityIndicator);
$this->currency = $this->mergeValue($this->currency, $secureEcom->currency);
$this->decoupledResponseIndicator = $this->mergeValue($this->decoupledResponseIndicator, $secureEcom->decoupledResponseIndicator);
$this->directoryServerTransactionId = $this->mergeValue($this->directoryServerTransactionId, $secureEcom->directoryServerTransactionId);
$this->directoryServerEndVersion = $this->mergeValue($this->directoryServerEndVersion, $secureEcom->directoryServerEndVersion);
$this->directoryServerStartVersion = $this->mergeValue($this->directoryServerStartVersion, $secureEcom->directoryServerStartVersion);
$this->eci = $this->mergeValue($this->eci, $secureEcom->eci);
$this->enrolled = $this->mergeValue($this->enrolled, $secureEcom->enrolled);
$this->issuerAcsUrl = $this->mergeValue($this->issuerAcsUrl, $secureEcom->issuerAcsUrl);
$this->messageCategory = $this->mergeValue($this->messageCategory, $secureEcom->messageCategory);
$this->messageExtensionData = $this->mergeValue($this->messageExtensionData, $secureEcom->messageExtensionData);
$this->messageExtensionId = $this->mergeValue($this->messageExtensionId, $secureEcom->messageExtensionId);
$this->messageExtensionName = $this->mergeValue($this->messageExtensionName, $secureEcom->messageExtensionName);
$this->messageVersion = $this->mergeValue($this->messageVersion, $secureEcom->messageVersion);
Expand All @@ -357,6 +386,7 @@ public function merge(ThreeDSecure $secureEcom)
$this->status = $this->mergeValue($this->status, $secureEcom->status);
$this->statusReason = $this->mergeValue($this->statusReason, $secureEcom->statusReason);
$this->version = $this->mergeValue($this->version, $secureEcom->version);
$this->whitelistStatus = $this->mergeValue($this->whitelistStatus, $secureEcom->whitelistStatus);
$this->xid = $this->mergeValue($this->xid, $secureEcom->xid);
}
}
Expand Down
19 changes: 16 additions & 3 deletions src/Gateways/Gp3DSProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ public function processSecure3d(Secure3dBuilder $builder)

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

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

$queryValues = [];
$queryValues['merchant_id'] = $this->merchantId;
Expand Down Expand Up @@ -143,18 +145,22 @@ public function processSecure3d(Secure3dBuilder $builder)
$request = $this->maybeSetKey($request, 'method_url_completion', $builder->getMethodUrlCompletion());
$request = $this->maybeSetKey($request, 'merchant_contact_url', $this->merchantContactUrl);
$request = $this->maybeSetKey($request, 'merchant_initiated_request_type', $builder->getMerchantInitiatedRequestType());
$request = $this->maybeSetKey($request, 'whitelist_status', $builder->getWhitelistStatus());
$request = $this->maybeSetKey($request, 'decoupled_flow_request', $builder->getDecoupledFlowRequest());
$request = $this->maybeSetKey($request, 'decoupled_flow_timeout', $builder->getDecoupledFlowTimeout());
$request = $this->maybeSetKey($request, 'decoupled_notification_url', $builder->getDecoupledNotificationUrl());

// card details
$hashValue = '';
$request['card_detail'] = [];
if ($paymentMethod instanceof CreditCardData) {
$cardData = $paymentMethod;
$hashValue = $cardData->number;

$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'number', $cardData->number);
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'scheme', strtoupper($cardData->getCardType()));
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_month', $cardData->expMonth);
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_year',
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'expiry_year',
substr(str_pad($cardData->expYear, 4, '0', STR_PAD_LEFT), 2, 2));
$request['card_detail'] = $this->maybeSetKey($request['card_detail'], 'full_name', $cardData->cardHolderName);

Expand Down Expand Up @@ -312,7 +318,7 @@ public function processSecure3d(Secure3dBuilder $builder)
$request['sdk_information'] = [];
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'application_id', $builder->getApplicationId());
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'ephemeral_public_key', $builder->getEphemeralPublicKey());
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'maximum_timeout',
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'maximum_timeout',
(!empty($builder->getMaximumTimeout())) ? str_pad($builder->getMaximumTimeout(), 2, '0' , STR_PAD_LEFT) : '');
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'reference_number', $builder->getReferenceNumber());
$request['sdk_information'] = $this->maybeSetKey($request['sdk_information'], 'sdk_trans_id', $builder->getSdkTransactionId());
Expand All @@ -328,6 +334,7 @@ public function processSecure3d(Secure3dBuilder $builder)

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

// challenge mandated
if (array_key_exists('challenge_mandated', $doc)) {
Expand All @@ -382,6 +393,8 @@ private function mapResponse($rawResponse)
$secureEcom->criticalityIndicator =
isset($doc['message_extension']['criticality_indicator']) ?
$doc['message_extension']['criticality_indicator'] : null;
$secureEcom->messageExtensionData = isset($doc['message_extension']['data']) ?
$doc['message_extension']['data'] : null;
$secureEcom->messageExtensionId =
isset($doc['message_extension']['id']) ? $doc['message_extension']['id'] : null;
$secureEcom->messageExtensionName =
Expand Down
9 changes: 8 additions & 1 deletion src/Gateways/RealexConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,18 @@ public function processAuthorization(AuthorizationBuilder $builder)
$mpi->appendChild($xml->createElement("cavv", $secureEcom->cavv));
$mpi->appendChild($xml->createElement("xid", $secureEcom->xid));

if ($secureEcom->directoryServerTransactionId != null || $secureEcom->authenticationValue != null || $secureEcom->messageVersion != null) {
if (
$secureEcom->directoryServerTransactionId != null ||
$secureEcom->authenticationValue != null ||
$secureEcom->messageVersion != null
) {
$mpi->appendChild($xml->createElement("ds_trans_id", $secureEcom->directoryServerTransactionId));
$mpi->appendChild($xml->createElement("authentication_value", $secureEcom->authenticationValue));
$mpi->appendChild($xml->createElement("message_version", $secureEcom->messageVersion));
}
if ($secureEcom->exemptStatus != null) {
$mpi->appendChild($xml->createElement("exempt_status", $secureEcom->exemptStatus));
}
$request->appendChild($mpi);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ServiceConfigs/Gateways/GpEcomConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function configureContainer($services) {
$secure3d2->setMerchantId($gateway->merchantId);
$secure3d2->setAccountId($gateway->accountId);
$secure3d2->setSharedSecret($gateway->sharedSecret);
$secure3d2->serviceUrl = $gateway->serviceUrl;
$secure3d2->serviceUrl = $this->environment == Environment::TEST ? ServiceEndpoints::THREE_DS_AUTH_TEST : ServiceEndpoints::THREE_DS_AUTH_PRODUCTION;
$secure3d2->setMerchantContactUrl($this->merchantContactUrl);
$secure3d2->setMethodNotificationUrl($this->merchantNotificationUrl);
$secure3d2->setMethodNotificationUrl($this->methodNotificationUrl);
$secure3d2->setChallengeNotificationUrl($this->challengeNotificationUrl);
$secure3d2->timeout = $gateway->timeout;

Expand Down
2 changes: 1 addition & 1 deletion src/ServicesContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function getReportingClient($configName)
/**
* @return ISecure3dProvider
*/
public function getSecure3d($configName, Secure3dVersion $version)
public function getSecure3d($configName, $version)
{
if (array_key_exists($configName, static::$configurations)) {
$provider = static::$configurations[$configName]->getSecure3dProvider($version);
Expand Down
Loading

0 comments on commit 3cdeb3b

Please sign in to comment.