Skip to content

Commit

Permalink
OctopusDeploy release: 7.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed May 9, 2023
1 parent cf0bb83 commit 73afe68
Show file tree
Hide file tree
Showing 30 changed files with 605 additions and 402 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

## Latest Version
#### Enhancements:
- GP-API: Manage fund transfers, splits and reverse splits in your partner network.
- https://developer.globalpay.com/api/transfers
- https://developer.globalpay.com/api/transactions#/Split%20a%20Transaction%20Amount/splitTransaction
- Updates on unit tests for: PayLink, 3DS1 and RiskAssessment


## v7.0.2 (05/02/2023)
#### Enhancements:
- GP-API: Manage merchant accounts for partner solution
(https://developer.globalpay.com/api/accounts)
- https://developer.globalpay.com/api/accounts
- GP-ECOM: Add to the mapping response fields: acs_reference_number & acs_signed_content for the authentication source MOBILE_SDK

## v7.0.1 (04/04/2023)
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>7.0.2</releaseNumber>
<releaseNumber>7.0.3</releaseNumber>
</xml>
39 changes: 34 additions & 5 deletions src/Builders/ManagementBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace GlobalPayments\Api\Builders;

use GlobalPayments\Api\Entities\{
DccRateData,
LodgingData,
Transaction
};
use GlobalPayments\Api\Entities\{DccRateData, FundsData, LodgingData, Transaction};
use GlobalPayments\Api\Entities\Enums\{
CommercialIndicator,
PaymentMethodUsageMode,
Expand Down Expand Up @@ -208,6 +204,12 @@ class ManagementBuilder extends TransactionBuilder
/** @var PaymentMethodUsageMode */
public $paymentMethodUsageMode;

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

/** @var FundsData */
public $fundsData;

/**
* {@inheritdoc}
*
Expand Down Expand Up @@ -715,4 +717,31 @@ public function withLodgingData($lodgingData)

return $this;
}

/**
* Set the reference
*
* @param string $reference
*
* @return $this
*/
public function withReference($reference)
{
$this->reference = $reference;

return $this;
}

/**
* Set the details about the funds transfer
*
* @param FundsData $fundsData
* @return $this
*/
public function withFundsData(FundsData $fundsData)
{
$this->fundsData = $fundsData;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use GlobalPayments\Api\Entities\Enums\TransactionModifier;
use GlobalPayments\Api\Entities\Enums\TransactionType;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
use GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException;
use GlobalPayments\Api\Entities\GpApi\DTO\Card;
use GlobalPayments\Api\Entities\GpApi\DTO\PaymentMethod;
use GlobalPayments\Api\Entities\GpApi\GpApiRequest;
Expand All @@ -40,6 +41,7 @@
use GlobalPayments\Api\PaymentMethods\DebitTrackData;
use GlobalPayments\Api\PaymentMethods\ECheck;
use GlobalPayments\Api\PaymentMethods\AlternativePaymentMethod;
use GlobalPayments\Api\PaymentMethods\FundsAccount;
use GlobalPayments\Api\PaymentMethods\Interfaces\ICardData;
use GlobalPayments\Api\PaymentMethods\Interfaces\IEncryptable;
use GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable;
Expand Down Expand Up @@ -167,6 +169,23 @@ public function buildRequest(BaseBuilder $builder, $config)
];
}
break;
case TransactionType::TRANSFER_FUNDS:
if (!$builder->paymentMethod instanceof FundsAccount) {
throw new UnsupportedTransactionException("Payment method doesn't support funds transfers");
}
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->paymentMethod->merchantId .
GpApiRequest::TRANSFER_ENDPOINT;
$verb = 'POST';
$requestData = [
'account_id' => $builder->paymentMethod->accountId ?? null,
'account_name' => $builder->paymentMethod->accountName ?? null,
'recipient_account_id' => $builder->paymentMethod->recipientAccountId ?? null,
'reference' => $builder->clientTransactionId ?? GenerationUtils::getGuid(),
'amount' => StringUtils::toNumeric($builder->amount),
'description' => $builder->description,
'usable_balance_mode' => $builder->paymentMethod->usableBalanceMode ?? null
];
break;
default:
return '';
}
Expand Down Expand Up @@ -413,6 +432,7 @@ private function createPaymentMethodParam($builder, $config)
break;
case ECheck::class:
$paymentMethod->name = $paymentMethodContainer->checkHolderName;
$paymentMethod->narrative = $paymentMethodContainer->merchantNotes;
$paymentMethod->bank_transfer = [
'account_number' => $paymentMethodContainer->accountNumber,
'account_type' => EnumMapping::mapAccountType(
Expand All @@ -421,19 +441,18 @@ private function createPaymentMethodParam($builder, $config)
),
'check_reference' => $paymentMethodContainer->checkReference,
'sec_code' => $paymentMethodContainer->secCode,
'narrative' => $paymentMethodContainer->merchantNotes,
'bank' => [
'code' => $paymentMethodContainer->routingNumber,
'name' => $paymentMethodContainer->bankName,
'address' =>
[
'line_1' => $paymentMethodContainer->bankAddress->streetAddress1,
'line_2' => $paymentMethodContainer->bankAddress->streetAddress2,
'line_3' => $paymentMethodContainer->bankAddress->streetAddress3,
'city' => $paymentMethodContainer->bankAddress->city,
'postal_code' => $paymentMethodContainer->bankAddress->postalCode,
'state' => $paymentMethodContainer->bankAddress->state,
'country' => $paymentMethodContainer->bankAddress->countryCode
'line_1' => $paymentMethodContainer->bankAddress->streetAddress1 ?? null,
'line_2' => $paymentMethodContainer->bankAddress->streetAddress2 ?? null,
'line_3' => $paymentMethodContainer->bankAddress->streetAddress3 ?? null,
'city' => $paymentMethodContainer->bankAddress->city ?? null,
'postal_code' => $paymentMethodContainer->bankAddress->postalCode ?? null,
'state' => $paymentMethodContainer->bankAddress->state ?? null,
'country' => $paymentMethodContainer->bankAddress->countryCode ?? null
]
]
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,19 @@ public function buildRequest(BaseBuilder $builder, $config)
break;
case TransactionType::REVERSAL:
$endpoint = GpApiRequest::TRANSACTION_ENDPOINT . '/' . $builder->paymentMethod->transactionId . '/reversal';
if ($builder->paymentMethod->paymentMethodType == PaymentMethodType::ACCOUNT_FUNDS) {
$endpoint = GpApiRequest::TRANSFER_ENDPOINT . '/' . $builder->paymentMethod->transactionId .
'/reversal';
if (!empty($builder->fundsData->merchantId)) {
$endpoint = GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' .
$builder->fundsData->merchantId .
$endpoint;
}
}
$verb = 'POST';
$payload['amount'] = StringUtils::toNumeric($builder->amount);
$payload['currency_conversion'] = !empty($builder->dccRateData) ? $this->getDccRate($builder->dccRateData) : null;
$payload['currency_conversion'] = !empty($builder->dccRateData) ?
$this->getDccRate($builder->dccRateData) : null;
break;
case TransactionType::CAPTURE:
$endpoint = GpApiRequest::TRANSACTION_ENDPOINT . '/' . $builder->paymentMethod->transactionId . '/capture';
Expand Down Expand Up @@ -253,6 +263,25 @@ public function buildRequest(BaseBuilder $builder, $config)
'reason_code' => EnumMapping::mapReasonCode(GatewayProvider::GP_API, $builder->reasonCode) ?? null
];
break;
case TransactionType::SPLIT_FUNDS:
$endpoint =
GpApiRequest::TRANSACTION_ENDPOINT . '/' . $builder->paymentMethod->transactionId .
'/split';
if ($builder->paymentMethod->paymentMethodType == PaymentMethodType::ACCOUNT_FUNDS) {
$endpoint =
GpApiRequest::MERCHANT_MANAGEMENT_ENDPOINT . '/' . $builder->fundsData->merchantId .
$endpoint;
}
$verb = 'POST';
$payload['transfers'] = [
[
'recipient_account_id' => $builder->fundsData->recipientAccountId ?? null,
'reference' => $builder->reference,
'amount' => StringUtils::toNumeric($builder->amount),
'description' => $builder->description
]
];
break;
default:
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/Entities/Enums/PaymentMethodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ class PaymentMethodType extends Enum
const APM = 8;
const BANK_PAYMENT = 9;
const BNPL = 10;
const ACCOUNT_FUNDS = 11;
}
1 change: 1 addition & 0 deletions src/Entities/Enums/TransactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ class TransactionType extends Enum
const REAUTH = 36028797018963968; // 1 << 55
const CONFIRM = 72057594037927936; // 1 << 56
const PAYLINK_UPDATE = 144115188075855872; // 1 << 57
const TRANSFER_FUNDS = 288230376151711744; // // 1 << 58
}
11 changes: 11 additions & 0 deletions src/Entities/Enums/UsableBalanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace GlobalPayments\Api\Entities\Enums;

