Skip to content

Commit

Permalink
OctopusDeploy release: 2.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed Aug 3, 2021
1 parent 7b710dd commit aea2fc0
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 29 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
# Changelog

## Latest version
- Send "x-gp-sdk" in the header with the SDK programming language and release version used
- Send headers to GP-API that are dynamically set through configuration, like:
- x-gp-platform: "prestashop;version=1.7.2"
- x-gp-extension: "coccinet;version=2.4.1"
- Fix some GP-ECOM unit tests for APM, certifications and add Secure3dServiceTest to realex test suite
- Add support for Propay timezone and device details

## v2.3.8 (07/27/2021)

#### Enhancements:
- Add new HPP example for GP-ECOM
- Add file medatada.xml


## v2.3.7 (07/20/2021)

#### Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion metadata.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<xml>
<releaseNumber>2.3.8</releaseNumber>
<releaseNumber>2.3.9</releaseNumber>
</xml>
9 changes: 8 additions & 1 deletion src/Builders/PayFacBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PayFacBuilder extends BaseBuilder
public $flashFundsPaymentCardData;
public $externalId;
public $sourceEmail;
public $deviceDetails;

const UPLOAD_FILE_TYPES = [
'tif', 'tiff', 'bmp', 'jpg', 'jpeg', 'gif', 'png', 'doc', 'docx'
Expand Down Expand Up @@ -166,7 +167,6 @@ protected function setupValidations()
->check('transNum')->isNotNull()
->check('requireCCRefund')->isNotNull()
->check('ccAmount')->isNotNull();

}

/*
Expand Down Expand Up @@ -384,4 +384,11 @@ public function withSourceEmail($sourceEmail)
$this->sourceEmail = $sourceEmail;
return $this;
}

public function withDeviceDetails($deviceDetails)
{
$this->deviceDetails = $deviceDetails;
return $this;
}

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

namespace GlobalPayments\Api\Entities\Enums;

use GlobalPayments\Api\Entities\Enum;

class TimeZone extends Enum
{
const UTC = "UTC"; //Universal Time Coordinated
const PT = "PT"; //Pacific Time (US) (UTC-8/7DST)
const MST = "MST"; //Arizona (Mountain Standard Time[US]) (UTC-7)
const MT = 'MT'; //Mountain Time (US) (UTC-7/6DST)
const CT = 'CT'; //Central Time (US) (UTC-6/5DST)
const ET = 'ET'; //Eastern Time (US) (UTC-5/4DST)
const HST = 'HST'; //Hawaii Standard Time (UTC-10)
const AT = 'AT'; //Atlantic Time (UTC-4/3DST)
const AST = 'AST'; //Puerto Rico (Atlantic Standard Time)(UTC-4)
const AKST = 'AKST'; //Alaska (Alaska Standard Time) (UTC-9)
}
9 changes: 9 additions & 0 deletions src/Entities/PayFac/DeviceDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace GlobalPayments\Api\Entities\PayFac;

class DeviceDetails
{
public $quantity;
public $timezone;
}
8 changes: 7 additions & 1 deletion src/Gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ abstract class Gateway
*/
public $webProxy;

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

/**
* @param string $contentType
*
Expand All @@ -51,6 +56,7 @@ abstract class Gateway
public function __construct($contentType)
{
$this->headers = [];
$this->dynamicHeaders = [];
$this->contentType = $contentType;
}

Expand Down Expand Up @@ -83,7 +89,7 @@ protected function sendRequest(
$queryString = $this->buildQueryString($queryStringParams);
$request = curl_init($this->serviceUrl . $endpoint . $queryString);

$this->headers = array_merge($this->headers, [
$this->headers = array_merge($this->dynamicHeaders, $this->headers, [
'Content-Type' => sprintf('%s; charset=UTF-8', $this->contentType),
'Content-Length' => empty($data) ? 0 : strlen($data),
]);
Expand Down
17 changes: 17 additions & 0 deletions src/Gateways/GpApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public function __construct(GpApiConfig $gpApiConfig)
$this->headers['X-GP-Version'] = self::GP_API_VERSION;
$this->headers['Accept'] = 'application/json';
$this->headers['Accept-Encoding'] = 'gzip';
$this->headers['x-gp-sdk'] = 'php;version=' . $this->getReleaseVersion();
}

/**
* Get the SDK release version
*
* @return string|null
*/
private function getReleaseVersion()
{
$filename = dirname(__FILE__) . "/../../metadata.xml";
if (!file_exists($filename)) {
return null;
}
$xml = simplexml_load_string(file_get_contents($filename));

return !empty($xml->releaseNumber) ? $xml->releaseNumber : null;
}

