From 26c79efa131d3eb09653de21ada1ea0a14f94889 Mon Sep 17 00:00:00 2001 From: uzlonewolf Date: Thu, 29 Jul 2021 04:50:23 -0700 Subject: [PATCH] Allow running Credit transactions by referencing the Gateway Txn ID of a previous transaction --- src/Builders/AuthorizationBuilder.php | 6 +++++- src/Gateways/PorticoConnector.php | 4 ++++ src/PaymentMethods/Credit.php | 4 ++-- src/PaymentMethods/CreditCardData.php | 3 ++- src/PaymentMethods/CreditCardReference.php | 16 ++++++++++++++++ src/PaymentMethods/CreditTrackData.php | 3 ++- src/PaymentMethods/Interfaces/IReferencable.php | 7 +++++++ 7 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/PaymentMethods/CreditCardReference.php create mode 100644 src/PaymentMethods/Interfaces/IReferencable.php diff --git a/src/Builders/AuthorizationBuilder.php b/src/Builders/AuthorizationBuilder.php index ef141f3f..fb4c650b 100644 --- a/src/Builders/AuthorizationBuilder.php +++ b/src/Builders/AuthorizationBuilder.php @@ -1057,7 +1057,11 @@ public function withRequestMultiUseToken($requestMultiUseToken) */ public function withTransactionId($transactionId) { - $this->paymentMethod = new TransactionReference($transactionId); + if ($this->paymentMethod === null) + $this->paymentMethod = new TransactionReference(); + + $this->paymentMethod->transactionId = $transactionId; + return $this; } diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index 178a334b..03a99569 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -30,6 +30,7 @@ use GlobalPayments\Api\PaymentMethods\Interfaces\IEncryptable; use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; use GlobalPayments\Api\PaymentMethods\Interfaces\IPinProtected; +use GlobalPayments\Api\PaymentMethods\Interfaces\IReferencable; use GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable; use GlobalPayments\Api\PaymentMethods\Interfaces\ITrackData; use GlobalPayments\Api\PaymentMethods\RecurringPaymentMethod; @@ -377,6 +378,9 @@ public function processAuthorization(AuthorizationBuilder $builder) $block1->appendChild($xml->createElement('GatewayTxnId', $builder->paymentMethod->transactionId)); $block1->appendChild($xml->createElement('ClientTxnId', $builder->paymentMethod->clientTransactionId)); } + else if ($builder->paymentMethod instanceof IReferencable && !empty($builder->paymentMethod->transactionId)) { + $block1->appendChild($xml->createElement('GatewayTxnId', $builder->paymentMethod->transactionId)); + } if ($builder->paymentMethod instanceof RecurringPaymentMethod) { $method = $builder->paymentMethod; diff --git a/src/PaymentMethods/Credit.php b/src/PaymentMethods/Credit.php index 4d808d54..bbf87d34 100644 --- a/src/PaymentMethods/Credit.php +++ b/src/PaymentMethods/Credit.php @@ -15,18 +15,18 @@ use GlobalPayments\Api\PaymentMethods\Interfaces\IEncryptable; use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; use GlobalPayments\Api\PaymentMethods\Interfaces\IPrePayable; +use GlobalPayments\Api\PaymentMethods\Interfaces\IReferencable; use GlobalPayments\Api\PaymentMethods\Interfaces\IRefundable; use GlobalPayments\Api\PaymentMethods\Interfaces\IReversable; use GlobalPayments\Api\PaymentMethods\Interfaces\ISecure3d; -use GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable; use GlobalPayments\Api\PaymentMethods\Interfaces\IVerifyable; abstract class Credit implements IPaymentMethod, IEncryptable, - ITokenizable, IChargable, IAuthable, + IReferencable, IRefundable, IReversable, IVerifyable, diff --git a/src/PaymentMethods/CreditCardData.php b/src/PaymentMethods/CreditCardData.php index ae50467c..07a920c4 100644 --- a/src/PaymentMethods/CreditCardData.php +++ b/src/PaymentMethods/CreditCardData.php @@ -7,12 +7,13 @@ use GlobalPayments\Api\Entities\Enums\CvnPresenceIndicator; use GlobalPayments\Api\Entities\Enums\TransactionType; use GlobalPayments\Api\PaymentMethods\Interfaces\ICardData; +use GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable; use GlobalPayments\Api\Entities\Enums\DccProcessor; use GlobalPayments\Api\Entities\Enums\DccRateType; use GlobalPayments\Api\Entities\DccRateData; use GlobalPayments\Api\Entities\ThreeDSecure; -class CreditCardData extends Credit implements ICardData +class CreditCardData extends Credit implements ITokenizable, ICardData { /** * Card number diff --git a/src/PaymentMethods/CreditCardReference.php b/src/PaymentMethods/CreditCardReference.php new file mode 100644 index 00000000..2f17ea8e --- /dev/null +++ b/src/PaymentMethods/CreditCardReference.php @@ -0,0 +1,16 @@ +