use GlobalPayments\Api\Entities\Enum;

class UsableBalanceMode extends Enum
{
const AVAILABLE_BALANCE = 'AVAILABLE_BALANCE';
const AVAILABLE_AND_PENDING_BALANCE = 'AVAILABLE_AND_PENDING_BALANCE';
}
17 changes: 17 additions & 0 deletions src/Entities/FundsData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace GlobalPayments\Api\Entities;

class FundsData
{
/**
* @var string
*/
public $merchantId;

/**
* The merchant's account id that will be receiving the transfer
* @var string
*/
public $recipientAccountId;
}
3 changes: 3 additions & 0 deletions src/Entities/GpApi/AccessTokenInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class AccessTokenInfo
*/
public $accessToken;

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

/**
* @var string
*/
Expand Down
1 change: 1 addition & 0 deletions src/Entities/GpApi/GpApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class GpApiRequest extends Request
const PAYLINK_ENDPOINT = '/links';
const RISK_ASSESSMENTS = '/risk-assessments';
const ACCOUNTS_ENDPOINT = '/accounts';
const TRANSFER_ENDPOINT = '/transfers';
}
23 changes: 21 additions & 2 deletions src/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace GlobalPayments\Api\Entities;

use GlobalPayments\Api\Builders\AuthorizationBuilder;
use GlobalPayments\Api\Builders\ManagementBuilder;
use GlobalPayments\Api\Entities\Enums\PaymentMethodType;
use GlobalPayments\Api\Entities\Enums\PaymentMethodUsageMode;
Expand All @@ -23,6 +22,7 @@
* @property string $transactionId The transaction ID.
* @property AlternativePaymentResponse $alternativePaymentResponse The APM response
* @property BNPLResponse $bnplResponse The BNP response
* @property TransferFundsAccountDetails $transfersFundsAccount Transfer details after funds movement
*/
class Transaction
{
Expand Down Expand Up @@ -549,6 +549,13 @@ public function confirm($amount = null)
->withAmount($amount);
}

