diff --git a/CHANGELOG.md b/CHANGELOG.md index 491a69fd..692a33b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ # Changelog -## Latest Version - v11.0.5 (01/09/24) +## Latest Version - v11.0.6 (01/16/24) +### Enhancements: +- [GP-API] Update QR code payment example for WeChat + +#### Bug Fixes: +[GP-ECOM] Fix parseResponse on HostedService when TIMESTAMP is not returned from API + +## v11.0.5 (01/09/24) #### Bug Fixes: - [Portico] Fixed null CustomerData exception - [A35_PAX] Fixed long transaction processing times diff --git a/examples/gp-api/alipay/GenerateToken.php b/examples/gp-api/alipay/GenerateToken.php index 11664094..d2a6b6ee 100644 --- a/examples/gp-api/alipay/GenerateToken.php +++ b/examples/gp-api/alipay/GenerateToken.php @@ -8,9 +8,9 @@ class GenerateToken { - const APP_ID = 'QzFNaCAVCSH4tELLYz5iReERAJ3mqHu7'; - const APP_KEY = '0QCyAwox3nRufZhX'; - const ACCOUNT_ID = 'TRA_c7fdc03bc9354fd3b674dddb22583553'; + const APP_ID = 'bvKLJsu6vYC9zxX2BpOgNK95kbboP3Uw'; + const APP_KEY = '7aH9QlA3yVFwpESQ'; + const ACCOUNT_ID = 'TRA_1366cd0db8c14fffb130ab49be84d944'; private static $instance = null; private string $accessToken; diff --git a/examples/gp-api/alipay/initiatePayment.php b/examples/gp-api/alipay/initiatePayment.php index bf0faf27..8bbc0555 100644 --- a/examples/gp-api/alipay/initiatePayment.php +++ b/examples/gp-api/alipay/initiatePayment.php @@ -4,7 +4,6 @@ require_once('GenerateToken.php'); use GlobalPayments\Api\Entities\Enums\AlternativePaymentType; -use GlobalPayments\Api\Entities\Enums\Environment; use GlobalPayments\Api\Entities\Enums\Channel; use GlobalPayments\Api\Entities\Enums\MerchantCategory; use GlobalPayments\Api\Entities\Exceptions\ApiException; @@ -15,24 +14,29 @@ use GlobalPayments\Api\Utils\Logging\Logger; use GlobalPayments\Api\Entities\GpApi\AccessTokenInfo; -$decodedData = json_decode(file_get_contents('php://input')); -$provider = $decodedData->provider; +$provider = $_GET['provider'] ?? ''; + +if ($provider === 'WeChat') { + $provider = AlternativePaymentType::WECHAT_PAY; +} else { + $provider = strtolower($provider); +} // configure client & request settings $config = new GpApiConfig(); $config->appId = GenerateToken::APP_ID; $config->appKey = GenerateToken::APP_KEY; -$config->environment = Environment::TEST; $config->channel = Channel::CardNotPresent; +$config->country = 'HK'; $config->accessTokenInfo = new AccessTokenInfo(); $config->accessTokenInfo->transactionProcessingAccountID = GenerateToken::ACCOUNT_ID; $config->requestLogger = new SampleRequestLogger(new Logger("logs")); ServicesContainer::configureService($config); -$paymentMethod = new AlternativePaymentMethod(AlternativePaymentType::ALIPAY); +$paymentMethod = new AlternativePaymentMethod($provider); $paymentMethod->returnUrl = $_SERVER['HTTP_ORIGIN'] . '/examples/gp-api/alipay/returnUrl'; $paymentMethod->statusUpdateUrl = $_SERVER['HTTP_ORIGIN'] . '/examples/gp-api/alipay/returnUrl'; -$paymentMethod->country = 'US'; +$paymentMethod->country = 'HK'; $paymentMethod->accountHolderName = 'Jane Doe'; try { @@ -48,10 +52,10 @@ // simple example of how to prepare the JSON string for JavaScript Library $responseJson = array( "seconds_to_expire" => $response->alternativePaymentResponse->secondsToExpire ?? '120', - "next_action" => $response->alternativePaymentResponse->nextAction, - "redirect_url" => $response->alternativePaymentResponse->redirectUrl, - "qr_code" => $response->alternativePaymentResponse->qrCodeImage, - "provider" => $response->alternativePaymentResponse->providerName + "next_action" => $response->alternativePaymentResponse->nextAction ?? '', + "redirect_url" => $response->alternativePaymentResponse->redirectUrl ?? '', + "qr_code" => $response->alternativePaymentResponse->qrCodeImage ?? '', + "provider" => $response->alternativePaymentResponse->providerName ?? '' ); echo json_encode($responseJson); diff --git a/examples/gp-api/alipay/main.js b/examples/gp-api/alipay/main.js index 6285ab9a..166c13bf 100644 --- a/examples/gp-api/alipay/main.js +++ b/examples/gp-api/alipay/main.js @@ -18,6 +18,7 @@ GlobalPayments.configure({ const cardForm = GlobalPayments.creditCard.form( '#credit-card', { + amount: "20", style: "gp-default", apms: [ GlobalPayments.enums.Apm.QRCodePayments, @@ -39,6 +40,7 @@ cardForm.on(GlobalPayments.enums.QRCodePaymentsMerchantInteractionEvents.Payment }); window.dispatchEvent(merchantCustomEventProvideDetails); } - xmlhttp.open("GET", "initiatePayment.php?q=" + provider); + + xmlhttp.open("GET", "initiatePayment.php?provider=" + provider); xmlhttp.send(); }); diff --git a/metadata.xml b/metadata.xml index 6d797f74..8b735657 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 11.0.5 + 11.0.6 \ No newline at end of file diff --git a/src/Mapping/GpApiMapping.php b/src/Mapping/GpApiMapping.php index e1f3b502..cedcb206 100644 --- a/src/Mapping/GpApiMapping.php +++ b/src/Mapping/GpApiMapping.php @@ -883,7 +883,7 @@ public static function mapResponseAPM($response) if (is_string($paymentMethodApm->provider)) { $apm->providerName = $paymentMethodApm->provider; } elseif (is_object($paymentMethodApm->provider)) { - $apm->providerName = strtolower($paymentMethodApm->provider->name) ?? null; + $apm->providerName = $paymentMethodApm->provider->name ?? null; $apm->providerReference = $paymentMethodApm->provider->merchant_identifier ?? null; $apm->timeCreatedReference = $paymentMethodApm->provider->time_created_reference ?? null; } diff --git a/src/Services/HostedService.php b/src/Services/HostedService.php index 82ee1d75..1315504a 100644 --- a/src/Services/HostedService.php +++ b/src/Services/HostedService.php @@ -98,23 +98,23 @@ public function void($transaction = null) private function mapTransactionStatusResponse($response) : array { return [ - 'ACCOUNT_HOLDER_NAME' => $response['accountholdername'], - 'ACCOUNT_NUMBER' => $response['accountnumber'], - 'TIMESTAMP' => $response['timestamp'], - 'MERCHANT_ID' => $response['merchantid'], - 'BANK_CODE' => $response['bankcode'], - 'BANK_NAME' => $response['bankname'], - 'HPP_CUSTOMER_BIC' => $response['bic'], - 'COUNTRY' => $response['country'], - 'HPP_CUSTOMER_EMAIL' => $response['customeremail'], - 'TRANSACTION_STATUS' => $response['fundsstatus'], - 'IBAN' => $response['iban'], - 'MESSAGE' => $response['message'], - 'ORDER_ID' => $response['orderid'], - 'PASREF' => $response['pasref'], - 'PAYMENTMETHOD' => $response['paymentmethod'], - 'PAYMENT_PURPOSE' => $response['paymentpurpose'], - 'RESULT' => $response['result'], + 'ACCOUNT_HOLDER_NAME' => $response['accountholdername'] ?? '', + 'ACCOUNT_NUMBER' => $response['accountnumber'] ?? '', + 'TIMESTAMP' => $response['timestamp'] ?? '', + 'MERCHANT_ID' => $response['merchantid'] ?? '', + 'BANK_CODE' => $response['bankcode'] ?? '', + 'BANK_NAME' => $response['bankname'] ?? '', + 'HPP_CUSTOMER_BIC' => $response['bic'] ?? '', + 'COUNTRY' => $response['country'] ?? '', + 'HPP_CUSTOMER_EMAIL' => $response['customeremail'] ?? '', + 'TRANSACTION_STATUS' => $response['fundsstatus'] ?? '', + 'IBAN' => $response['iban'] ?? '', + 'MESSAGE' => $response['message'] ?? '', + 'ORDER_ID' => $response['orderid'] ?? '', + 'PASREF' => $response['pasref'] ?? '', + 'PAYMENTMETHOD' => $response['paymentmethod'] ?? '', + 'PAYMENT_PURPOSE' => $response['paymentpurpose'] ?? '', + 'RESULT' => $response['result'] ?? '', $this->shaHashType . "HASH" => $response[strtolower($this->shaHashType).'hash'] ]; }