diff --git a/CHANGELOG.md b/CHANGELOG.md index a16260b2..87aefb6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ ## Latest Version #### Enhancements: +- GP-API: Create open banking transactions +- GPI Transactions: Reporting tests refacto + +## v6.1.2 (02/13/2023) +#### Enhancements: - GP-API: BNPL unit tests update ## v6.1.1 (02/09/2023) @@ -16,6 +21,7 @@ #### Enhancements: - GP-API: add risk assessment feature - Refacto the Secure3DBuilder +- GP-API: update CTP transaction request ## v6.0.6 (01/26/2023) #### Enhancements: diff --git a/metadata.xml b/metadata.xml index 27a9bccb..90c0233f 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 6.1.2 + 6.1.3 \ No newline at end of file diff --git a/src/Builders/AuthorizationBuilder.php b/src/Builders/AuthorizationBuilder.php index eb1dfacb..dcc75c85 100644 --- a/src/Builders/AuthorizationBuilder.php +++ b/src/Builders/AuthorizationBuilder.php @@ -12,19 +12,18 @@ HostedPaymentData, PhoneNumber, StoredCredential, - Transaction -}; + OrderDetails, + DccRateData, + DecisionManager, + Transaction}; use GlobalPayments\Api\Entities\Enums\{ AddressType, AliasAction, BNPLShippingMethod, - DccRateData, - DecisionManager, EmvFallbackCondition, EmvLastChipRead, InquiryType, FraudFilterMode, - OrderDetails, PaymentMethodUsageMode, PhoneNumberType, RemittanceReferenceType, @@ -33,12 +32,7 @@ TransactionModifier, TransactionType }; -use GlobalPayments\Api\PaymentMethods\{ - BNPL, - EBTCardData, - GiftCard, - TransactionReference -}; +use GlobalPayments\Api\PaymentMethods\{BankPayment, BNPL, EBTCardData, GiftCard, TransactionReference}; use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; use GlobalPayments\Api\Entities\Exceptions\ArgumentException; @@ -545,6 +539,13 @@ public function execute($configName = 'default') parent::execute($configName); $client = ServicesContainer::instance()->getClient($configName); + if ($client->supportsOpenBanking() && $this->paymentMethod instanceof BankPayment) { + $obClient = ServicesContainer::instance()->getOpenBanking($configName); + if (get_class($obClient) != get_class($client)) { + return $obClient->processOpenBanking($this); + } + } + return $client->processAuthorization($this); } diff --git a/src/Builders/BankPaymentBuilder.php b/src/Builders/BankPaymentBuilder.php deleted file mode 100644 index 3dafea2b..00000000 --- a/src/Builders/BankPaymentBuilder.php +++ /dev/null @@ -1,136 +0,0 @@ -transactionType = $transactionType; - if (!is_null($paymentMethod)) { - $this->withPaymentMethod($paymentMethod); - } - } - - public function setupValidations() - { - $this->validations->of(TransactionType::SALE) - ->check('paymentMethod')->isNotNull() - ->check('amount')->isNotNull() - ->check('currency')->isNotNull(); - } - - public function execute($configName = 'default') - { - parent::execute(); - - $client = ServicesContainer::instance()->getOpenBanking($configName); - return $client->processOpenBanking($this); - } - - public function serialize($configName = 'default') - { - $this->transactionModifier = TransactionModifier::HOSTEDREQUEST; - parent::execute(); - - $client = ServicesContainer::instance()->getOpenBanking($configName); - - if ($client->supportsHostedPayments()) { - return $client->serializeRequest($this); - } - - throw new UnsupportedTransactionException("Your current gateway does not support hosted payments."); - } - - public function withCurrency($currency) - { - $this->currency = $currency; - return $this; - } - - public function withAmount($amount) - { - $this->amount = $amount; - return $this; - } - - public function withDescription($description) - { - $this->description = $description; - return $this; - } - - public function withPaymentMethod($paymentMethod) - { - $this->paymentMethod = $paymentMethod; - return $this; - } - - public function withOrderId($orderId) - { - $this->orderId = $orderId; - return $this; - } - - public function withModifier($transactionModifier) - { - $this->transactionModifier = $transactionModifier; - return $this; - } - - /** - * @param string $timestamp - * - * @return $this - */ - public function withTimeStamp($timestamp) - { - $this->timestamp = $timestamp; - return $this; - } - - public function withRemittanceReference($remittanceReferenceType, $remittanceReferenceValue) - { - $this->remittanceReferenceType = $remittanceReferenceType; - $this->remittanceReferenceValue = $remittanceReferenceValue; - - return $this; - } -} \ No newline at end of file diff --git a/src/Builders/RequestBuilder/GpApi/GpApiAuthorizationRequestBuilder.php b/src/Builders/RequestBuilder/GpApi/GpApiAuthorizationRequestBuilder.php index 0facf8d3..160f7462 100644 --- a/src/Builders/RequestBuilder/GpApi/GpApiAuthorizationRequestBuilder.php +++ b/src/Builders/RequestBuilder/GpApi/GpApiAuthorizationRequestBuilder.php @@ -6,6 +6,7 @@ use GlobalPayments\Api\Builders\BaseBuilder; use GlobalPayments\Api\Entities\CustomerDocument; use GlobalPayments\Api\Entities\EncryptionData; +use GlobalPayments\Api\Entities\Enums\BankPaymentType; use GlobalPayments\Api\Entities\Enums\CardType; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\DigitalWalletTokenFormat; @@ -16,6 +17,7 @@ use GlobalPayments\Api\Entities\Enums\CaptureMode; use GlobalPayments\Api\Entities\Enums\PayLinkStatus; use GlobalPayments\Api\Entities\Enums\PaymentEntryMode; +use GlobalPayments\Api\Entities\Enums\PaymentProvider; use GlobalPayments\Api\Entities\Enums\PaymentType; use GlobalPayments\Api\Entities\Enums\PhoneNumberType; use GlobalPayments\Api\Entities\Enums\TransactionModifier; @@ -28,7 +30,9 @@ use GlobalPayments\Api\Entities\PayLinkData; use GlobalPayments\Api\Entities\PhoneNumber; use GlobalPayments\Api\Entities\Product; +use GlobalPayments\Api\Gateways\OpenBankingProvider; use GlobalPayments\Api\Mapping\EnumMapping; +use GlobalPayments\Api\PaymentMethods\BankPayment; use GlobalPayments\Api\PaymentMethods\BNPL; use GlobalPayments\Api\PaymentMethods\Credit; use GlobalPayments\Api\PaymentMethods\CreditCardData; @@ -223,12 +227,12 @@ private function createFromAuthorizationBuilder($builder, GpApiConfig $config) } if ($builder->paymentMethod instanceof AlternativePaymentMethod || $builder->paymentMethod instanceof BNPL) { $this->setOrderInformation($builder, $requestBody); - - $requestBody['notifications'] = [ - 'return_url' => $builder->paymentMethod->returnUrl, - 'status_url' => $builder->paymentMethod->statusUpdateUrl, - 'cancel_url' => $builder->paymentMethod->cancelUrl - ]; + } + if ($builder->paymentMethod instanceof AlternativePaymentMethod || + $builder->paymentMethod instanceof BNPL || + $builder->paymentMethod instanceof BankPayment + ) { + $this->setNotificationUrls($requestBody); } if (!empty($builder->storedCredential)) { $initiator = EnumMapping::mapStoredCredentialInitiator(GatewayProvider::GP_API, $builder->storedCredential->initiator); @@ -373,7 +377,7 @@ private function getPhoneNumber($builder, $type) */ private function createPaymentMethodParam($builder, $config) { - /** @var CreditCardData|CreditTrackData|DebitTrackData|ECheck|AlternativePaymentMethod|BNPL $paymentMethodContainer */ + /** @var CreditCardData|CreditTrackData|DebitTrackData|ECheck|AlternativePaymentMethod|BNPL|BankPayment $paymentMethodContainer */ $paymentMethodContainer = $builder->paymentMethod; $paymentMethod = new PaymentMethod(); $paymentMethod->entry_mode = $this->getEntryMode($builder, $config->channel); @@ -452,7 +456,27 @@ private function createPaymentMethodParam($builder, $config) 'address_override_mode' => !empty($paymentMethodContainer->addressOverrideMode) ? $paymentMethodContainer->addressOverrideMode : null ]; - + return $paymentMethod; + case BankPayment::class: + $paymentMethod->apm = [ + 'provider' => PaymentProvider::OPEN_BANKING, + 'countries' => $paymentMethodContainer->countries ?? [], + ]; + $bankPaymentType = !empty($paymentMethodContainer->bankPaymentType) ? + $paymentMethodContainer->bankPaymentType : OpenBankingProvider::getBankPaymentType($builder->currency); + $paymentMethod->bank_transfer = [ + 'account_number' => $bankPaymentType == BankPaymentType::FASTERPAYMENTS ? + $paymentMethodContainer->accountNumber : '', + 'iban' => $bankPaymentType == BankPaymentType::SEPA ? $paymentMethodContainer->iban : '', + 'bank' => [ + 'code' => $paymentMethodContainer->sortCode, + 'name' => $paymentMethodContainer->accountName + ], + 'remittance_reference' => [ + 'type' => $builder->remittanceReferenceType, + 'value' => $builder->remittanceReferenceValue + ] + ]; return $paymentMethod; case BNPL::class: if (!empty($builder->customerData->firstName) && !empty($builder->customerData->lastName)) { @@ -628,6 +652,15 @@ private function getCaptureMode(AuthorizationBuilder $builder) return CaptureMode::AUTO; } + private function setNotificationUrls(&$requestBody) + { + $requestBody['notifications'] = [ + 'return_url' => $this->builder->paymentMethod->returnUrl ?? null, + 'status_url' => $this->builder->paymentMethod->statusUpdateUrl ?? null, + 'cancel_url' => $this->builder->paymentMethod->cancelUrl ?? null + ]; + } + private function setOrderInformation($builder, &$requestBody) { $order['description'] = !empty($builder->orderDetails) ? diff --git a/src/Builders/RequestBuilder/GpApi/GpApiManagementRequestBuilder.php b/src/Builders/RequestBuilder/GpApi/GpApiManagementRequestBuilder.php index 53616f6c..4dbd7444 100644 --- a/src/Builders/RequestBuilder/GpApi/GpApiManagementRequestBuilder.php +++ b/src/Builders/RequestBuilder/GpApi/GpApiManagementRequestBuilder.php @@ -6,8 +6,10 @@ use GlobalPayments\Api\Builders\ManagementBuilder; use GlobalPayments\Api\Entities\DccRateData; use GlobalPayments\Api\Entities\Enums\GatewayProvider; +use GlobalPayments\Api\Entities\Enums\PaymentMethodName; use GlobalPayments\Api\Entities\Enums\PaymentMethodType; use GlobalPayments\Api\Entities\Enums\TransactionType; +use GlobalPayments\Api\Entities\Exceptions\BuilderException; use GlobalPayments\Api\Entities\GpApi\DTO\Card; use GlobalPayments\Api\Entities\GpApi\GpApiRequest; use GlobalPayments\Api\Entities\IRequestBuilder; @@ -22,6 +24,10 @@ class GpApiManagementRequestBuilder implements IRequestBuilder { + private static $allowedActions =[ + PaymentMethodType::BANK_PAYMENT => [] + ]; + /** * @param $builder * @return bool @@ -44,6 +50,26 @@ public static function canProcess($builder) public function buildRequest(BaseBuilder $builder, $config) { $payload = null; + + if (!empty($builder->paymentMethod->paymentMethodType)) { + switch ($builder->paymentMethod->paymentMethodType) { + case PaymentMethodType::BANK_PAYMENT: + if ( + !isset(self::$allowedActions[PaymentMethodType::BANK_PAYMENT]) || + !in_array($builder->transactionType, self::$allowedActions[PaymentMethodType::BANK_PAYMENT]) + ) { + throw new BuilderException( + sprintf( + "The %s is not supported for %s", + $this->getTransactionTypeName($builder->transactionType), PaymentMethodName::BANK_PAYMENT + ) + ); + } + default: + break; + } + } + /** * @var ManagementBuilder $builder */ @@ -244,4 +270,11 @@ private function getDccRate($dccRateData) 'id' => $dccRateData->dccId ]; } + + private function getTransactionTypeName($transactionType) + { + $reflector = new \ReflectionClass(TransactionType::class); + + return array_search($transactionType,$reflector->getConstants()); + } } \ No newline at end of file diff --git a/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php b/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php index 9ab1b88a..ca093bd7 100644 --- a/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php +++ b/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.php @@ -7,8 +7,6 @@ use GlobalPayments\Api\Builders\TransactionReportBuilder; use GlobalPayments\Api\Entities\Enums\GatewayProvider; use GlobalPayments\Api\Entities\Enums\ReportType; -use GlobalPayments\Api\Entities\Enums\TransactionModifier; -use GlobalPayments\Api\Entities\Enums\TransactionType; use GlobalPayments\Api\Entities\GpApi\GpApiRequest; use GlobalPayments\Api\Entities\IRequestBuilder; use GlobalPayments\Api\Mapping\EnumMapping; @@ -88,7 +86,8 @@ public function buildRequest(BaseBuilder $builder, $config) 'risk_assessment_result' => EnumMapping::mapFraudFilterResult( GatewayProvider::GP_API, $builder->searchBuilder->riskAssessmentResult), - 'risk_assessment_reason_code' => $builder->searchBuilder->riskAssessmentReasonCode + 'risk_assessment_reason_code' => $builder->searchBuilder->riskAssessmentReasonCode, + 'provider' => $builder->searchBuilder->paymentProvider, ]; $this->addBasicParams($queryParams, $builder); diff --git a/src/Builders/RequestBuilder/RequestBuilderFactory.php b/src/Builders/RequestBuilder/RequestBuilderFactory.php index 08a057d6..f56b0baf 100644 --- a/src/Builders/RequestBuilder/RequestBuilderFactory.php +++ b/src/Builders/RequestBuilder/RequestBuilderFactory.php @@ -26,7 +26,7 @@ class RequestBuilderFactory { - public static $processes = [ + private static $processes = [ GatewayProvider::GP_ECOM => [ GpEcomRecurringRequestBuilder::class, GpEcomAuthorizationRequestBuilder::class, diff --git a/src/Builders/RequestBuilder/TransactionApi/TransactionApiReportRequestBuilder.php b/src/Builders/RequestBuilder/TransactionApi/TransactionApiReportRequestBuilder.php index 00742e01..96481a96 100644 --- a/src/Builders/RequestBuilder/TransactionApi/TransactionApiReportRequestBuilder.php +++ b/src/Builders/RequestBuilder/TransactionApi/TransactionApiReportRequestBuilder.php @@ -3,7 +3,7 @@ namespace GlobalPayments\Api\Builders\RequestBuilder\TransactionApi; use GlobalPayments\Api\Builders\{BaseBuilder, TransactionReportBuilder}; -use GlobalPayments\Api\Entities\Enums\{PaymentMethodType, ReportType}; +use GlobalPayments\Api\Entities\Enums\{PaymentMethodType, PaymentType, ReportType}; use GlobalPayments\Api\Entities\IRequestBuilder; use GlobalPayments\Api\ServiceConfigs\Gateways\TransactionApiConfig; use GlobalPayments\Api\Entities\TransactionApi\TransactionApiRequest; @@ -22,53 +22,56 @@ public static function canProcess($builder) */ public function buildRequest(BaseBuilder $builder, $config) { - $queryParams = $payload = null; + $queryParams = $payload = $endpoint = null; /** * @var TransactionReportBuilder $builder */ switch ($builder->reportType) { - case ReportType::TRANSACTION_DETAIL || ReportType::FIND_TRANSACTIONS: - if (is_object($builder->transactionId)) { - $transData = $builder->transactionId; - if ($transData->paymentMethodType == PaymentMethodType::CREDIT) { - if (isset($transData->transactionReference->transactionId)) { - $endpoint = TransactionApiRequest::CREDITREFUND . '/' . $transData->transactionReference->transactionId; + case ReportType::TRANSACTION_DETAIL: + $verb = 'GET'; + $endpoint = TransactionApiRequest::CREDITSALE . '/' . $builder->transactionId; + break; + case ReportType::FIND_TRANSACTIONS: + $verb = 'GET'; + + switch ($builder->searchBuilder->paymentMethodType) + { + case PaymentMethodType::CREDIT: + if (isset($builder->transactionId)) { + $endpoint = TransactionApiRequest::CREDITREFUND . '/' . $builder->transactionId; } - if (isset($transData->transactionReference->clientTransactionId)) { - $endpoint = TransactionApiRequest::CREDITREFUNDREF . '/' . $transData->transactionReference->clientTransactionId; + if (isset($builder->searchBuilder->clientTransactionId)) { + $endpoint = TransactionApiRequest::CREDITREFUNDREF . '/' . $builder->searchBuilder->clientTransactionId; } - } - if ($transData->paymentMethodType == PaymentMethodType::ACH) { - if ($transData->originalTransactionType == "REFUND") { - if (isset($transData->transactionReference->transactionId)) { - $endpoint = TransactionApiRequest::CHECKREFUND . '/' . $transData->transactionReference->transactionId; + break; + case PaymentMethodType::ACH: + if ($builder->searchBuilder->paymentType == PaymentType::REFUND) { + if (isset($builder->transactionId)) { + $endpoint = TransactionApiRequest::CHECKREFUND . '/' . $builder->transactionId; } - if (isset($transData->transactionReference->clientTransactionId)) { - $endpoint = TransactionApiRequest::CHECKREFUNDREF . '/' . $transData->transactionReference->clientTransactionId; + if (isset($builder->searchBuilder->clientTransactionId)) { + $endpoint = TransactionApiRequest::CHECKREFUNDREF . '/' . $builder->searchBuilder->clientTransactionId; } } else { - if (isset($transData->transactionReference->transactionId)) { - $endpoint = TransactionApiRequest::CHECKSALES . '/' . $transData->transactionReference->transactionId; + if (isset($builder->transactionId)) { + $endpoint = TransactionApiRequest::CHECKSALES . '/' . $builder->transactionId; } - if (isset($transData->transactionReference->clientTransactionId)) { - $endpoint = TransactionApiRequest::CHECKSALESREF . '/' . $transData->transactionReference->clientTransactionId; + if (isset($builder->searchBuilder->clientTransactionId)) { + $endpoint = TransactionApiRequest::CHECKSALESREF . '/' . $builder->searchBuilder->clientTransactionId; } } - } - } else { - if (isset($builder->transactionId)) { - $endpoint = TransactionApiRequest::CREDITSALE . '/' . $builder->transactionId; - } - if (isset($builder->searchBuilder->clientTransactionId)) { - $endpoint = TransactionApiRequest::CREDITSALEREF . '/' . $builder->searchBuilder->clientTransactionId; - } + break; + default: + if (isset($builder->searchBuilder->clientTransactionId)) { + $endpoint = TransactionApiRequest::CREDITSALEREF . '/' . $builder->searchBuilder->clientTransactionId; + } + break; } - - $verb = 'GET'; break; default: return null; } + return new TransactionApiRequest($endpoint, $verb, $payload, $queryParams); } } diff --git a/src/Entities/BankPaymentResponse.php b/src/Entities/BankPaymentResponse.php index ec3d350f..c89b74e1 100644 --- a/src/Entities/BankPaymentResponse.php +++ b/src/Entities/BankPaymentResponse.php @@ -43,4 +43,10 @@ class BankPaymentResponse /** @var string */ public $iban; + + /** @var string */ + public $remittanceReferenceValue; + + /** @var string */ + public $remittanceReferenceType; } \ No newline at end of file diff --git a/src/Entities/Enums/PaymentProvider.php b/src/Entities/Enums/PaymentProvider.php new file mode 100644 index 00000000..f32283de --- /dev/null +++ b/src/Entities/Enums/PaymentProvider.php @@ -0,0 +1,10 @@ + + * @var IPaymentMethod */ - public $paymentTypes; + public $paymentMethod; + + /** @var PaymentMethodUsageMode */ + public $paymentMethodUsageMode; + + /** @var string */ + public $paymentMethodKey; + + /** + * @var PaymentMethodType + */ + public $paymentMethodType; /** * @var string @@ -471,16 +488,6 @@ class SearchCriteriaBuilder */ public $httpResponseCode; - /** - * @var PaymentMethodName - */ - public $paymentMethodName; - - /** - * @var IPaymentMethod - */ - public $paymentMethod; - /** * This is the PayLink id * @@ -488,9 +495,6 @@ class SearchCriteriaBuilder */ public $payLinkId; - /** @var PaymentMethodUsageMode */ - public $paymentMethodUsageMode; - /** @var string */ public $description; diff --git a/src/Gateways/GeniusConnector.php b/src/Gateways/GeniusConnector.php index 2ebaf055..ad954eb1 100644 --- a/src/Gateways/GeniusConnector.php +++ b/src/Gateways/GeniusConnector.php @@ -4,6 +4,7 @@ use DOMDocument; use DOMElement; +use GlobalPayments\Api\Builders\AuthorizationBuilder; use GlobalPayments\Api\Builders\TransactionBuilder; use GlobalPayments\Api\Entities\{BatchSummary, Transaction}; use GlobalPayments\Api\Entities\Enums\{PaymentMethodType, TransactionModifier, TransactionType}; @@ -30,7 +31,12 @@ class GeniusConnector extends XmlGateway implements IPaymentGateway const CREDIT_SERVICE_END_POINT = 'RetailTransaction/v45/Credit.asmx'; const GIFT_SERVICE_END_POINT = 'ExtensionServices/v46/Giftcard.asmx'; - public function processAuthorization($builder) + public function supportsOpenBanking() : bool + { + return false; + } + + public function processAuthorization(AuthorizationBuilder $builder) { $xml = new DOMDocument(); $paymentMethod = $builder->paymentMethod; diff --git a/src/Gateways/GpApiConnector.php b/src/Gateways/GpApiConnector.php index 7433927c..2b4b55b8 100644 --- a/src/Gateways/GpApiConnector.php +++ b/src/Gateways/GpApiConnector.php @@ -43,6 +43,11 @@ class GpApiConnector extends RestGateway implements IPaymentGateway, ISecure3dPr private $gpApiConfig; private $accessToken; + public function supportsOpenBanking() : bool + { + return true; + } + public function __construct(GpApiConfig $gpApiConfig) { parent::__construct(); diff --git a/src/Gateways/GpEcomConnector.php b/src/Gateways/GpEcomConnector.php index 8df78c16..1718d8c5 100644 --- a/src/Gateways/GpEcomConnector.php +++ b/src/Gateways/GpEcomConnector.php @@ -50,6 +50,11 @@ public function __construct(GpEcomConfig $config) $this->config = $config; } + public function supportsOpenBanking() : bool + { + return true; + } + /** @return Secure3dVersion */ public function getVersion() { diff --git a/src/Gateways/IOpenBankingProvider.php b/src/Gateways/IOpenBankingProvider.php index b5ef26b9..1797bf89 100644 --- a/src/Gateways/IOpenBankingProvider.php +++ b/src/Gateways/IOpenBankingProvider.php @@ -2,9 +2,9 @@ namespace GlobalPayments\Api\Gateways; -use GlobalPayments\Api\Builders\BankPaymentBuilder; +use GlobalPayments\Api\Builders\AuthorizationBuilder; interface IOpenBankingProvider { - public function processOpenBanking(BankPaymentBuilder $builder); + public function processOpenBanking(AuthorizationBuilder $builder); } \ No newline at end of file diff --git a/src/Gateways/IPaymentGateway.php b/src/Gateways/IPaymentGateway.php index e3a6a867..957632ef 100644 --- a/src/Gateways/IPaymentGateway.php +++ b/src/Gateways/IPaymentGateway.php @@ -29,4 +29,5 @@ public function manageTransaction(ManagementBuilder $builder); public function processReport(ReportBuilder $builder); public function serializeRequest(AuthorizationBuilder $builder); + public function supportsOpenBanking() : bool; } diff --git a/src/Gateways/OpenBankingProvider.php b/src/Gateways/OpenBankingProvider.php index e05d5988..361d2c49 100644 --- a/src/Gateways/OpenBankingProvider.php +++ b/src/Gateways/OpenBankingProvider.php @@ -2,7 +2,7 @@ namespace GlobalPayments\Api\Gateways; -use GlobalPayments\Api\Builders\BankPaymentBuilder; +use GlobalPayments\Api\Builders\AuthorizationBuilder; use GlobalPayments\Api\Builders\TransactionReportBuilder; use GlobalPayments\Api\Entities\Enums\BankPaymentType; use GlobalPayments\Api\Entities\Enums\ReportType; @@ -44,7 +44,7 @@ public function __construct() $this->headers['Accept'] = 'application/json'; } - public function processOpenBanking(BankPaymentBuilder $builder) + public function processOpenBanking(AuthorizationBuilder $builder) { $httpVerb = $endpoint = $payload = null; $timestamp = (new \DateTime())->format("YmdHis"); diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index 44938ad4..a85bbe9a 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -141,6 +141,11 @@ class PorticoConnector extends XmlGateway implements IPaymentGateway */ public $sdkNameVersion; + public function supportsOpenBanking() : bool + { + return false; + } + /** * {@inheritdoc} * diff --git a/src/Gateways/TransITConnector.php b/src/Gateways/TransITConnector.php index 4aa86ab6..9024edb4 100644 --- a/src/Gateways/TransITConnector.php +++ b/src/Gateways/TransITConnector.php @@ -41,6 +41,11 @@ class TransITConnector extends XmlGateway implements IPaymentGateway public $supportsHostedPayments = false; + public function supportsOpenBanking() : bool + { + return false; + } + public function processAuthorization(AuthorizationBuilder $builder) { if (empty($this->transactionKey) && empty($this->manifest)) { diff --git a/src/Gateways/TransactionApiConnector.php b/src/Gateways/TransactionApiConnector.php index 4c0f1b77..29c16ed6 100644 --- a/src/Gateways/TransactionApiConnector.php +++ b/src/Gateways/TransactionApiConnector.php @@ -33,6 +33,11 @@ public function __construct(TransactionApiConfig $transactionApiConfig) $this->transactionApiConfig = $transactionApiConfig; } + public function supportsOpenBanking() : bool + { + return false; + } + /** * Serializes and executes authorization transactions * diff --git a/src/Mapping/GpApiMapping.php b/src/Mapping/GpApiMapping.php index f04c56f9..610b1f3a 100644 --- a/src/Mapping/GpApiMapping.php +++ b/src/Mapping/GpApiMapping.php @@ -4,6 +4,7 @@ use GlobalPayments\Api\Entities\Address; use GlobalPayments\Api\Entities\AlternativePaymentResponse; +use GlobalPayments\Api\Entities\BankPaymentResponse; use GlobalPayments\Api\Entities\BatchSummary; use GlobalPayments\Api\Entities\BNPLResponse; use GlobalPayments\Api\Entities\Card; @@ -15,6 +16,7 @@ use GlobalPayments\Api\Entities\Enums\FraudFilterResult; use GlobalPayments\Api\Entities\Enums\PaymentMethodName; use GlobalPayments\Api\Entities\Enums\PaymentMethodType; +use GlobalPayments\Api\Entities\Enums\PaymentProvider; use GlobalPayments\Api\Entities\Enums\PhoneNumberType; use GlobalPayments\Api\Entities\Enums\ReportType; use GlobalPayments\Api\Entities\Enums\Secure3dStatus; @@ -106,6 +108,7 @@ public static function mapResponse($response) $transaction->fingerprint = !empty($response->fingerprint) ? $response->fingerprint : null; $transaction->fingerprintIndicator = !empty($response->fingerprint_presence_indicator) ? $response->fingerprint_presence_indicator : null; + if (isset($response->payment_method->bnpl)) { return self::mapBNPLResponse($response, $transaction); } @@ -114,7 +117,7 @@ public static function mapResponse($response) $response->id : null; $transaction->tokenUsageMode = !empty($response->usage_mode) ? $response->usage_mode : null; if (!empty($response->payment_method)) { - $transaction->authorizationCode = $response->payment_method->result; + $transaction->authorizationCode = $response->payment_method->result ?? null; if (!empty($response->payment_method->id)) { $transaction->token = $response->payment_method->id; } @@ -139,14 +142,25 @@ public static function mapResponse($response) self::mapCardIssuerResponse($transaction, $card->provider); } } - if (!empty($response->payment_method->bank_transfer)) { + if (!empty($response->payment_method->apm) && + $response->payment_method->apm->provider == strtolower(PaymentProvider::OPEN_BANKING) + ) { + $transaction->paymentMethodType = PaymentMethodType::BANK_PAYMENT; + $obResponse = new BankPaymentResponse(); + $obResponse->redirectUrl = $response->payment_method->redirect_url ?? null; + $obResponse->paymentStatus = $response->payment_method->message ?? null; + $obResponse->accountNumber = $response->payment_method->bank_transfer->account_number ?? null; + $obResponse->sortCode = $response->payment_method->bank_transfer->bank->code ?? null; + $obResponse->accountName = $response->payment_method->bank_transfer->bank->name ?? null; + $obResponse->iban = $response->payment_method->bank_transfer->iban ?? null; + $transaction->bankPaymentResponse = $obResponse; + } elseif (!empty($response->payment_method->bank_transfer)) { $bankTransfer = $response->payment_method->bank_transfer; $transaction->accountNumberLast4 = !empty($bankTransfer->masked_account_number_last4) ? $bankTransfer->masked_account_number_last4 : null; $transaction->accountType = !empty($bankTransfer->account_type) ? $bankTransfer->account_type : null; $transaction->paymentMethodType = PaymentMethodType::ACH; - } - if (!empty($response->payment_method->apm)) { + } elseif (!empty($response->payment_method->apm)) { $transaction->paymentMethodType = PaymentMethodType::APM; } } @@ -353,33 +367,60 @@ public static function mapTransactionSummary($response) $summary->gatewayResponseMessage = isset($paymentMethod->message) ? $paymentMethod->message : null; $summary->entryMode = isset($paymentMethod->entry_mode) ? $paymentMethod->entry_mode : null; $summary->cardHolderName = isset($paymentMethod->name) ? $paymentMethod->name : ''; - if (isset($response->payment_method->card)) { - $card = $response->payment_method->card; + + /** map card details */ + if (isset($paymentMethod->card)) { + $card = $paymentMethod->card; $summary->aquirerReferenceNumber = isset($card->arn) ? $card->arn : null; $summary->maskedCardNumber = isset($card->masked_number_first6last4) ? $card->masked_number_first6last4 : null; $summary->paymentType = PaymentMethodName::CARD; - } elseif (isset($response->payment_method->digital_wallet)) { + } + /** map digital wallet info */ + if (isset($paymentMethod->digital_wallet)) { $card = $response->payment_method->digital_wallet; $summary->maskedCardNumber = isset($card->masked_token_first6last4) ? $card->masked_token_first6last4 : null; $summary->paymentType = PaymentMethodName::DIGITAL_WALLET; - } elseif (isset($response->payment_method->bank_transfer)) { + } + /** map ACH response info */ + if ( + isset($response->payment_method->bank_transfer) && + !isset($response->payment_method->apm) + ) { + $summary->paymentType = PaymentMethodName::BANK_TRANSFER; $bankTransfer = $response->payment_method->bank_transfer; $summary->accountNumberLast4 = !empty($bankTransfer->masked_account_number_last4) ? $bankTransfer->masked_account_number_last4 : null; $summary->accountType = !empty($bankTransfer->account_type) ? $bankTransfer->account_type : null; - $summary->paymentType = PaymentMethodName::BANK_TRANSFER; - } elseif (isset($response->payment_method->apm)) { - $apm = $response->payment_method->apm; - $alternativePaymentResponse = new AlternativePaymentResponse(); - $alternativePaymentResponse->redirectUrl = !empty($response->payment_method->redirect_url) ? - $response->payment_method->redirect_url : null; - $alternativePaymentResponse->providerName = !empty($apm->provider) ? $apm->provider : null; - $alternativePaymentResponse->providerReference = !empty($apm->provider_reference) ? $apm->provider_reference : null; - $summary->alternativePaymentResponse = $alternativePaymentResponse; - $summary->paymentType = PaymentMethodName::APM; - } elseif (isset($response->payment_method->bnpl)) { + } + if (isset($response->payment_method->apm)) { + /** map Open Banking response info */ + if ($response->payment_method->apm->provider == strtolower(PaymentProvider::OPEN_BANKING)) { + $summary->paymentType = PaymentMethodName::BANK_PAYMENT; + $bankPaymentResponse = new BankPaymentResponse(); + $bankPaymentResponse->iban = $response->payment_method->bank_transfer->iban ?? null; + $bankPaymentResponse->accountNumber = $response->payment_method->bank_transfer->account_number ?? null; + $bankPaymentResponse->accountName = $response->payment_method->bank_transfer->bank->name ?? null; + $bankPaymentResponse->sortCode = $response->payment_method->bank_transfer->bank->code ?? null; + $bankPaymentResponse->remittanceReferenceValue = + $response->payment_method->bank_transfer->remittance_reference->value ?? null; + $bankPaymentResponse->remittanceReferenceType = + $response->payment_method->bank_transfer->remittance_reference->type ?? null; + $summary->bankPaymentResponse = $bankPaymentResponse; + } else { /** map APMs (Paypal) response info */ + $apm = $response->payment_method->apm; + $alternativePaymentResponse = new AlternativePaymentResponse(); + $alternativePaymentResponse->redirectUrl = !empty($response->payment_method->redirect_url) ? + $response->payment_method->redirect_url : null; + $alternativePaymentResponse->providerName = !empty($apm->provider) ? $apm->provider : null; + $alternativePaymentResponse->providerReference = !empty($apm->provider_reference) ? $apm->provider_reference : null; + $summary->alternativePaymentResponse = $alternativePaymentResponse; + $summary->paymentType = PaymentMethodName::APM; + } + } + /** map BNPL response info */ + if (isset($response->payment_method->bnpl)) { $bnpl = $response->payment_method->bnpl; $bnplResponse = new BNPLResponse(); $bnplResponse->providerName = $bnpl->provider ?? null; diff --git a/src/PaymentMethods/BankPayment.php b/src/PaymentMethods/BankPayment.php index 6b13873c..743fa6a6 100644 --- a/src/PaymentMethods/BankPayment.php +++ b/src/PaymentMethods/BankPayment.php @@ -3,14 +3,14 @@ namespace GlobalPayments\Api\PaymentMethods; use GlobalPayments\Api\Builders\AuthorizationBuilder; -use GlobalPayments\Api\Builders\BankPaymentBuilder; use GlobalPayments\Api\Entities\Enums\BankPaymentType; use GlobalPayments\Api\Entities\Enums\PaymentMethodType; use GlobalPayments\Api\Entities\Enums\TransactionModifier; use GlobalPayments\Api\Entities\Enums\TransactionType; +use GlobalPayments\Api\PaymentMethods\Interfaces\IChargable; use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; -class BankPayment implements IPaymentMethod +class BankPayment implements IPaymentMethod, IChargable { /** * Merchant/Individual Name. @@ -52,16 +52,19 @@ class BankPayment implements IPaymentMethod /** @var BankPaymentType */ public $bankPaymentType; + /** @var array */ + public $countries; + /** * This is a mandatory request used to initiate an Open Banking transaction, * - * @param string|float $amount Amount to authorize + * @param string|float|null $amount Amount to charge * - * @return BankPaymentBuilder + * @return AuthorizationBuilder */ - public function charge($amount) + public function charge($amount = null) { - return (new BankPaymentBuilder(TransactionType::SALE, $this)) + return (new AuthorizationBuilder(TransactionType::SALE, $this)) ->withModifier(TransactionModifier::BANK_PAYMENT) ->withAmount($amount); } diff --git a/src/ServiceConfigs/Gateways/GpApiConfig.php b/src/ServiceConfigs/Gateways/GpApiConfig.php index 566649da..ce37bc55 100644 --- a/src/ServiceConfigs/Gateways/GpApiConfig.php +++ b/src/ServiceConfigs/Gateways/GpApiConfig.php @@ -97,10 +97,10 @@ public function configureContainer(ConfiguredServices $services) $services->reportingService = $gateway; $services->fraudService = $gateway; + $services->setOpenBankingProvider($gateway); $services->setPayFacProvider($gateway); $services->setSecure3dProvider(Secure3dVersion::ONE, $gateway); $services->setSecure3dProvider(Secure3dVersion::TWO, $gateway); - } public function validate() diff --git a/src/ServiceConfigs/Gateways/GpEcomConfig.php b/src/ServiceConfigs/Gateways/GpEcomConfig.php index e97ba6c0..d53eba62 100644 --- a/src/ServiceConfigs/Gateways/GpEcomConfig.php +++ b/src/ServiceConfigs/Gateways/GpEcomConfig.php @@ -35,6 +35,9 @@ class GpEcomConfig extends GatewayConfig public $merchantNotificationUrl; public $secure3dVersion; + /** + * @deprecated Property not used and it will be removed + */ //Open banking service public $enableBankPayment = false; @@ -85,7 +88,7 @@ public function configureContainer(ConfiguredServices $services) $services->setSecure3dProvider(Secure3dVersion::TWO, $secure3d2); } - if ($this->enableBankPayment === true) { + if ($gateway->supportsOpenBanking()) { $openBanking = new OpenBankingProvider(); $openBanking->merchantId = $this->merchantId; $openBanking->accountId = $this->accountId; diff --git a/src/Services/ReportingService.php b/src/Services/ReportingService.php index 82e0bb7f..b1febd76 100644 --- a/src/Services/ReportingService.php +++ b/src/Services/ReportingService.php @@ -2,13 +2,10 @@ namespace GlobalPayments\Api\Services; -use GlobalPayments\Api\Builders\BankPaymentBuilder; -use GlobalPayments\Api\Builders\PayFacBuilder; use GlobalPayments\Api\Builders\TransactionReportBuilder; use GlobalPayments\Api\Builders\UserReportBuilder; use GlobalPayments\Api\Entities\Enums\ReportType; use GlobalPayments\Api\Entities\Enums\TransactionModifier; -use GlobalPayments\Api\Entities\Enums\TransactionType; class ReportingService { @@ -33,14 +30,8 @@ public static function activity() return (new TransactionReportBuilder(ReportType::ACTIVITY)); } - public static function transactionDetail($transactionId) + public static function transactionDetail(?string $transactionId) { - if (isset($transactionId->paymentMethodType)) { - return (new TransactionReportBuilder(ReportType::TRANSACTION_DETAIL)) - ->withTransactionId($transactionId) - ->withPaymentType($transactionId->paymentMethodType); - } - return (new TransactionReportBuilder(ReportType::TRANSACTION_DETAIL)) ->withTransactionId($transactionId); } diff --git a/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.php b/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.php index 00fd7606..d9e3f5f6 100644 --- a/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.php +++ b/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.php @@ -700,7 +700,7 @@ public function testVerifyTokenizedPaymentMethod_WrongID() } } - public function testCreditVerifyx() + public function testCreditVerify() { $response = $this->card->verify() ->withCurrency($this->currency) diff --git a/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php b/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php new file mode 100644 index 00000000..6c0613f2 --- /dev/null +++ b/test/Integration/Gateways/GpApiConnector/GpApiOpenBankingTest.php @@ -0,0 +1,144 @@ +setUpConfig()); + $this->startDate = (new \DateTime())->modify('-30 days')->setTime(0, 0, 0); + $this->endDate = (new \DateTime())->modify('-3 days')->setTime(0, 0, 0); + } + + public static function tearDownAfterClass() + { + BaseGpApiTestConfig::resetGpApiConfig(); + } + + public function setUpConfig() + { + $config = BaseGpApiTestConfig::gpApiSetupConfig(Channel::CardNotPresent); + $config->country = 'GB'; + return $config; + } + + private function fasterPaymentsConfig() + { + $bankPayment = new BankPayment(); + $bankPayment->accountNumber = '99999999'; + $bankPayment->sortCode = '407777'; + $bankPayment->accountName = 'Minal'; + $bankPayment->countries = ['GB', 'IE']; + $bankPayment->returnUrl = 'https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net'; + $bankPayment->statusUpdateUrl = 'https://gp-sdk.localhost.com/examples/gp-api/notificationUrl.php'; + + return $bankPayment; + } + + private function sepaConfig() + { + $bankPayment = new BankPayment(); + $bankPayment->iban = 'GB33BUKB20201555555555'; + $bankPayment->accountName = 'AccountName'; + $bankPayment->returnUrl = 'https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net'; + $bankPayment->statusUpdateUrl = 'https://7b8e82a17ac00346e91e984f42a2a5fb.m.pipedream.net'; + + return $bankPayment; + } + + private function assertOpenBankingResponse(Transaction $trn) + { + $this->assertEquals(TransactionStatus::INITIATED, $trn->responseMessage); + $this->assertNotNull($trn->transactionId); + $this->assertNotNull($trn->bankPaymentResponse->redirectUrl); + } + + public function testFasterPaymentsCharge() + { + $bankPayment = $this->fasterPaymentsConfig(); + + $trn = $bankPayment->charge($this->amount) + ->withCurrency($this->currency) + ->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes') + ->execute(); + + $this->assertOpenBankingResponse($trn); + + fwrite(STDERR, print_r($trn->bankPaymentResponse->redirectUrl, true)); + sleep(2); + + /** @var TransactionSummary $response */ + $response = ReportingService::transactionDetail($trn->transactionId) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals($trn->transactionId, $response->transactionId); + $this->assertNotNull($response->bankPaymentResponse->sortCode); + $this->assertNull($response->bankPaymentResponse->iban); + $this->assertNotNull($response->bankPaymentResponse->accountNumber); + } + + public function testSEPACharge() + { + $bankPayment = $this->sepaConfig(); + + $trn = $bankPayment->charge($this->amount) + ->withCurrency('EUR') + ->withRemittanceReference(RemittanceReferenceType::TEXT, 'Nike Bounce Shoes') + ->execute(); + + $this->assertOpenBankingResponse($trn); + fwrite(STDERR, print_r($trn->bankPaymentResponse->redirectUrl, TRUE)); + sleep(2); + /** @var TransactionSummary $response */ + $response = ReportingService::transactionDetail($trn->transactionId) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals($trn->transactionId, $response->transactionId); + $this->assertNotNull($response->bankPaymentResponse->iban); + $this->assertNull($response->bankPaymentResponse->sortCode); + $this->assertNull($response->bankPaymentResponse->accountNumber); + } + + public function testReportFindOBTransactionsByStartDateAndEndDate() + { + $response = ReportingService::findTransactionsPaged(1, 10) + ->orderBy(TransactionSortProperty::TIME_CREATED) + ->where(SearchCriteria::START_DATE, $this->startDate) + ->andWith(SearchCriteria::END_DATE, $this->endDate) + ->andWith(SearchCriteria::PAYMENT_PROVIDER, PaymentProvider::OPEN_BANKING) + ->execute(); + + $this->assertNotNull($response); + $this->assertTrue(is_array($response->result)); + + /** @var TransactionSummary $rs */ + foreach ($response->result as $rs) { + $this->assertEquals(PaymentMethodName::BANK_PAYMENT, $rs->paymentType); + $this->assertLessThanOrEqual($this->endDate->format('Y-m-d'), $rs->transactionDate->format('Y-m-d')); + $this->assertGreaterThanOrEqual($this->startDate->format('Y-m-d'), $rs->transactionDate->format('Y-m-d')); + } + } +} \ No newline at end of file diff --git a/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php b/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php index e0406bfe..cc2df8b3 100644 --- a/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php +++ b/test/Integration/Gateways/GpEcomConnector/OpenBankingTest.php @@ -34,7 +34,6 @@ protected function getConfig() $config->sharedSecret = 'sharedsecret'; $config->accountId = 'internet'; $config->requestLogger = new SampleRequestLogger(new Logger("logs")); - $config->enableBankPayment = true; $config->shaHashType = ShaHashType::SHA512; return $config; diff --git a/test/Integration/Gateways/TransactionApiConnector/TransactionApiAchTest.php b/test/Integration/Gateways/TransactionApiConnector/TransactionApiAchTest.php index 8cfa6a0e..c9975633 100644 --- a/test/Integration/Gateways/TransactionApiConnector/TransactionApiAchTest.php +++ b/test/Integration/Gateways/TransactionApiConnector/TransactionApiAchTest.php @@ -20,7 +20,7 @@ class TransactionApiAchTest extends TestCase private $customer; - public function setup() + public function setup(): void { $this->eCheck = new ECheck(); $this->eCheck->accountNumber = '12121'; diff --git a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCAReportingTest.php b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCAReportingTest.php index 6b20c495..0d4fd5e7 100644 --- a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCAReportingTest.php +++ b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCAReportingTest.php @@ -6,7 +6,8 @@ EcommerceIndicator, PaymentMethodType, PhoneNumberType, - TransactionLanguage + TransactionLanguage, + PaymentType }; use GlobalPayments\Api\Entities\TransactionApi\TransactionApiData; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; @@ -26,7 +27,7 @@ class TransactionApiCAReportingTest extends TestCase private $config; - public function setup() + public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); @@ -169,9 +170,8 @@ public function test003CreditReturnByCreditSaleId() $creditReturnId = $response->transactionId; - $transaction = Transaction::fromId($creditReturnId, null, PaymentMethodType::CREDIT); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions($creditReturnId) + ->where(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::CREDIT) ->execute(); $this->assertNotNull($response); @@ -198,12 +198,11 @@ public function test004CreditReturnByCreditReferenceId() ->execute(); $this->assertNotNull($response->referenceNumber); - $creditReferenceId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId($creditReferenceId); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $creditReferenceId) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::CREDIT) ->execute(); $this->assertNotNull($response); @@ -214,6 +213,7 @@ public function test004CreditReturnByCreditReferenceId() public function test005CheckSaleById() { ServicesContainer::configureService($this->setUpConfigACH()); + ServicesContainer::configureService($this->setUpConfigACH()); $this->transData = $this->getTransactionAchData( 'CA', @@ -236,9 +236,8 @@ public function test005CheckSaleById() $checkSaleId = $response->transactionReference->checkSaleId; - $transaction = Transaction::fromId($checkSaleId, null, PaymentMethodType::ACH); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions($checkSaleId) + ->where(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -271,13 +270,9 @@ public function test006CheckSaleByRefId() $checkRefId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId( - $checkRefId, - null, - PaymentMethodType::ACH - ); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $checkRefId) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -310,10 +305,9 @@ public function test007CheckRefundById() $checkRefundId = $response->transactionReference->checkRefundId; - $transaction = Transaction::fromId($checkRefundId, null, PaymentMethodType::ACH); - $transaction->originalTransactionType = "REFUND"; - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions($checkRefundId) + ->where(SearchCriteria::PAYMENT_TYPE, PaymentType::REFUND) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -349,14 +343,10 @@ public function test008CheckRefundByRefId() $checkRefId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId( - $checkRefId, - null, - PaymentMethodType::ACH - ); - $transaction->originalTransactionType = "REFUND"; - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $checkRefId) + ->andWith(SearchCriteria::PAYMENT_TYPE, PaymentType::REFUND) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); diff --git a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditReturnTest.php b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditReturnTest.php index 2b7b52c5..4d0290c4 100644 --- a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditReturnTest.php +++ b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditReturnTest.php @@ -27,7 +27,7 @@ class TransactionApiCreditReturnTest extends TestCase private $currency = "840"; - public function setup() + public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); $this->card = new CreditCardData(); diff --git a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditTest.php b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditTest.php index 0e0649eb..d4dddb43 100644 --- a/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditTest.php +++ b/test/Integration/Gateways/TransactionApiConnector/TransactionApiCreditTest.php @@ -29,7 +29,7 @@ class TransactionApiCreditTest extends TestCase private $card; private $address; private $addressCa; - public function setup() + public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); $this->card = new CreditCardData(); diff --git a/test/Integration/Gateways/TransactionApiConnector/TransactionApiReportingTest.php b/test/Integration/Gateways/TransactionApiConnector/TransactionApiReportingTest.php index f0fc1b2c..90a01e34 100644 --- a/test/Integration/Gateways/TransactionApiConnector/TransactionApiReportingTest.php +++ b/test/Integration/Gateways/TransactionApiConnector/TransactionApiReportingTest.php @@ -6,7 +6,8 @@ EcommerceIndicator, PaymentMethodType, PhoneNumberType, - TransactionLanguage + TransactionLanguage, + PaymentType }; use GlobalPayments\Api\Entities\Reporting\SearchCriteria; use GlobalPayments\Api\Entities\TransactionApi\TransactionApiData; @@ -28,7 +29,7 @@ class TransactionApiReportingTest extends TestCase private $currency = '840'; - public function setup() + public function setup(): void { ServicesContainer::configureService($this->setUpConfig()); @@ -144,9 +145,8 @@ public function test003CreditReturnByCreditReturnId() $creditReturnId = $response->transactionId; - $transaction = Transaction::fromId($creditReturnId, null, PaymentMethodType::CREDIT); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions($creditReturnId) + ->where(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::CREDIT) ->execute(); $this->assertNotNull($response); @@ -169,9 +169,9 @@ public function test004CreditReturnByCreditReferenceId() $this->assertNotNull($response->referenceNumber); $creditReferenceId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId($creditReferenceId); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $creditReferenceId) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::CREDIT) ->execute(); $this->assertNotNull($response); @@ -208,9 +208,8 @@ public function test005CheckSaleById() $checkSaleId = $response->transactionReference->checkSaleId; - $transaction = Transaction::fromId($checkSaleId, null, PaymentMethodType::ACH); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions($checkSaleId) + ->where(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -246,13 +245,9 @@ public function test006CheckSaleByRefId() $this->assertNotNull($response->referenceNumber); $checkRefId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId( - $checkRefId, - null, - PaymentMethodType::ACH - ); - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $checkRefId) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -286,11 +281,10 @@ public function test007CheckRefundById() ->execute(); $checkRefundId = $response->checkRefundId; - - $transaction = Transaction::fromId($checkRefundId, null, PaymentMethodType::ACH); - $transaction->originalTransactionType = "REFUND"; - - $response = ReportingService::transactionDetail($transaction) + + $response = ReportingService::findTransactions($checkRefundId) + ->where(SearchCriteria::PAYMENT_TYPE, PaymentType::REFUND) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response); @@ -325,14 +319,10 @@ public function test008CheckRefundByRefId() $checkRefId = $response->referenceNumber; - $transaction = Transaction::fromClientTransactionId( - $checkRefId, - null, - PaymentMethodType::ACH - ); - $transaction->originalTransactionType = "REFUND"; - - $response = ReportingService::transactionDetail($transaction) + $response = ReportingService::findTransactions() + ->where(SearchCriteria::CLIENT_TRANSACTION_ID, $checkRefId) + ->andWith(SearchCriteria::PAYMENT_TYPE, PaymentType::REFUND) + ->andWith(SearchCriteria::PAYMENT_METHOD_TYPE, PaymentMethodType::ACH) ->execute(); $this->assertNotNull($response);