public function split($amount = null)
{
return (new ManagementBuilder(TransactionType::SPLIT_FUNDS))
->withPaymentMethod($this->transactionReference)
->withAmount($amount);
}

public function __get($name)
{
switch ($name) {
Expand Down Expand Up @@ -597,6 +604,11 @@ public function __get($name)
return $this->transactionReference->bnplResponse;
}
return null;
case 'transfersFundsAccount':
if ($this->transactionReference !== null) {
return $this->transactionReference->transfersFundsAccount;
}
return null;
default:
break;
}
Expand All @@ -619,7 +631,8 @@ public function __isset($name)
'checkRefundId',
'checkSaleId',
'alternativePaymentResponse',
'bnplResponse'
'bnplResponse',
'transfersFundsAccount'
]) || isset($this->{$name});
}

Expand Down Expand Up @@ -680,6 +693,12 @@ public function __set($name, $value)
}
$this->transactionReference->bnplResponse = $value;
return;
case 'transfersFundsAccount':
if (!$this->transactionReference instanceof TransactionReference) {
$this->transactionReference = new TransactionReference();
}
$this->transactionReference->transfersFundsAccount = $value;
return;
default:
break;
}
Expand Down
20 changes: 20 additions & 0 deletions src/Entities/TransferFundsAccountCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace GlobalPayments\Api\Entities;

class TransferFundsAccountCollection extends \ArrayObject
{
/**
* @param TransferFundsAccountDetails $transfer
* @param string $id
*/
public function add(TransferFundsAccountDetails $transfer, string $id)
{
$this->offsetSet($id, $transfer);
}

public function get(string $id) : TransferFundsAccountDetails
{
return $this->offsetGet($id);
}
}
44 changes: 44 additions & 0 deletions src/Entities/TransferFundsAccountDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace GlobalPayments\Api\Entities;

use GlobalPayments\Api\Entities\Enums\TransactionStatus;

class TransferFundsAccountDetails
{
/**
* A unique identifier generated by Global Payments to identify a transfer
* @var string
*/
public $id;
/**
* Indicates where a Transfer is in its lifecycle.
*
* @var TransactionStatus
*/
public $status;

/**
* Global Payments time indicating when the object was created in ISO-8601 format.
* @var string
*/
public $timeCreated;

/**
* This is the amount being transferred.
* @var string;
*/
public $amount;

/**
* Split reference number
* @var string
*/
public $reference;

/**
* The description of the split.
* @var string
*/
public $description;
}
Loading

0 comments on commit 73afe68

Please sign in to comment.