public function getVersion()
Expand Down
43 changes: 31 additions & 12 deletions src/Gateways/ProPayConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use GlobalPayments\Api\Entities\PayFac\RenewAccountData;
use GlobalPayments\Api\Entities\PayFac\SingleSignOnData;
use GlobalPayments\Api\Entities\PayFac\OwnerDetailsResponseData;
use GlobalPayments\Api\Entities\PayFac\DeviceDetails;

class ProPayConnector extends XmlGateway implements IPayFacProvider
{
Expand Down Expand Up @@ -62,16 +63,16 @@ public function processPayFac(PayFacBuilder $builder)
$this->hydrateFlashFundsData($xml, $xmlTrans, $builder->flashFundsPaymentCardData);
} elseif ($builder->transactionType === TransactionType::GET_ACCOUNT_DETAILS
&& empty($builder->accountNumber)) {
if(!empty($builder->externalId)){
if (!empty($builder->externalId)) {
$xmlTrans->appendChild($xml->createElement('externalId', $builder->externalId));
} elseif(!empty($builder->sourceEmail)){
} elseif (!empty($builder->sourceEmail)) {
$xmlTrans->appendChild($xml->createElement('sourceEmail', $builder->sourceEmail));
}
}

$transaction->appendChild($xmlTrans);

$requestXML = $xml->saveXML($transaction);
$requestXML = $xml->saveXML($transaction);
$response = $this->doTransaction($requestXML);

return $this->mapResponse($builder, $response);
Expand Down Expand Up @@ -186,6 +187,10 @@ private function hydrateAccountDetails($xml, $xmlTrans, PayFacBuilder $builder)
if (!empty($builder->grossBillingInformation)) {
$this->hydrateGrossBillingData($xml, $xmlTrans, $builder->grossBillingInformation);
}

if (!empty($builder->deviceDetails)) {
$this->hydrateDeviceQuantity($xml, $xmlTrans, $builder->deviceDetails);
}

$this->hydrateBankDetails($xml, $xmlTrans, $builder);
$this->hydratOtherDetails($xml, $xmlTrans, $builder);
Expand All @@ -205,6 +210,8 @@ private function hydrateAccountEditDetails($xml, $xmlTrans, PayFacBuilder $build
$this->hydrateBusinessData($xml, $xmlTrans, $builder->businessData);
} elseif (!empty($builder->grossBillingInformation)) {
$this->hydrateGrossBillingData($xml, $xmlTrans, $builder->grossBillingInformation);
} elseif (!empty($builder->deviceQuantity)) {
$this->hydrateDeviceQuantity($xml, $xmlTrans, $builder->deviceQuantity);
}
//update bank details if any
$this->hydrateBankDetails($xml, $xmlTrans, $builder);
Expand Down Expand Up @@ -248,7 +255,7 @@ private function hydrateBeneficialOwnerData($xml, $xmLtransaction, $beneficialOw
'City' => !empty($ownerInfo->ownerAddress->city) ? $ownerInfo->ownerAddress->city : '',
'State' => !empty($ownerInfo->ownerAddress->state) ? $ownerInfo->ownerAddress->state : '',
'Zip' => !empty($ownerInfo->ownerAddress->postalCode) ? $ownerInfo->ownerAddress->postalCode : '',
'Country' => !empty($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '',
'Country' => !is_null($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '',
'Title' => !empty($ownerInfo->title) ? $ownerInfo->title : '',
'Percentage' => !empty($ownerInfo->percentage) ? $ownerInfo->percentage : ''
];
Expand Down Expand Up @@ -277,7 +284,7 @@ private function hydrateBusinessData($xml, $transaction, BusinessData $businessD
'BusinessAddress' => !empty($businessData->businessAddress->streetAddress1) ? $businessData->businessAddress->streetAddress1 : '',
'BusinessAddress2' => !empty($businessData->businessAddress->streetAddress2) ? $businessData->businessAddress->streetAddress2 : '',
'BusinessCity' => !empty($businessData->businessAddress->city) ? $businessData->businessAddress->city : '',
'BusinessCountry' => !empty($businessData->businessAddress->country) ? $businessData->businessAddress->country : '',
'BusinessCountry' => !is_null($businessData->businessAddress->country) ? $businessData->businessAddress->country : '',
'BusinessState' => !empty($businessData->businessAddress->state) ? $businessData->businessAddress->state : '',
'BusinessZip' => !empty($businessData->businessAddress->postalCode) ? $businessData->businessAddress->postalCode : ''
];
Expand Down Expand Up @@ -310,13 +317,13 @@ private function hydrateUserPersonalData($xml, $transaction, UserPersonalData $u
'city' => !empty($merchantAddress->city) ? $merchantAddress->city : '',
'state' => !empty($merchantAddress->state) ? $merchantAddress->state : '',
'zip' => !empty($merchantAddress->postalCode) ? $merchantAddress->postalCode : '',
'country' => !empty($merchantAddress->country) ? $merchantAddress->country : '',
'country' => !is_null($merchantAddress->country) ? $merchantAddress->country : '',

'mailAddr' => !empty($mailingAddress->streetAddress1) ? $mailingAddress->streetAddress1 : '',
'mailApt' => !empty($mailingAddress->streetAddress2) ? $mailingAddress->streetAddress2: '',
'mailAddr3' => !empty($mailingAddress->streetAddress3) ? $mailingAddress->streetAddress3 : '',
'mailCity' => !empty($mailingAddress->city) ? $mailingAddress->city : '',
'mailCountry' => !empty($mailingAddress->country) ? $mailingAddress->country : '',
'mailCountry' => !is_null($mailingAddress->country) ? $mailingAddress->country : '',
'mailState' => !empty($mailingAddress->state) ? $mailingAddress->state : '' ,
'mailZip' => !empty($mailingAddress->postalCode) ? $mailingAddress->postalCode : '',
];
Expand Down Expand Up @@ -401,7 +408,7 @@ private function hydratOtherDetails($xml, $xmlTrans, $builder)
'SignificantOwnerCityName' => !empty($significantOwnerData->ownerAddress->city) ? $significantOwnerData->ownerAddress->city : '',
'SignificantOwnerRegionCode' => !empty($significantOwnerData->ownerAddress->state) ? $significantOwnerData->ownerAddress->state : '',
'SignificantOwnerPostalCode' => !empty($significantOwnerData->ownerAddress->postalCode) ? $significantOwnerData->ownerAddress->postalCode : '',
'SignificantOwnerCountryCode' => !empty($significantOwnerData->ownerAddress->country) ? $significantOwnerData->ownerAddress->country : '',
'SignificantOwnerCountryCode' => !is_null($significantOwnerData->ownerAddress->countryCode) ? $significantOwnerData->ownerAddress->countryCode : '',
'SignificantOwnerTitle' => !empty($significantOwnerData->title) ? $significantOwnerData->title : '',
'SignificantOwnerPercentage' => !empty($significantOwnerData->percentage) ? $significantOwnerData->percentage : '',
]);
Expand All @@ -417,13 +424,13 @@ private function hydrateGrossBillingData($xml, $transaction, $grossBilling)
'GrossSettleCity' => !empty($grossBilling->grossSettleAddress->city) ? $grossBilling->grossSettleAddress->city : '',
'GrossSettleState' => !empty($grossBilling->grossSettleAddress->state) ? $grossBilling->grossSettleAddress->state : '',
'GrossSettleZipCode' => !empty($grossBilling->grossSettleAddress->postalCode) ? $grossBilling->grossSettleAddress->postalCode : '',
'GrossSettleCountry' => !empty($grossBilling->grossSettleAddress->country) ? $grossBilling->grossSettleAddress->country : '',
'GrossSettleCountry' => !is_null($grossBilling->grossSettleAddress->country) ? $grossBilling->grossSettleAddress->country : '',

'GrossSettleCreditCardNumber' => !empty($grossBilling->grossSettleCreditCardData->number) ? $grossBilling->grossSettleCreditCardData->number : '',
'GrossSettleNameOnCard' => !empty($grossBilling->grossSettleCreditCardData->cardHolderName) ? $grossBilling->grossSettleCreditCardData->cardHolderName : '',
'GrossSettleCreditCardExpDate' => $grossBilling->grossSettleCreditCardData->getShortExpiry(),

'GrossSettleAccountCountryCode' => !empty($grossBilling->grossSettleBankData->accountCountryCode) ? $grossBilling->grossSettleBankData->accountCountryCode : '',
'GrossSettleAccountCountryCode' => !is_null($grossBilling->grossSettleBankData->accountCountryCode) ? $grossBilling->grossSettleBankData->accountCountryCode : '',
'GrossSettleAccountHolderName' => !empty($grossBilling->grossSettleBankData->accountName) ? $grossBilling->grossSettleBankData->accountName : '',
'GrossSettleAccountNumber' => !empty($grossBilling->grossSettleBankData->accountNumber) ? $grossBilling->grossSettleBankData->accountNumber : '',
'GrossSettleAccountType' => !empty($grossBilling->grossSettleBankData->accountType) ? $grossBilling->grossSettleBankData->accountType : '',
Expand Down Expand Up @@ -533,7 +540,7 @@ private function updateBankAccountOwnershipInfo($xml, $xmLtransaction, $benefici
'City' => !empty($ownerInfo->ownerAddress->city) ? $ownerInfo->ownerAddress->city : '',
'StateProvince' => !empty($ownerInfo->ownerAddress->state) ? $ownerInfo->ownerAddress->state : '',
'PostalCode' => !empty($ownerInfo->ownerAddress->postalCode) ? $ownerInfo->ownerAddress->postalCode : '',
'Country' => !empty($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '',
'Country' => !is_null($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '',
'Phone' => !empty($ownerInfo->phone) ? $ownerInfo->phone : '',
];

Expand Down Expand Up @@ -633,7 +640,7 @@ private function populateProPayResponse($root)

if (!empty($root->beneficialOwnerDataResult->Owner)) {
foreach ($root->beneficialOwnerDataResult->Owner as $owner) {
$ownerDetails = new OwnerDetailsResponseData();
$ownerDetails = new OwnerDetailsResponseData();
$ownerDetails->firstName = (string) $owner->FirstName;
$ownerDetails->lastName = (string) $owner->LastName;
$ownerDetails->validationStatus = (string) $owner->Status;
Expand All @@ -643,4 +650,16 @@ private function populateProPayResponse($root)

return $propayResponse;
}

private function hydrateDeviceQuantity($xml, $xmlTrans, DeviceDetails $deviceDetails)
{
$devicesList = $xml->createElement('Devices');
$device = $xml->createElement('Device');
$device->appendChild($xml->createElement('Quantity', $deviceDetails->quantity));
$devicesList->appendChild($device);

$xmlTrans->appendChild($devicesList);

$xmlTrans->appendChild($xml->createElement('TimeZone', $deviceDetails->timezone));
}
}
13 changes: 7 additions & 6 deletions src/Gateways/RealexConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,13 @@ public function processAuthorization(AuthorizationBuilder $builder)
$request->setAttribute("type", $transactionType);

$request->appendChild($xml->createElement("merchantid", $this->merchantId));

if ($this->accountId !== null) {
$request->appendChild($xml->createElement("account", $this->accountId));
}
if ($this->channel !== null) {
$request->appendChild($xml->createElement("channel", $this->channel));
}

$request->appendChild($xml->createElement("orderid", $orderId));

if (isset($builder->amount)) {
$amount = $xml->createElement("amount", preg_replace('/[^0-9]/', '', sprintf('%01.2f', $builder->amount)));
Expand All @@ -168,6 +166,8 @@ public function processAuthorization(AuthorizationBuilder $builder)
$request->appendChild($element);
}

$request->appendChild($xml->createElement("orderid", $orderId));

// For Fraud Decision Manager
if (!empty($builder->customerData)) {
$customerValue = $builder->customerData;
Expand Down Expand Up @@ -463,8 +463,8 @@ public function processAuthorization(AuthorizationBuilder $builder)
}

// mpi
$secureEcom = $builder->paymentMethod->threeDSecure;
if (!empty($secureEcom)) {
if (!empty($builder->paymentMethod->threeDSecure)) {
$secureEcom = $builder->paymentMethod->threeDSecure;
$mpi = $xml->createElement("mpi");
$mpi->appendChild($xml->createElement("eci", $secureEcom->eci));
$mpi->appendChild($xml->createElement("cavv", $secureEcom->cavv));
Expand Down Expand Up @@ -596,6 +596,7 @@ public function serializeRequest(AuthorizationBuilder $builder)
$this->setSerializeData('CUST_NUM', $builder->customerId);
}
if (!empty($builder->shippingAddress)) {

$countryCode = CountryUtils::getCountryCodeByCountry($builder->shippingAddress->country);
$shippingCode = $this->generateCode($builder->shippingAddress);

Expand Down Expand Up @@ -1451,7 +1452,7 @@ private function mapAcceptedCodes($paymentMethodType)
case "3ds-verifysig":
case "3ds-verifyenrolled":
return ["00", "110"];
case PaymentMethodType::APM:
case "payment-set":
return ["01"];
default:
return ["00"];
Expand Down
5 changes: 5 additions & 0 deletions src/ServiceConfigs/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ abstract public function configureContainer(ConfiguredServices $services);
/** @var bool */
public $forceGatewayTimeout;

/**
* @var array
*/
public $dynamicHeaders = [];

public function validate()
{
$this->validated = true;
Expand Down
1 change: 1 addition & 0 deletions src/ServiceConfigs/Gateways/GpApiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function configureContainer(ConfiguredServices $services)
$gateway->serviceUrl = $this->serviceUrl;
$gateway->requestLogger = $this->requestLogger;
$gateway->webProxy = $this->webProxy;
$gateway->dynamicHeaders = $this->dynamicHeaders;

$services->gatewayConnector = $gateway;
$services->reportingService = $gateway;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,11 @@ public function setUpConfig()
$config->environment = Environment::TEST;
$config->channel = Channels::CardNotPresent;
$config->country = 'GB';
//DO NO DELETE - usage example for some settings
// $config->dynamicHeaders = [
// 'x-gp-platform' => 'prestashop;version=1.7.2',
// 'x-gp-extension' => 'coccinet;version=2.4.1',
// ];
// $config->permissions = ['TRN_POST_Authorize'];
// $config->webProxy = new CustomWebProxy('127.0.0.1:8866');
// $config->requestLogger = new SampleRequestLogger(new Logger("logs"));
Expand Down
Loading

0 comments on commit aea2fc0

Please sign in to comment.