From 4738c3084ebad77b7072b3980dc7b2430d618e8f Mon Sep 17 00:00:00 2001 From: securesubmit-buildmaster Date: Thu, 9 Feb 2023 08:02:34 -0500 Subject: [PATCH] OctopusDeploy release: 6.1.1 --- CHANGELOG.md | 8 +- metadata.xml | 2 +- src/Gateways/PorticoConnector.php | 9 +- src/PaymentMethods/Credit.php | 97 ++++++++++--------- .../Certifications/EcommerceTest.php | 76 +++++++++++++++ 5 files changed, 137 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f01ea005..8ca01101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,16 @@ # Changelog -## Latest version +## Latest Version +#### Bug Fixes: +- Portico Gateway: fix DigitalPaymentToken handling + +## v6.0.6 (02/02/2023) #### Enhancements: - GP-API: add risk assessment feature - Refacto the Secure3DBuilder -## v6.0.6 (02/26/2023) +## v6.0.6 (01/26/2023) #### Enhancements: - GPI Transactions : added support for credit, ach & reporting transactions - GP-API: add to generateXGPSignature to GenerationUtils diff --git a/metadata.xml b/metadata.xml index fff7c43f..11ca6220 100644 --- a/metadata.xml +++ b/metadata.xml @@ -1,3 +1,3 @@ - 6.1.0 + 6.1.1 \ No newline at end of file diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index 8f9fb07b..44938ad4 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -2341,11 +2341,7 @@ protected function hydrateThreeDSecureData(DOMDocument $xml, BaseBuilder $builde private function hydrateWalletData(DOMDocument $xml, BaseBuilder $builder, $block1, $cardData) { //wallet data - if ( - $builder->paymentMethod->mobileType == MobilePaymentMethodType::APPLEPAY - || $builder->paymentMethod->mobileType == MobilePaymentMethodType::GOOGLEPAY - && $this->isAppleOrGooglePay($builder->paymentMethod->paymentSource) - ) { + if ($this->isAppleOrGooglePay($builder->paymentMethod->paymentSource)) { $walletData = $xml->createElement('WalletData'); if (!empty($builder->paymentMethod->threeDSecure->cavv)) { @@ -2357,8 +2353,7 @@ private function hydrateWalletData(DOMDocument $xml, BaseBuilder $builder, $bloc if (!empty($builder->paymentMethod->paymentSource)) { $walletData->appendChild($xml->createElement('PaymentSource', $builder->paymentMethod->paymentSource)); } - - if ($builder->paymentMethod->mobileType) { + if (!empty($builder->paymentMethod->token)) { $token = $this->toFormatToken($builder->paymentMethod->token); $walletData->appendChild($xml->createElement('DigitalPaymentToken', $token)); $block1->removeChild($cardData); diff --git a/src/PaymentMethods/Credit.php b/src/PaymentMethods/Credit.php index 7a348f22..ceddfb23 100644 --- a/src/PaymentMethods/Credit.php +++ b/src/PaymentMethods/Credit.php @@ -2,28 +2,29 @@ namespace GlobalPayments\Api\PaymentMethods; -use GlobalPayments\Api\Builders\AuthorizationBuilder; -use GlobalPayments\Api\Builders\ManagementBuilder; -use GlobalPayments\Api\Entities\DccRateData; -use GlobalPayments\Api\Entities\Enums\EntryMethod; -use GlobalPayments\Api\Entities\Enums\ManualEntryMethod; -use GlobalPayments\Api\Entities\Enums\PaymentMethodUsageMode; -use GlobalPayments\Api\Entities\ThreeDSecure; -use GlobalPayments\Api\Entities\Enums\PaymentMethodType; -use GlobalPayments\Api\Entities\Enums\TransactionType; -use GlobalPayments\Api\Entities\Exceptions\ApiException; +use GlobalPayments\Api\Builders\{AuthorizationBuilder, ManagementBuilder}; +use GlobalPayments\Api\Entities\{DccRateData, ThreeDSecure}; +use GlobalPayments\Api\Entities\Enums\{ + EntryMethod, + ManualEntryMethod, + PaymentMethodType, + PaymentMethodUsageMode, + TransactionType +}; use GlobalPayments\Api\Entities\Exceptions\BuilderException; -use GlobalPayments\Api\PaymentMethods\Interfaces\IAuthable; -use GlobalPayments\Api\PaymentMethods\Interfaces\IBalanceable; -use GlobalPayments\Api\PaymentMethods\Interfaces\IChargable; -use GlobalPayments\Api\PaymentMethods\Interfaces\IEncryptable; -use GlobalPayments\Api\PaymentMethods\Interfaces\IPaymentMethod; -use GlobalPayments\Api\PaymentMethods\Interfaces\IPrePayable; -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; +use GlobalPayments\Api\PaymentMethods\Interfaces\{ + IAuthable, + IPaymentMethod, + IEncryptable, + ITokenizable, + IChargable, + IRefundable, + IReversable, + IVerifyable, + IPrePayable, + IBalanceable, + ISecure3d +}; abstract class Credit implements IPaymentMethod, @@ -38,22 +39,10 @@ abstract class Credit implements IBalanceable, ISecure3d { - public $encryptionData; - public $paymentMethodType = PaymentMethodType::CREDIT; - /** - * The token value representing the card. - * - * For `TransactionModifier.Encrypted_Mobile` transactions, this value is the - * encrypted payload from the mobile payment scheme. - */ - public $token; - - /** - * The type of mobile device used in `TransactionModifier.Encrypted_Mobile` - * transactions. + * The card type of the manual entry data. */ - public $mobileType; + public $cardType; /** * The authentication value use to verify the validity of the digit wallet transaction. @@ -69,6 +58,29 @@ abstract class Credit implements */ public $eci; + public $encryptionData; + + /** @var EntryMethod|ManualEntryMethod */ + public $entryMethod; + + /** @var bool */ + public $isFleet; + + /** + * The type of mobile device used in `TransactionModifier.Encrypted_Mobile` + * transactions. + */ + public $mobileType; + + public $paymentMethodType = PaymentMethodType::CREDIT; + + + // maybe change the name of the below var + + + /** @var PaymentDataSourceType */ + public $paymentSource; + /** * Secure 3d Data attached to the card * @var ThreeDSecure @@ -76,17 +88,12 @@ abstract class Credit implements public $threeDSecure; /** - * The card type of the manual entry data. + * The token value representing the card. + * + * For `TransactionModifier.Encrypted_Mobile` transactions, this value is the + * encrypted payload from the mobile payment scheme. */ - public $cardType; - - /** @var bool */ - public $isFleet; - - /** @var EntryMethod|ManualEntryMethod */ - public $entryMethod; - - /** @return boolean */ + public $token; /** * Authorizes the payment method diff --git a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php index 6f7f4209..b039da4a 100644 --- a/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php +++ b/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.php @@ -2054,4 +2054,80 @@ public function testEcomWithWalletDataMobileType() $this->assertEquals(true, $response != null); $this->assertEquals('00', $response->responseCode); } + + // can use this to generate a token: https://gpay-test.azurewebsites.net/ + // use MID 777703754644 + public function testGooglePay() : void + { + $walletConfig = new PorticoConfig(); + $walletConfig->secretApiKey = 'skapi_cert_MVq4BQC5n3AAgd4M1Cvph2ud3CGaIclCgC7H_KxZaQ'; + ServicesContainer::configureService($walletConfig, 'GooglePay'); + + $card = new CreditCardData(); + $card->paymentSource = PaymentDataSourceType::GOOGLEPAYAPP; + $card->token = '{"signature":"MEUCIDiJ2XhsweojddWc6VNuK+aq9JvT3M1kfQGOCiQEiYdVAiEA+o6f5VcMxbTABBCAmq9gMEA8KAzhfhJf4qAMh9sxRK0\u003d","protocolVersion":"ECv1","signedMessage":"{\"encryptedMessage\":\"nOdfmUk8qjQKUmJJzve9V7fTD3uu1tzsFWD9iM2rNoneCHLEhsgbK1CGpMuB4kpNIFlbcCTFbmwPqriE0W0Wr8iisPnUgDrBG7O7PnRImAzx83P0LnNgHHNs7V0Z4yqOZ9r22nI4wE6OEfNZutacluR4rHJQRd4WqcDeiqfbftmr97aOlZ5m/G/7/Fpqu4Caeicol8LuqIEtcwRFX3Qya2alJ4lrgb7eRSapZiOFjwt/4EyXaxsh8MmIOeDDyFybKliySIbAXdC+0LsrBgn9Jujgy7GRlWc94C8RZ8hy0U7IlCAD3NznEEQ9gkmq2h0/NH5Zz660cpp42GzCEwLe0Q3m8p6IvMct2xKm3IkuC1iJQthuakURalp16TdaealTU2NIaMh3ZD6X8KO0zaEBVkK4cmC1Aj0MDDheKMcjQvYoO47XPobYUE3qDhoZ6iPwCWSNVrA1EQ\\u003d\\u003d\",\"ephemeralPublicKey\":\"BLdiwg4jfHZehuzoeR3/sxKYWqU6nmsnheenjUPaw3v3M2In0HVVONotaNb566oZtHT5afvwtBZvd6VL6PSowqE\\u003d\",\"tag\":\"q/+hOdT+8mEkSMIRXeE6TlKG5t5o29jmCj7wsjO+lCg\\u003d\"}"}'; + + $response = $card->charge(10) + ->withCurrency('USD') + ->withInvoiceNumber('12345') + ->withAllowDuplicates(true) + ->execute('GooglePay'); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + public function testMasterCardSuptSale() : void + { + $walletConfig = new PorticoConfig(); + $walletConfig->secretApiKey = 'skapi_cert_MVq4BQC5n3AAgd4M1Cvph2ud3CGaIclCgC7H_KxZaQ'; + ServicesContainer::configureService($walletConfig, 'GooglePay'); + + $card = new CreditCardData(); + $card->token = $this->getMastercardToken('pkapi_cert_BxO8wdeBZaZfEBuP0b'); + + $response = $card->charge(10) + ->withCurrency('USD') + ->withInvoiceNumber('12345') + ->withAllowDuplicates(true) + ->execute('GooglePay'); + + $this->assertEquals(true, $response != null); + $this->assertEquals('00', $response->responseCode); + } + + /** + * + * @param string $pubKey + * @return string + * @throws AssertionFailedError + */ + protected function getMastercardToken(string $pubKey) : string + { + $payload = array( + 'object' => 'token', + 'token_type' => 'supt', + 'card' => array( + 'number' => '5454545454545454', + 'cvc' => '123', + 'exp_month' => '12', + 'exp_year' => '2023' + ) + ); + $url = 'https://cert.api2-c.heartlandportico.com/Hps.Exchange.PosGateway.Hpf.v1/api/token?api_key=' + . $pubKey; + $options = array( + 'http' => array( + 'header' => "Content-Type: application/json\r\n", + 'method' => 'POST', + 'content' => json_encode($payload), + ), + ); + $context = stream_context_create($options); + $response = json_decode(file_get_contents($url, false, $context)); + if (!$response || isset($response->error)) { + $this->fail('no single-use token obtained'); + } + return $response->token_value; + } }