jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/376349 )
Change subject: Fix RETURNURL for PayPal EC, add tests for API params ...................................................................... Fix RETURNURL for PayPal EC, add tests for API params Change-Id: I5b0cb7017f99c5d1e39e7b3416abf3dc81909fab --- M paypal_gateway/express_checkout/paypal_express.adapter.php M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php 2 files changed, 83 insertions(+), 0 deletions(-) Approvals: XenoRyet: Looks good to me, approved jenkins-bot: Verified diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php b/paypal_gateway/express_checkout/paypal_express.adapter.php index 00fa775..5af3ac3 100644 --- a/paypal_gateway/express_checkout/paypal_express.adapter.php +++ b/paypal_gateway/express_checkout/paypal_express.adapter.php @@ -366,6 +366,8 @@ public function doPayment() { $this->config['transformers'][] = 'PaypalExpressReturnUrl'; + $this->data_transformers[] = new PaypalExpressReturnUrl(); + $this->stageData(); if ( $this->getData_Unstaged_Escaped( 'recurring' ) ) { // Build the billing agreement and get a token to redirect. $resultData = $this->do_transaction( 'SetExpressCheckout_recurring' ); diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php index cfab70a..37c216f 100644 --- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php +++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php @@ -54,6 +54,46 @@ $result->getRedirect(), 'Wrong redirect for PayPal EC payment setup' ); + $this->assertEquals( 1, count( $gateway->curled ), 'Should have made 1 API call' ); + $apiCall = $gateway->curled[0]; + $parsed = []; + parse_str( $apiCall, $parsed ); + $actualReturn = $parsed['RETURNURL']; + $parsedReturn = []; + parse_str( parse_url( $actualReturn, PHP_URL_QUERY ), $parsedReturn ); + $this->assertEquals( + [ + 'title' => 'Special:PaypalExpressGatewayResult', + 'order_id' => $init['contribution_tracking_id'] . '.1', + 'wmf_token' => $gateway->token_getSaltedSessionToken() + ], + $parsedReturn + ); + unset( $parsed['RETURNURL'] ); + $expected = [ + 'USER' => 'phpunittest...@wikimedia.org', + 'PWD' => '9876543210', + 'VERSION' => '204', + 'METHOD' => 'SetExpressCheckout', + 'CANCELURL' => 'https://example.com/tryAgain.php/fr', + 'REQCONFIRMSHIPPING' => '0', + 'NOSHIPPING' => '1', + 'LOCALECODE' => 'fr_US', + 'L_PAYMENTREQUEST_0_AMT0' => '1.55', + 'L_PAYMENTREQUEST_0_DESC0' => 'Donation to the Wikimedia Foundation', + 'PAYMENTREQUEST_0_AMT' => '1.55', + 'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD', + 'PAYMENTREQUEST_0_CUSTOM' => $init['contribution_tracking_id'], + 'PAYMENTREQUEST_0_DESC' => 'Donation to the Wikimedia Foundation', + 'PAYMENTREQUEST_0_INVNUM' => $init['contribution_tracking_id'] . '.1', + 'PAYMENTREQUEST_0_ITEMAMT' => '1.55', + 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', + 'PAYMENTREQUEST_0_PAYMENTREASON' => 'None', + 'SIGNATURE' => 'ABCDEFGHIJKLMNOPQRSTUV-ZXCVBNMLKJHGFDSAPOIUYTREWQ', + ]; + $this->assertEquals( + $expected, $parsed + ); $message = QueueWrapper::getQueue( 'pending' )->pop(); $this->assertNotEmpty( $message, 'Missing pending message' ); self::unsetVariableFields( $message ); @@ -107,6 +147,47 @@ $result->getRedirect(), 'Wrong redirect for PayPal EC payment setup' ); + $this->assertEquals( 1, count( $gateway->curled ), 'Should have made 1 API call' ); + $apiCall = $gateway->curled[0]; + $parsed = []; + parse_str( $apiCall, $parsed ); + $actualReturn = $parsed['RETURNURL']; + $parsedReturn = []; + parse_str( parse_url( $actualReturn, PHP_URL_QUERY ), $parsedReturn ); + $this->assertEquals( + [ + 'title' => 'Special:PaypalExpressGatewayResult', + 'order_id' => $init['contribution_tracking_id'] . '.1', + 'recurring' => '1', + 'wmf_token' => $gateway->token_getSaltedSessionToken() + ], + $parsedReturn + ); + unset( $parsed['RETURNURL'] ); + $expected = [ + 'USER' => 'phpunittest...@wikimedia.org', + 'PWD' => '9876543210', + 'VERSION' => '204', + 'METHOD' => 'SetExpressCheckout', + 'CANCELURL' => 'https://example.com/tryAgain.php/fr', + 'REQCONFIRMSHIPPING' => '0', + 'NOSHIPPING' => '1', + 'LOCALECODE' => 'fr_US', + 'L_PAYMENTREQUEST_0_AMT0' => '1.55', + 'PAYMENTREQUEST_0_AMT' => '1.55', + 'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD', + 'L_BILLINGTYPE0' => 'RecurringPayments', + 'L_BILLINGAGREEMENTDESCRIPTION0' => 'Monthly donation to the Wikimedia Foundation', + 'L_BILLINGAGREEMENTCUSTOM0' => $init['contribution_tracking_id'] . '.1', + 'L_PAYMENTREQUEST_0_NAME0' => 'Monthly donation to the Wikimedia Foundation', + 'L_PAYMENTREQUEST_0_QTY0' => '1', + 'MAXAMT' => '1.55', + 'PAYMENTREQUEST_0_ITEMAMT' => '1.55', + 'SIGNATURE' => 'ABCDEFGHIJKLMNOPQRSTUV-ZXCVBNMLKJHGFDSAPOIUYTREWQ', + ]; + $this->assertEquals( + $expected, $parsed + ); $message = QueueWrapper::getQueue( 'pending' )->pop(); $this->assertNotEmpty( $message, 'Missing pending message' ); self::unsetVariableFields( $message ); -- To view, visit https://gerrit.wikimedia.org/r/376349 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5b0cb7017f99c5d1e39e7b3416abf3dc81909fab Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Mepps <me...@wikimedia.org> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits