Skip to content

Commit

Permalink
OctopusDeploy release: 12.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed May 30, 2024
1 parent 683c89b commit 836cc93
Show file tree
Hide file tree
Showing 25 changed files with 499 additions and 52 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

# Changelog

## Latest Version - v12.0.3 (05/23/24)
## Latest Version - v12.0.4 (05/30/24)
### Enhancements:
- [GP-ECOM] Added additional fee to a card transaction (surchargeamount).
- [GP-API] Add mapping for "message_received " and "message_sent " on get a Single Action response
- [GP-API] Add "Payers" feature

## v12.0.3 (05/23/24)
### Enhancements:
- [GP-API] Add "payer->email" property on 3DS "/initiate" request
- [GP-API] Improvements on access token request
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>12.0.3</releaseNumber>
<releaseNumber>12.0.4</releaseNumber>
</xml>
8 changes: 7 additions & 1 deletion src/Builders/AuthorizationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use GlobalPayments\Api\Entities\Enums\{AddressType,
AliasAction,
BNPLShippingMethod,
CreditDebitIndicator,
EmvFallbackCondition,
EmvLastChipRead,
InquiryType,
Expand Down Expand Up @@ -525,6 +526,9 @@ class AuthorizationBuilder extends TransactionBuilder
/** @var MerchantCategory */
public string $merchantCategory;

/** @var string|CreditDebitIndicator */
public string $creditDebitIndicator;

/**
* {@inheritdoc}
*
Expand Down Expand Up @@ -1446,12 +1450,14 @@ public function withClerkId($clerkId)

/**
* @param float $value
* @param string|CreditDebitIndicator $creditDebitIndicator
*
* @return AuthorizationBuilder
*/
public function withSurchargeAmount($value)
public function withSurchargeAmount($value, $creditDebitIndicator = null)
{
$this->surchargeAmount = $value;
$this->creditDebitIndicator = $creditDebitIndicator;

return $this;
}
Expand Down
20 changes: 20 additions & 0 deletions src/Builders/ManagementBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GlobalPayments\Api\Entities\{DccRateData, FundsData, LodgingData, Transaction};
use GlobalPayments\Api\Entities\Enums\{
CommercialIndicator,
CreditDebitIndicator,
PaymentMethodType,
PaymentMethodUsageMode,
TaxType,
Expand Down Expand Up @@ -211,6 +212,11 @@ class ManagementBuilder extends TransactionBuilder
/** @var FundsData */
public $fundsData;

public float $surchargeAmount;

/** @var string|CreditDebitIndicator */
public string $creditDebitIndicator;

/**
* {@inheritdoc}
*
Expand Down Expand Up @@ -755,4 +761,18 @@ public function withFundsData(FundsData $fundsData)

return $this;
}

/**
* @param float $value
* @param string|CreditDebitIndicator $creditDebitIndicator
*
* @return ManagementBuilder
*/
public function withSurchargeAmount($value, $creditDebitIndicator = null)
{
$this->surchargeAmount = $value;
$this->creditDebitIndicator = $creditDebitIndicator;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public function buildRequest(BaseBuilder $builder, $config)
$requestData = [];
$requestData['account_name'] = $config->accessTokenInfo->tokenizationAccountName;
$requestData['account_id'] = $config->accessTokenInfo->tokenizationAccountID;
$requestData['name'] = $builder->description ? $builder->description : "";
$requestData['reference'] = $builder->clientTransactionId ?
$builder->clientTransactionId : GenerationUtils::generateOrderId();
$requestData['name'] = $builder->description ?: "";
$requestData['payer'] = ['id' => $builder->customerId ?: ""];
$requestData['reference'] = $builder->clientTransactionId ?: GenerationUtils::generateOrderId();
$requestData['usage_mode'] = $builder->paymentMethodUsageMode;
$requestData['fingerprint_mode'] =
(!empty($builder->customerData) & !empty($builder->customerData->deviceFingerPrint) ?
Expand Down Expand Up @@ -311,8 +311,9 @@ private function setRequestStoredCredentials(StoredCredential $storedCredential,
*/
private function setPayerInformation($builder)
{
$payer['reference'] = !empty($builder->customerId) ?
$payer['id'] = !empty($builder->customerId) ?
$builder->customerId : (!empty($builder->customerData) ? $builder->customerData->id : null);
$payer['reference'] = !empty($builder->customerData) ? $builder->customerData->key : null;
switch (get_class($builder->paymentMethod)) {
case AlternativePaymentMethod::class:
$payer['home_phone'] = [
Expand Down
85 changes: 85 additions & 0 deletions src/Builders/RequestBuilder/GpApi/GpApiRecurringRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace GlobalPayments\Api\Builders\RequestBuilder\GpApi;

use GlobalPayments\Api\Builders\BaseBuilder;
use GlobalPayments\Api\Builders\RecurringBuilder;
use GlobalPayments\Api\Entities\Customer;
use GlobalPayments\Api\Entities\Enums\TransactionType;
use GlobalPayments\Api\Entities\GpApi\GpApiRequest;
use GlobalPayments\Api\Entities\IRequestBuilder;
use GlobalPayments\Api\Entities\Request;
use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig;

class GpApiRecurringRequestBuilder implements IRequestBuilder
{
private $builder;
/***
* @param RecurringBuilder $builder
*
* @return bool
*/
public static function canProcess($builder = null)
{
if ($builder instanceof RecurringBuilder) {
return true;
}

return false;
}

/**
* @param BaseBuilder $builder
* @param GpApiConfig $config
*
* @return Request
*/
public function buildRequest(BaseBuilder $builder, $config)
{
/** @var RecurringBuilder $builder */
$this->builder = $builder;
$requestData = [];
/**
* @var RecurringBuilder $builder
*/
switch ($builder->transactionType) {
case TransactionType::CREATE:
$endpoint = GpApiRequest::PAYERS_ENDPOINT;
$verb = 'POST';
if ($builder->entity instanceof Customer) {
$this->preparePayerRequest($requestData);
}
break;
case TransactionType::EDIT:
$endpoint = GpApiRequest::PAYERS_ENDPOINT . '/' . $this->builder->entity->id;
$verb = 'PATCH';
if ($builder->entity instanceof Customer) {
$this->preparePayerRequest($requestData);
}
break;
}
return new GpApiRequest($endpoint, $verb, $requestData);
}

private function preparePayerRequest(array &$requestData)
{
/** @var Customer $customer */
$customer = $this->builder->entity;
$requestData['first_name'] = $customer->firstName;
$requestData['last_name'] = $customer->lastName;
$requestData['reference'] = $customer->key;
if (!empty($customer->paymentMethods)) {
foreach ($customer->paymentMethods as $index => $paymentMethod) {
$requestData['payment_methods'][] = [
'id' => $index,
'default' => $index === array_key_first($customer->paymentMethods) ? 'YES' : 'NO',
];
}
}
}

public function buildRequestFromJson($jsonRequest, $config)
{
// TODO: Implement buildRequestFromJson() method.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ public function buildRequest(BaseBuilder $builder, $config)
}

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

if (isset($builder->surchargeAmount)) {
$surchargeAmount = $xml->createElement("surchargeamount", preg_replace('/[^0-9]/', '', sprintf('%01.2f', $builder->surchargeAmount)));
if (!empty($builder->creditDebitIndicator)) {
$surchargeAmount->setAttribute("type", strtolower($builder->creditDebitIndicator));
}
$request->appendChild($surchargeAmount);
}
// For Fraud Decision Manager
if (!empty($builder->customerData)) {
$customerValue = $builder->customerData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public function buildRequest(BaseBuilder $builder, $config)
}

$request->appendChild($xml->createElement("orderid", $orderId));
if (isset($builder->surchargeAmount)) {
$surchargeAmount = $xml->createElement("surchargeamount", preg_replace('/[^0-9]/', '', sprintf('%01.2f', $builder->surchargeAmount)));
if (!empty($builder->creditDebitIndicator)) {
$surchargeAmount->setAttribute("type", strtolower($builder->creditDebitIndicator));
}
$request->appendChild($surchargeAmount);
}
$request->appendChild($xml->createElement("pasref", $builder->transactionId ?? ''));

// rebate hash
Expand Down
10 changes: 7 additions & 3 deletions src/Builders/RequestBuilder/RequestBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
namespace GlobalPayments\Api\Builders\RequestBuilder;

use GlobalPayments\Api\Builders\BaseBuilder;
use GlobalPayments\Api\Builders\RequestBuilder\GpApi\{GpApiAuthorizationRequestBuilder,
use GlobalPayments\Api\Builders\RequestBuilder\GpApi\{
GpApiAuthorizationRequestBuilder,
GpApiFileProcessingRequestBuilder,
GpApiManagementRequestBuilder,
GpApiMiCRequestBuilder,
GpApiPayFacRequestBuilder,
GpApiRecurringRequestBuilder,
GpApiReportRequestBuilder,
GpApiSecureRequestBuilder};
GpApiSecureRequestBuilder
};
use GlobalPayments\Api\Builders\RequestBuilder\GpEcom\{
GpEcomAuthorizationRequestBuilder,
GpEcomManagementRequestBuilder,
Expand Down Expand Up @@ -40,7 +43,8 @@ class RequestBuilderFactory
GpApiSecureRequestBuilder::class,
GpApiPayFacRequestBuilder::class,
GpApiMiCRequestBuilder::class,
GpApiFileProcessingRequestBuilder::class
GpApiFileProcessingRequestBuilder::class,
GpApiRecurringRequestBuilder::class,
],
GatewayProvider::TRANSACTION_API => [
TransactionApiReportRequestBuilder::class,
Expand Down
3 changes: 3 additions & 0 deletions src/Entities/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class Customer extends RecurringEntity
/** @var array<CustomerDocument> */
public $documents = [];

public array $paymentMethods = [];

/**
* Adds a payment method to the customer
*
Expand All @@ -166,6 +168,7 @@ public function addPaymentMethod($paymentId, IPaymentMethod $paymentMethod, ?Sto
$payment->id = $paymentId;
$payment->nameOnAccount = $nameOnAccount;
$payment->storedCredential = $storedCredential;
$this->paymentMethods[$paymentId] = $paymentMethod;
return $payment;
}
}
1 change: 1 addition & 0 deletions src/Entities/Enums/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
class UserType extends Enum
{
const MERCHANT = 'MERCHANT';
const PAYER = 'PAYER';
}
1 change: 1 addition & 0 deletions src/Entities/GpApi/GpApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ class GpApiRequest extends Request
const TRANSFER_ENDPOINT = '/transfers';
const DEVICE_ENDPOINT = '/devices';
const FILE_PROCESSING = '/files';
const PAYERS_ENDPOINT = '/payers';
}
3 changes: 3 additions & 0 deletions src/Entities/Reporting/ActionSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ class ActionSummary
* @var string
*/
public $accountId;

public ?string $rawRequest = null;
public ?string $rawResponse = null;
}
11 changes: 11 additions & 0 deletions src/Gateways/GpApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use GlobalPayments\Api\Builders\FraudBuilder;
use GlobalPayments\Api\Builders\ManagementBuilder;
use GlobalPayments\Api\Builders\PayFacBuilder;
use GlobalPayments\Api\Builders\RecurringBuilder;
use GlobalPayments\Api\Builders\ReportBuilder;
use GlobalPayments\Api\Builders\RequestBuilder\GpApi\GpApiMiCRequestBuilder;
use GlobalPayments\Api\Builders\RequestBuilder\RequestBuilderFactory;
Expand Down Expand Up @@ -224,6 +225,16 @@ public function processFileUpload(FileProcessingBuilder $builder) : FileProcesso
return GpApiMapping::mapFileProcessingResponse($response);
}

public function processRecurring(RecurringBuilder $builder)
{
if (empty($this->accessToken)) {
$this->signIn();
}
$response = $this->executeProcess($builder);

return GpApiMapping::mapRecurringEntity($response, $builder->entity);
}

private function executeProcess(BaseBuilder $builder)
{
$processFactory = new RequestBuilderFactory();
Expand Down
23 changes: 22 additions & 1 deletion src/Mapping/GpApiMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use GlobalPayments\Api\Entities\BNPLResponse;
use GlobalPayments\Api\Entities\Card;
use GlobalPayments\Api\Entities\CardIssuerResponse;
use GlobalPayments\Api\Entities\Customer;
use GlobalPayments\Api\Entities\DisputeDocument;
use GlobalPayments\Api\Entities\DccRateData;
use GlobalPayments\Api\Entities\Document;
Expand Down Expand Up @@ -41,6 +42,7 @@
use GlobalPayments\Api\Entities\Person;
use GlobalPayments\Api\Entities\PersonList;
use GlobalPayments\Api\Entities\PhoneNumber;
use GlobalPayments\Api\Entities\RecurringEntity;
use GlobalPayments\Api\Entities\Reporting\ActionSummary;
use GlobalPayments\Api\Entities\Reporting\DepositSummary;
use GlobalPayments\Api\Entities\Reporting\DisputeSummary;
Expand Down Expand Up @@ -700,7 +702,8 @@ public static function mapActionsSummary($response)
$summary->merchantName = !empty($response->merchant_name) ? $response->merchant_name : null;
$summary->accountName = !empty($response->account_name) ? $response->account_name : null;
$summary->accountId = !empty($response->account_id) ? $response->account_id : null;

$summary->rawRequest = $response->message_received ?? null;
$summary->rawResponse = $response->message_sent ?? null;
return $summary;
}

Expand Down Expand Up @@ -1346,4 +1349,22 @@ private static function mapSystemResponse(TransactionSummary|DepositSummary &$su
$summary->merchantName = $system->name ?? null;
$summary->merchantDbaName = $system->dba ?? null;
}

public static function mapRecurringEntity($response,RecurringEntity $recurringEntity) : RecurringEntity
{
switch (get_class($recurringEntity)) {
case Customer::class:
$payer = $recurringEntity;
$payer->id = $response->id;
if (!empty($response->payment_methods)) {
$payer->paymentMethods = [];
foreach ($response->payment_methods as $paymentMethod) {
$payer->paymentMethods[] = $paymentMethod;
}
}
return $payer;
default:
break;
}
}
}
1 change: 1 addition & 0 deletions src/ServiceConfigs/Gateways/GpApiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function configureContainer(ConfiguredServices $services)
$services->reportingService = $gateway;
$services->fraudService = $gateway;
$services->fileProcessingService = $gateway;
$services->recurringConnector = $gateway;

$services->setOpenBankingProvider($gateway);
$services->setPayFacProvider($gateway);
Expand Down
Loading

0 comments on commit 836cc93

Please sign in to comment.