Mepps has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/387638 )
Change subject: Merge branch 'master' into deployment ...................................................................... Merge branch 'master' into deployment cat7e511a2 Redirect for Safari + multiskins ec03452 Localisation updates from https://translatewiki.net. f276437 Add processor_form to qqq.json dda6398 Don't require API read rights to report client-side errors 65c21ec Unit tests for Adyen multi-skin switching 122eb3b Revert "Handle payment not initiated" 2b78bae Localisation updates from https://translatewiki.net. 6373220 Localisation updates from https://translatewiki.net. 5dedd23 Localisation updates from https://translatewiki.net. 0d57b21 Handle PaymentActionCompleted in batch mode Change-Id: Ibd8372ca200cf06fd6fc7a26de9a01ebb79d4786 --- M paypal_gateway/express_checkout/paypal_express.adapter.php D tests/phpunit/Adapter/Adyen/AdyenTest.php D tests/phpunit/Adapter/PayPal/PayPalExpressTest.php D tests/phpunit/DonationInterfaceTestCase.php D tests/phpunit/TestConfiguration.php D tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_10486.testresponse D tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_C2.testresponse D tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_OK.testresponse D tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Recurring-OK.testresponse 9 files changed, 0 insertions(+), 1,884 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/38/387638/1 diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php b/paypal_gateway/express_checkout/paypal_express.adapter.php index 4a27176..3565b03 100644 --- a/paypal_gateway/express_checkout/paypal_express.adapter.php +++ b/paypal_gateway/express_checkout/paypal_express.adapter.php @@ -439,10 +439,6 @@ break; case 'GetExpressCheckoutDetails': $this->checkResponseAck( $response ); -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) - -======= ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) // Merge response into our transaction data. // TODO: Use getFormattedData instead. // FIXME: We don't want to allow overwriting of ctid, need a @@ -564,24 +560,6 @@ ResponseCodes::UNKNOWN ); } -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) - if ( $this->getData_Unstaged_Escaped( 'recurring' ) ) { - // Set up recurring billing agreement. - $this->addRequestData( array( - 'date' => time() - ) ); - $resultData = $this->do_transaction( 'CreateRecurringPaymentsProfile' ); - if ( !$resultData->getCommunicationStatus() ) { - throw new ResponseProcessingException( - 'Failed to create a recurring profile', ResponseCodes::UNKNOWN ); - } - } else { - // One-time payment, or initial payment in a subscription. - $resultData = $this->do_transaction( 'DoExpressCheckoutPayment' ); - if ( !$resultData->getCommunicationStatus() ) { - $this->finalizeInternalStatus( FinalStatus::FAILED ); - return PaymentResult::newFailure(); -======= if ( $this->getFinalStatus() !== FinalStatus::COMPLETE ) { if ( $this->getData_Unstaged_Escaped( 'recurring' ) ) { // Set up recurring billing agreement. @@ -600,7 +578,6 @@ $this->finalizeInternalStatus( FinalStatus::FAILED ); return PaymentResult::newFailure(); } ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) } } return PaymentResult::fromResults( diff --git a/tests/phpunit/Adapter/Adyen/AdyenTest.php b/tests/phpunit/Adapter/Adyen/AdyenTest.php deleted file mode 100644 index 819b1a4..0000000 --- a/tests/phpunit/Adapter/Adyen/AdyenTest.php +++ /dev/null @@ -1,271 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -<?php -/** - * Wikimedia Foundation - * - * LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -use SmashPig\PaymentProviders\Adyen\Tests\AdyenTestConfiguration; -use SmashPig\Tests\TestingContext; -use Wikimedia\TestingAccessWrapper; - -/** - * - * @group Fundraising - * @group DonationInterface - * @group Adyen - */ -class DonationInterface_Adapter_Adyen_Test extends DonationInterfaceTestCase { - - /** - * @param $name string The name of the test case - * @param $data array Any parameters read from a dataProvider - * @param $dataName string|int The name or index of the data set - */ - public function __construct( $name = null, array $data = array(), $dataName = '' ) { - parent::__construct( $name, $data, $dataName ); - $this->testAdapterClass = 'TestingAdyenAdapter'; - } - - public function setUp() { - parent::setUp(); - TestingContext::get()->providerConfigurationOverride = - AdyenTestConfiguration::createWithSuccessfulApi( - $this->smashPigGlobalConfig - ); - - $this->setMwGlobals( array( - 'wgAdyenGatewayEnabled' => true, - ) ); - } - - /** - * Integration test to verify that the donate transaction works as expected when all necessary data is present. - */ - function testDoTransactionDonate() { - $init = $this->getDonorTestData(); - $init['payment_submethod'] = 'visa'; - $gateway = $this->getFreshGatewayObject( $init ); - - $gateway->do_transaction( 'donate' ); - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $ret = $exposed->buildRequestParams(); - - $expected = array( - 'allowedMethods' => 'card', - 'billingAddress.street' => $init['street_address'], - 'billingAddress.city' => $init['city'], - 'billingAddress.postalCode' => $init['postal_code'], - 'billingAddress.stateOrProvince' => $init['state_province'], - 'billingAddress.country' => $init['country'], - 'billingAddress.houseNumberOrName' => 'NA', - 'billingAddressType' => 2, - 'card.cardHolderName' => $init['first_name'] . ' ' . $init['last_name'], - 'currencyCode' => $init['currency'], - 'merchantAccount' => 'wikitest', - 'merchantReference' => $exposed->getData_Staged( 'order_id' ), - 'merchantSig' => $exposed->getData_Staged( 'hpp_signature' ), - 'paymentAmount' => ( $init['amount'] ) * 100, -// 'sessionValidity' => '2014-03-09T19:41:50+00:00', //commenting out, because this is a problem. -// 'shipBeforeDate' => $exposed->getData_Staged( 'expiration' ), //this too. - 'skinCode' => 'testskin', - 'shopperLocale' => 'en_US', - 'shopperEmail' => '[email protected]', - 'offset' => '52', // once we construct the FraudFiltersTestCase, it should land here. - ); - - // deal with problem keys. - // @TODO: Refactor gateway so these are more testable - $problems = array( - 'sessionValidity', - 'shipBeforeDate', - ); - - foreach ( $problems as $oneproblem ) { - if ( isset( $ret[$oneproblem] ) ) { - unset( $ret[$oneproblem] ); - } - } - - $this->assertEquals( $expected, $ret, 'Adyen "donate" transaction not constructing the expected redirect URL' ); - $this->assertNotNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Adyen order_id is null, and we need one for 'merchantReference'" ); - } - - function testRiskScoreAddedToQueueMessage() { - $init = $this->getDonorTestData(); - $init['payment_submethod'] = 'visa'; - $gateway = $this->getFreshGatewayObject( $init ); - - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $exposed->risk_score = 57; - $message = $exposed->getQueueDonationMessage(); - $this->assertEquals( 57, $message['risk_score'], 'Risk score was not correctly added to queue message.' ); - } - - /** - * Make sure language is staged correctly when qs param is uppercase - */ - function testLanguageCaseSensitivity() { - $init = $this->getDonorTestData(); - $init['payment_submethod'] = 'visa'; - $init['language'] = 'FR'; - $gateway = $this->getFreshGatewayObject( $init ); - - $gateway->do_transaction( 'donate' ); - $exposed = TestingAccessWrapper::newFromObject( $gateway ); - $ret = $exposed->buildRequestParams(); - - $expected = array( - 'allowedMethods' => 'card', - 'billingAddress.street' => $init['street_address'], - 'billingAddress.city' => $init['city'], - 'billingAddress.postalCode' => $init['postal_code'], - 'billingAddress.stateOrProvince' => $init['state_province'], - 'billingAddress.country' => $init['country'], - 'billingAddress.houseNumberOrName' => 'NA', - 'billingAddressType' => 2, - 'card.cardHolderName' => $init['first_name'] . ' ' . $init['last_name'], - 'currencyCode' => $init['currency'], - 'merchantAccount' => 'wikitest', - 'merchantReference' => $exposed->getData_Staged( 'order_id' ), - 'merchantSig' => $exposed->getData_Staged( 'hpp_signature' ), - 'paymentAmount' => ( $init['amount'] ) * 100, - 'skinCode' => 'testskin', - 'shopperLocale' => 'fr_US', - 'shopperEmail' => '[email protected]', - 'offset' => '52', - ); - - // deal with problem keys. - // @TODO: Refactor gateway so these are more testable - $problems = array( - 'sessionValidity', - 'shipBeforeDate', - ); - - foreach ( $problems as $oneproblem ) { - if ( isset( $ret[$oneproblem] ) ) { - unset( $ret[$oneproblem] ); - } - } - - $this->assertEquals( $expected, $ret, 'Adyen "donate" transaction not constructing the expected redirect URL' ); - $this->assertNotNull( $gateway->getData_Unstaged_Escaped( 'order_id' ), "Adyen order_id is null, and we need one for 'merchantReference'" ); - } - - public function testDonorReturnSuccess() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['language'] = 'FR'; - $init['order_id'] = '55555'; - $session['Donor'] = $init; - $this->setUpRequest( $init, $session ); - $gateway = $this->getFreshGatewayObject( array() ); - $result = $gateway->processDonorReturn( array( - 'authResult' => 'AUTHORISED', - 'merchantReference' => '55555.1', - 'merchantSig' => 'NPG6j/g5LVORxSXb8WLegoG6e2Fd7D4986p736yozbI=', - 'paymentMethod' => 'visa', - 'pspReference' => '123987612346789', - 'shopperLocale' => 'fr_FR', - 'skinCode' => 'testskin', - 'title' => 'Special:AdyenGatewayResult' - ) ); - $this->assertFalse( $result->isFailed() ); - $this->assertEmpty( $result->getErrors() ); - // TODO inspect the queue message - } - - /** - * Test that we verify the signature with the alternate skin code's HMAC - */ - public function testDonorReturnSuccessAltSkin() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['language'] = 'FR'; - $init['order_id'] = '55555'; - $session['Donor'] = $init; - $this->setUpRequest( $init, $session ); - $gateway = $this->getFreshGatewayObject( array() ); - $result = $gateway->processDonorReturn( array( - 'authResult' => 'AUTHORISED', - 'merchantReference' => '55555.1', - 'merchantSig' => '/uzhDRZ3zSzFNLgBj4tI6pHYDynVQAqCeKcJWsXeWo0=', - 'paymentMethod' => 'visa', - 'pspReference' => '123987612346789', - 'shopperLocale' => 'fr_FR', - 'skinCode' => 'altskin', - 'title' => 'Special:AdyenGatewayResult' - ) ); - $this->assertFalse( $result->isFailed() ); - $this->assertEmpty( $result->getErrors() ); - } - - public function testDonorReturnFailure() { - $init = $this->getDonorTestData(); - $init['payment_method'] = 'cc'; - $init['payment_submethod'] = 'visa'; - $init['language'] = 'FR'; - $init['order_id'] = '55555'; - $session['Donor'] = $init; - $this->setUpRequest( $init, $session ); - $gateway = $this->getFreshGatewayObject( array() ); - $result = $gateway->processDonorReturn( array( - 'authResult' => 'REFUSED', - 'merchantReference' => '55555.1', - 'merchantSig' => 's8t3037BPcWl8niWHsrnwOXh+EqdPHmKyaLHYLf1tz4=', - 'paymentMethod' => 'visa', - 'pspReference' => '123987612346789', - 'shopperLocale' => 'fr_FR', - 'skinCode' => 'testskin', - 'title' => 'Special:AdyenGatewayResult' - ) ); - $this->assertTrue( $result->isFailed() ); - } - - /** - * Test that we choose the correct HMAC based on skinCode - */ - public function testSignatureAltSkin() { - $init = $this->getDonorTestData(); - $gateway = $this->getFreshGatewayObject( $init ); - $toSign = [ - 'allowedMethods' => 'card', - 'billingAddress.street' => $init['street_address'], - 'billingAddress.city' => $init['city'], - 'billingAddress.postalCode' => $init['postal_code'], - 'billingAddress.stateOrProvince' => $init['state_province'], - 'billingAddress.country' => $init['country'], - 'billingAddress.houseNumberOrName' => 'NA', - 'billingAddressType' => 2, - 'card.cardHolderName' => $init['first_name'] . ' ' . $init['last_name'], - 'currencyCode' => $init['currency'], - 'merchantAccount' => 'wikitest', - 'merchantReference' => 123456, - 'paymentAmount' => ( $init['amount'] ) * 100, - 'skinCode' => 'testskin', - 'shopperLocale' => 'fr_US', - 'shopperEmail' => '[email protected]', - 'offset' => '52', - ]; - $defaultSig = AdyenHostedSignature::calculateSignature( $gateway, $toSign ); - $toSign['skinCode'] = 'altskin'; - $altSig = AdyenHostedSignature::calculateSignature( $gateway, $toSign ); - $this->assertEquals( 'xoI76zyUFjjBzubzSPEopAgoA9Bt7PjwQAi5QHk/GKo=', $defaultSig ); - $this->assertEquals( 'UKMVUkWR5GqsgfUEtqZalzh+kTa7kXyrDw9nbj4D/0Q=', $altSig ); - } -} ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php deleted file mode 100644 index 68092ba..0000000 --- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php +++ /dev/null @@ -1,537 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -<?php -/** - * 'TIMESTAMP=2016%2d05%2d02T19%3a58%3a19Z&CORRELATIONID=b33e6ff7eba&ACK=Failure&VERSION=0%2e000000&BUILD=21669447&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Authentication%2fAuthorization%20Failed&L_LONGMESSAGE0=You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call&L_SEVERITYCODE0=Error' - * - * TOKEN=EC%2d1YM52022PV490383V&PHONENUM=408%2d123%2d4567&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2016%2d05%2d03T19%3a57%3a56Z&CORRELATIONID=c3811aeb1e7f5&ACK=Success&VERSION=124&BUILD=21669447&EMAIL=fr%2dtech%2bdonor%40wikimedia%2eorg&PAYERID=FLJLQ2GV38E4Y&PAYERSTATUS=verified&FIRSTNAME=f&LASTNAME=doner&COUNTRYCODE=US&ADDRESSSTATUS=Confirmed&CURRENCYCODE=JPY&AMT=500&ITEMAMT=500&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&CUSTOM=4116&DESC=Donation%20to%20the%20Wikimedia%20Foundation&INVNUM=4116%2e1&INSURANCEAMT=0&SHIPDISCAMT=0&INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_CURRENCYCODE=JPY&PAYMENTREQUEST_0_AMT=500&PAYMENTREQUEST_0_ITEMAMT=500&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_CUSTOM=4116&PAYMENTREQUEST_0_DESC=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_INVNUM=4116%2e1&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=fr%2dtech%2dfacilitator%40wikimedia%2eorg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&PAYMENTREQUESTINFO_0_ERRORCODE=0 - * - * TIMESTAMP=2016%2d05%2d03T21%3a43%3a20Z&CORRELATIONID=f624ed5aa5db0&ACK=Failure&VERSION=124&BUILD=21669447&L_ERRORCODE0=10412&L_SHORTMESSAGE0=Duplicate%20invoice&L_LONGMESSAGE0=Payment%20has%20already%20been%20made%20for%20this%20InvoiceID%2e&L_SEVERITYCODE0=Error - */ - -use Psr\Log\LogLevel; -use SmashPig\Core\DataStores\QueueWrapper; -use SmashPig\Tests\TestingContext; -use SmashPig\Tests\TestingProviderConfiguration; - -/** - * - * @group Fundraising - * @group DonationInterface - * @group PayPal - */ -class DonationInterface_Adapter_PayPal_Express_Test extends DonationInterfaceTestCase { - - protected $testAdapterClass = 'TestingPaypalExpressAdapter'; - - public function setUp() { - parent::setUp(); - TestingContext::get()->providerConfigurationOverride = TestingProviderConfiguration::createForProvider( - 'paypal', $this->smashPigGlobalConfig - ); - $this->setMwGlobals( array( - 'wgDonationInterfaceCancelPage' => 'https://example.com/tryAgain.php', - 'wgPaypalExpressGatewayEnabled' => true, - 'wgDonationInterfaceThankYouPage' => 'https://example.org/wiki/Thank_You', - ) ); - } - - function testPaymentSetup() { - $init = array( - 'amount' => 1.55, - 'currency' => 'USD', - 'payment_method' => 'paypal', - 'utm_source' => 'CD1234_FR', - 'utm_medium' => 'sitenotice', - 'country' => 'US', - 'contribution_tracking_id' => strval( mt_rand() ), - 'language' => 'fr', - ); - $gateway = $this->getFreshGatewayObject( $init ); - $gateway::setDummyGatewayResponseCode( 'OK' ); - $result = $gateway->doPayment(); - $gateway->logPending(); // GatewayPage or the API calls this for redirects - $this->assertEquals( - 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8US12345X1234567U', - $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' => '[email protected]', - '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 ); - $expected = array( - 'country' => 'US', - 'fee' => '0', - 'gateway' => 'paypal_ec', - 'gateway_txn_id' => null, - 'language' => 'fr', - 'contribution_tracking_id' => $init['contribution_tracking_id'], - 'order_id' => $init['contribution_tracking_id'] . '.1', - 'utm_source' => 'CD1234_FR..paypal', - 'currency' => 'USD', - 'email' => '', - 'gross' => '1.55', - 'recurring' => '', - 'response' => false, - 'utm_medium' => 'sitenotice', - 'payment_method' => 'paypal', - 'payment_submethod' => '', - 'gateway_session_id' => 'EC-8US12345X1234567U', - 'user_ip' => '127.0.0.1', - 'source_name' => 'DonationInterface', - 'source_type' => 'payments', - ); - $this->assertEquals( - $expected, - $message, - 'PayPal EC setup sending wrong pending message' - ); - } - - function testPaymentSetupRecurring() { - $init = array( - 'amount' => 1.55, - 'currency' => 'USD', - 'payment_method' => 'paypal', - 'utm_source' => 'CD1234_FR', - 'utm_medium' => 'sitenotice', - 'country' => 'US', - 'recurring' => '1', - 'contribution_tracking_id' => strval( mt_rand() ), - 'language' => 'fr', - ); - $gateway = $this->getFreshGatewayObject( $init ); - TestingPaypalExpressAdapter::setDummyGatewayResponseCode( 'OK' ); - $result = $gateway->doPayment(); - $gateway->logPending(); // GatewayPage or the API calls this for redirects - $this->assertEquals( - 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8US12345X1234567U', - $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' => '[email protected]', - '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 ); - $expected = array( - 'country' => 'US', - 'fee' => '0', - 'gateway' => 'paypal_ec', - 'gateway_txn_id' => null, - 'language' => 'fr', - 'contribution_tracking_id' => $init['contribution_tracking_id'], - 'order_id' => $init['contribution_tracking_id'] . '.1', - 'utm_source' => 'CD1234_FR..rpaypal', - 'currency' => 'USD', - 'email' => '', - 'gross' => '1.55', - 'recurring' => '1', - 'response' => false, - 'utm_medium' => 'sitenotice', - 'payment_method' => 'paypal', - 'payment_submethod' => '', - 'gateway_session_id' => 'EC-8US12345X1234567U', - 'user_ip' => '127.0.0.1', - 'source_name' => 'DonationInterface', - 'source_type' => 'payments', - ); - $this->assertEquals( - $expected, - $message, - 'PayPal EC setup sending wrong pending message' - ); - } - - /** - * Check that the adapter makes the correct calls for successful donations - * and sends a good queue message. - */ - function testProcessDonorReturn() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - TestingPaypalExpressAdapter::setDummyGatewayResponseCode( 'OK' ); - $gateway->processDonorReturn( array( - 'token' => 'EC%2d4V987654XA123456V', - 'PayerID' => 'ASDASD', - ) ); - - $message = QueueWrapper::getQueue( 'donations' )->pop(); - $this->assertNotNull( $message, 'Not sending a message to the donations queue' ); - self::unsetVariableFields( $message ); - $expected = array( - 'contribution_tracking_id' => $init['contribution_tracking_id'], - 'country' => 'US', - 'fee' => '0', - 'gateway' => 'paypal_ec', - 'gateway_txn_id' => '5EJ123456T987654S', - 'gateway_session_id' => 'EC-4V987654XA123456V', - 'language' => 'en', - 'order_id' => $init['contribution_tracking_id'] . '.1', - 'payment_method' => 'paypal', - 'payment_submethod' => '', - 'response' => false, - 'user_ip' => '127.0.0.1', - 'utm_source' => '..paypal', - 'city' => 'San Francisco', - 'currency' => 'USD', - 'email' => '[email protected]', - 'first_name' => 'Fezziwig', - 'gross' => '1.55', - 'last_name' => 'Fowl', - 'recurring' => '', - 'state_province' => 'CA', - 'street_address' => '123 Fake Street', - 'postal_code' => '94105', - 'source_name' => 'DonationInterface', - 'source_type' => 'payments', - ); - $this->assertEquals( $expected, $message ); - - $this->assertNull( - QueueWrapper::getQueue( 'donations' )->pop(), - 'Sending extra messages to donations queue!' - ); - } - - public function testProcessDonorReturnRecurring() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $init['recurring'] = '1'; - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - $gateway = $this->getFreshGatewayObject( $init ); - $gateway::setDummyGatewayResponseCode( 'Recurring-OK' ); - $gateway->processDonorReturn( array( - 'token' => 'EC%2d4V987654XA123456V', - 'PayerID' => 'ASDASD' - ) ); - - $message = QueueWrapper::getQueue( 'donations' )->pop(); - $this->assertNull( $message, 'Recurring should not send a message to the donations queue' ); - } - - /** - * Check that we send the donor back to paypal to try a different source - */ - function testProcessDonorReturnPaymentRetry() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - $gateway::setDummyGatewayResponseCode( '10486' ); - $result = $gateway->processDonorReturn( array( - 'token' => 'EC%2d2D123456D9876543U', - 'PayerID' => 'ASDASD' - ) ); - - $message = QueueWrapper::getQueue( 'donations' )->pop(); - $this->assertNull( $message, 'Should not queue a message' ); - $this->assertFalse( $result->isFailed() ); - $redirect = $result->getRedirect(); - $this->assertEquals( - 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2D123456D9876543U', - $redirect - ); - } - - /** - * Check that we don't send donors to the fail page for warnings - */ - function testProcessDonorReturnWarning() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - - $gateway = $this->getFreshGatewayObject( $init ); - $gateway::setDummyGatewayResponseCode( array( - 'OK', // For GetExpressCheckoutDetails - '11607' // For DoExpressCheckoutPayment - ) ); - $result = $gateway->processDonorReturn( array( - 'token' => 'EC%2d2D123456D9876543U', - 'PayerID' => 'ASDASD' - ) ); - - $this->assertFalse( $result->isFailed() ); - $message = QueueWrapper::getQueue( 'donations' )->pop(); - $this->assertNotNull( $message, 'Not sending a message to the donations queue' ); - self::unsetVariableFields( $message ); - $expected = array( - 'contribution_tracking_id' => $init['contribution_tracking_id'], - 'country' => 'US', - 'fee' => '0', - 'gateway' => 'paypal_ec', - 'gateway_txn_id' => '33N12345BB123456D', - 'gateway_session_id' => 'EC-4V987654XA123456V', - 'language' => 'en', - 'order_id' => $init['contribution_tracking_id'] . '.1', - 'payment_method' => 'paypal', - 'payment_submethod' => '', - 'response' => false, - 'user_ip' => '127.0.0.1', - 'utm_source' => '..paypal', - 'city' => 'San Francisco', - 'currency' => 'USD', - 'email' => '[email protected]', - 'first_name' => 'Fezziwig', - 'gross' => '1.55', - 'last_name' => 'Fowl', - 'recurring' => '', - 'state_province' => 'CA', - 'street_address' => '123 Fake Street', - 'postal_code' => '94105', - 'source_name' => 'DonationInterface', - 'source_type' => 'payments', - ); - $this->assertEquals( $expected, $message ); - - $this->assertNull( - QueueWrapper::getQueue( 'donations' )->pop(), - 'Sending extra messages to donations queue!' - ); - $matches = self::getLogMatches( - LogLevel::WARNING, '/Transaction succeeded with warning.*/' - ); - $this->assertNotEmpty( $matches ); - } - - public function testProcessDonorReturnRecurringRetry() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $init['recurring'] = '1'; - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - $gateway = $this->getFreshGatewayObject( $init ); - $gateway::setDummyGatewayResponseCode( '10486' ); - $result = $gateway->processDonorReturn( array( - 'token' => 'EC%2d2D123456D9876543U', - 'PayerID' => 'ASDASD' - ) ); - - $this->assertNull( - QueueWrapper::getQueue( 'donations' )->pop(), - 'Sending a spurious message to the donations queue!' - ); - $this->assertFalse( $result->isFailed() ); - $redirect = $result->getRedirect(); - $this->assertEquals( - 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2D123456D9876543U', - $redirect - ); - } - - /* - * Check that it does not call doPayment when status is PaymentNotInitiated - */ - public function testProcessDonorReturnPaymentActionCompleted() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $options = array( 'batch_mode' => true ); - $this->setUpRequest( $init, array( 'Donor' => $init ) ); - - $gateway = $this->getFreshGatewayObject( $init, $options ); - $gateway::setDummyGatewayResponseCode( 'Complete' ); - $gateway->processDonorReturn( array( - 'token' => 'EC%2d4V987654XA123456V', - 'PayerID' => 'ASDASD', - ) ); - - $this->assertEquals( FinalStatus::COMPLETE, $gateway->getFinalStatus(), 'Should have Final Status Complete' ); - $this->assertEquals( 1, count( $gateway->curled ), 'Should only call curl once' ); - $message = QueueWrapper::getQueue( 'donations' )->pop(); - $this->assertNull( $message, 'Should not queue a message' ); - } - - /** - * The result switcher should redirect the donor to the thank you page and mark the token as - * processed. - */ - public function testResultSwitcher() { - $init = $this->getDonorTestData( 'US' ); - TestingPaypalExpressAdapter::setDummyGatewayResponseCode( 'OK' ); - $init['contribution_tracking_id'] = '45931210'; - $init['gateway_session_id'] = mt_rand(); - $init['language'] = 'pt'; - $session = array( 'Donor' => $init ); - - $request = array( - 'token' => $init['gateway_session_id'], - 'PayerID' => 'ASdASDAS', - 'language' => $init['language'] // FIXME: mashing up request vars and other stuff in verifyFormOutput - ); - $assertNodes = array( - 'headers' => array( - 'Location' => function ( $location ) use ( $init ) { - // Do this after the real processing to avoid side effects - $gateway = $this->getFreshGatewayObject( $init ); - $url = ResultPages::getThankYouPage( $gateway ); - $this->assertEquals( $url, $location ); - } - ) - ); - - $this->verifyFormOutput( 'PaypalExpressGatewayResult', $request, $assertNodes, false, $session ); - $key = 'processed_request-' . $request['token']; - $processed = wfGetMainCache()->get( $key ); - $this->assertTrue( $processed ); - - // Make sure we logged the expected cURL attempts - $messages = self::getLogMatches( 'info', '/Preparing to send GetExpressCheckoutDetails transaction to Paypal Express Checkout/' ); - $this->assertNotEmpty( $messages ); - $messages = self::getLogMatches( 'info', '/Preparing to send DoExpressCheckoutPayment transaction to Paypal Express Checkout/' ); - $this->assertNotEmpty( $messages ); - } - - /** - * The result switcher should redirect the donor to the thank you page without - * re-processing the donation. - */ - public function testResultSwitcherRepeat() { - $init = $this->getDonorTestData( 'US' ); - $init['contribution_tracking_id'] = '45931210'; - $init['gateway_session_id'] = mt_rand(); - $init['language'] = 'pt'; - $session = array( - 'Donor' => $init - ); - - $key = 'processed_request-' . $init['gateway_session_id']; - wfGetMainCache()->add( $key, true, 100 ); - - $request = array( - 'token' => $init['gateway_session_id'], - 'PayerID' => 'ASdASDAS', - 'language' => $init['language'] // FIXME: mashing up request vars and other stuff in verifyFormOutput - ); - $assertNodes = array( - 'headers' => array( - 'Location' => function ( $location ) use ( $init ) { - // Do this after the real processing to avoid side effects - $gateway = $this->getFreshGatewayObject( $init ); - $url = ResultPages::getThankYouPage( $gateway ); - $this->assertEquals( $url, $location ); - } - ) - ); - - $this->verifyFormOutput( 'PaypalExpressGatewayResult', $request, $assertNodes, false, $session ); - - // We should not have logged any cURL attempts - $messages = self::getLogMatches( 'info', '/Preparing to send .*/' ); - $this->assertEmpty( $messages ); - } - - public function testShouldRectifyOrphan() { - $message = $this->createOrphan( array( 'gateway' => 'paypal', 'payment_method' => 'paypal' ) ); - $this->gatewayAdapter = $this->getFreshGatewayObject( $message ); - $result = $this->gatewayAdapter->shouldRectifyOrphan(); - $this->assertEquals( $result, true, 'shouldRectifyOrphan returning false.' ); - } - - /** - * We should take the country from the donor info response, and transform - * it into a real code if it's a PayPal bogon. - */ - public function testUnstageCountry() { - $init = $this->getDonorTestData( 'US' ); - TestingPaypalExpressAdapter::setDummyGatewayResponseCode( [ 'C2', 'OK' ] ); - $init['contribution_tracking_id'] = '45931210'; - $init['gateway_session_id'] = mt_rand(); - $init['language'] = 'pt'; - $session = array( 'Donor' => $init ); - - $request = array( - 'token' => $init['gateway_session_id'], - 'PayerID' => 'ASdASDAS', - 'language' => $init['language'] // FIXME: mashing up request vars and other stuff in verifyFormOutput - ); - $this->setUpRequest( $request, $session ); - $gateway = $this->getFreshGatewayObject( $init ); - $gateway->processDonorReturn( $request ); - $savedCountry = $gateway->getData_Unstaged_Escaped( 'country' ); - $this->assertEquals( 'CN', $savedCountry ); - } -} ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/DonationInterfaceTestCase.php b/tests/phpunit/DonationInterfaceTestCase.php deleted file mode 100644 index a076366..0000000 --- a/tests/phpunit/DonationInterfaceTestCase.php +++ /dev/null @@ -1,777 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -<?php -/** - * Wikimedia Foundation - * - * LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -use Psr\Log\LogLevel; -use SmashPig\Core\Context; -use SmashPig\Tests\TestingContext; -use SmashPig\Tests\TestingGlobalConfiguration; -use SmashPig\Tests\TestingProviderConfiguration; -use Wikimedia\TestingAccessWrapper; - -/** - * @group Fundraising - * @group QueueHandling - * @group ClassMethod - * @group ListenerAdapter - * - * @category UnitTesting - * @package Fundraising_QueueHandling - */ -abstract class DonationInterfaceTestCase extends MediaWikiTestCase { - - /** - * An array of the vars we expect to be set before people hit payments. - * @var array - */ - public static $initial_vars = array( - 'ffname' => 'testytest', - 'referrer' => 'www.yourmom.com', // please don't go there. - 'currency' => 'USD', - ); - - /** - * This will be set by a test method with the adapter object. - * - * @var GatewayAdapter $gatewayAdapter - */ - protected $gatewayAdapter; - - protected $testAdapterClass = TESTS_ADAPTER_DEFAULT; - protected $smashPigGlobalConfig; - - /** - * @param $name string The name of the test case - * @param $data array Any parameters read from a dataProvider - * @param $dataName string|int The name or index of the data set - */ - public function __construct( $name = null, array $data = array(), $dataName = '' ) { - // Just in case you got here without running the configuration... - global $wgDonationInterfaceTest; - $wgDonationInterfaceTest = true; - - parent::__construct( $name, $data, $dataName ); - } - - public static function resetTestingAdapters() { - $testing_adapters = array( - 'TestingAdyenAdapter', - 'TestingAmazonAdapter', - 'TestingAstroPayAdapter', - 'TestingGenericAdapter', - 'TestingGlobalCollectAdapter', - 'TestingGlobalCollectOrphanAdapter', - 'TestingPaypalExpressAdapter', - 'TestingPaypalLegacyAdapter', - ); - foreach ( $testing_adapters as $testing_adapter ) { - $testing_adapter::setDummyGatewayResponseCode( null ); - } - } - - protected function setUp() { - // TODO: Use SmashPig dependency injection instead. Also override - // SmashPig core logger. - DonationLoggerFactory::$overrideLogger = new TestingDonationLogger(); - // Replace real SmashPig context with test version that lets us - // override provider configurations that may be set in code - $this->smashPigGlobalConfig = TestingGlobalConfiguration::create(); - TestingContext::init( $this->smashPigGlobalConfig ); - Context::get()->setSourceType( 'payments' ); - Context::get()->setSourceName( 'DonationInterface' ); - parent::setUp(); - } - - protected function tearDown() { - self::resetAllEnv(); - parent::tearDown(); - } - - /** - * Set up a fake request with the given data. Returns the fake request. - * @param array $data - * @param array $session - * @return FauxRequest - */ - protected function setUpRequest( $data, $session = null ) { - RequestContext::resetMain(); - $request = new FauxRequest( $data, false, $session ); - RequestContext::getMain()->setRequest( $request ); - return $request; - } - - /** - * Set global language for the duration of the test - * - * @param string $language language code to force - */ - protected function setLanguage( $language ) { - RequestContext::getMain()->setLanguage( $language ); - // BackCompat - $this->setMwGlobals( 'wgLang', RequestContext::getMain()->getLanguage() ); - } - - /** - * @param string $provider - * @return TestingProviderConfiguration - */ - protected function setSmashPigProvider( $provider ) { - $providerConfig = TestingProviderConfiguration::createForProvider( - $provider, $this->smashPigGlobalConfig - ); - TestingContext::get()->providerConfigurationOverride = $providerConfig; - return $providerConfig; - } - - /** - * buildRequestXmlForGlobalCollect - * - * @todo - * - there are many cases to this that need to be developed. - * - Do not consider this a complete test! - * - * @covers GatewayAdapter::__construct - * @covers GatewayAdapter::setCurrentTransaction - * @covers GatewayAdapter::buildRequestXML - */ - public function buildRequestXmlForGlobalCollect( $optionsForTestData, $options ) { - global $wgDonationInterfaceTest; - - $wgDonationInterfaceTest = true; - - $this->setUpRequest( $options ); - $this->gatewayAdapter = new TestingGlobalCollectAdapter(); - - $this->gatewayAdapter->setCurrentTransaction( 'INSERT_ORDERWITHPAYMENT' ); - - $exposed = TestingAccessWrapper::newFromObject( $this->gatewayAdapter ); - $request = trim( $exposed->buildRequestXML() ); - - $this->setUpRequest( $options ); - $expected = $this->getExpectedXmlRequestForGlobalCollect( $optionsForTestData, $options ); - - $this->assertEquals( $expected, $request, 'The constructed XML for payment_method [' . $optionsForTestData['payment_method'] . '] and payment_submethod [' . $optionsForTestData['payment_submethod'] . '] does not match our expected request.' ); - } - - /** - * - * @param string $country The country we want the test user to be from. - * @return array Donor data to use - * @throws OutOfBoundsException when there is no data available for the requested country - */ - public static function getDonorTestData( $country = '' ) { - $donortestdata = array( - 'US' => array( // default - 'city' => 'San Francisco', - 'state_province' => 'CA', - 'postal_code' => '94105', - 'currency' => 'USD', - 'street_address' => '123 Fake Street', - 'first_name' => 'Firstname', - 'last_name' => 'Surname', - 'amount' => '1.55', - 'language' => 'en', - 'email' => '[email protected]', - ), - 'AU' => array( - 'state_province' => 'NSW', - 'currency' => 'AUD', - 'first_name' => 'Firstname', - 'last_name' => 'Surname', - 'amount' => '5.55', - 'language' => 'en', - 'email' => '[email protected]', - ), - 'ES' => array( - 'city' => 'Barcelona', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 Calle Fake', - 'first_name' => 'Nombre', - 'last_name' => 'Apellido', - 'amount' => '1.55', - 'language' => 'es', - ), - 'Catalonia' => array( - 'city' => 'Barcelona', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 Calle Fake', - 'first_name' => 'Nombre', - 'last_name' => 'Apellido', - 'amount' => '1.55', - 'language' => 'ca', - ), - 'NO' => array( - 'city' => 'Oslo', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 Fake Gate', - 'first_name' => 'Fornavn', - 'last_name' => 'Etternavn', - 'amount' => '1.55', - 'language' => 'no', - ), - 'FR' => array( - 'city' => 'Versailles', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 Rue Faux', - 'first_name' => 'Prénom', - 'last_name' => 'Nom', - 'amount' => '1.55', - 'language' => 'fr', - ), - // Fiji is configured as a snowflake to test special treatment for certain store IDs - 'FJ' => array( - 'city' => 'Suva', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 Fake Street', - 'first_name' => 'FirstName', - 'last_name' => 'LastName', - 'amount' => '1.55', - 'language' => 'en', - ), - 'NL' => array( - 'city' => 'Amsterdam', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 nep straat', - 'first_name' => 'Voornaam', - 'last_name' => 'Achternaam', - 'amount' => '1.55', - 'language' => 'nl', - ), - 'BE' => array( - 'city' => 'Antwerp', - 'state_province' => 'XX', - 'postal_code' => '0', - 'currency' => 'EUR', - 'street_address' => '123 nep straat', - 'first_name' => 'Voornaam', - 'last_name' => 'Achternaam', - 'amount' => '1.55', - 'language' => 'nl', - ), - 'IT' => array( - 'city' => 'Torino', - 'state_province' => 'TO', - 'postal_code' => '10123', - 'currency' => 'EUR', - 'street_address' => 'Via Falso 123', - 'first_name' => 'Nome', - 'last_name' => 'Cognome', - 'amount' => '1.55', - 'language' => 'it', - ), - 'CA' => array( - 'city' => 'Saskatoon', - 'state_province' => 'SK', - 'postal_code' => 'S7K 0J5', - 'currency' => 'CAD', - 'street_address' => '123 Fake Street', - 'first_name' => 'Firstname', - 'last_name' => 'Surname', - 'amount' => '1.55', - 'language' => 'en', - ), - 'BR' => array( - 'currency' => 'BRL', - 'fiscal_number' => '00003456789', - 'payment_submethod' => 'test_bank', - 'first_name' => 'Nome', - 'last_name' => 'Apelido', - 'amount' => '100', - 'language' => 'pt', - 'email' => '[email protected]' - ), - 'MX' => array( - 'city' => 'Tuxtla Gutiérrez', - 'state_province' => 'CHP', - 'currency' => 'MXN', - 'street_address' => 'Calle Falso 123', - 'first_name' => 'Nombre', - 'last_name' => 'Apellido', - 'email' => '[email protected]', - 'amount' => '155', - 'language' => 'es', - ), - ); - // default to US - if ( $country === '' ) { - $country = 'US'; - } - - if ( array_key_exists( $country, $donortestdata ) ) { - $donortestdata = array_merge( self::$initial_vars, $donortestdata[$country] ); - $donortestdata['country'] = $country; - $donortestdata['processor_form'] = 'testskin'; - return $donortestdata; - } - throw new OutOfBoundsException( __FUNCTION__ . ": No donor data for country '$country'" ); - } - - /** - * Supported languages for Belgium - */ - public function belgiumLanguageProvider() { - return array( - array( 'nl' ), - array( 'de' ), - array( 'fr' ), - ); - } - - /** - * Supported languages for Canada - */ - public function canadaLanguageProvider() { - return array( - array( 'en' ), - array( 'fr' ), - ); - } - - /** - * Transaction codes for GC and GC orphan adapters not to be retried - * on pain of $1000+ fines by Mastercard - */ - public function mcNoRetryCodeProvider() { - return array( - array( '430260' ), - array( '430306' ), - array( '430330' ), - array( '430354' ), - array( '430357' ), - ); - } - - public function benignNoRetryCodeProvider() { - return array( - array( '430285' ), - ); - } - - /** - * Get the expected XML request from GlobalCollect - * - * @param $optionsForTestData - * @param array $options - * @return string The expected XML request - */ - public function getExpectedXmlRequestForGlobalCollect( $optionsForTestData, $options = array() ) { - global $wgDonationInterfaceThankYouPage; - $request = RequestContext::getMain()->getRequest(); - - $orderId = $this->gatewayAdapter->getData_Unstaged_Escaped( 'order_id' ); - $exposed = TestingAccessWrapper::newFromObject( $this->gatewayAdapter ); - $merchantref = $exposed->getData_Staged( 'contribution_tracking_id' ); - // @TODO: WHY IN THE NAME OF ZARQUON are we building XML in a STRING format here?!?!?!!!1one1!?. Great galloping galumphing giraffes. - $expected = '<?xml version="1.0" encoding="UTF-8"?' . ">\n"; - $expected .= '<XML>'; - $expected .= '<REQUEST>'; - $expected .= '<ACTION>INSERT_ORDERWITHPAYMENT</ACTION>'; - $expected .= '<META><MERCHANTID>' . $exposed->account_config[ 'MerchantID' ] . '</MERCHANTID>'; - - if ( isset( $request ) ) { - $expected .= '<IPADDRESS>' . $request->getIP() . '</IPADDRESS>'; - } - - $expected .= '<VERSION>1.0</VERSION>'; - $expected .= '</META>'; - $expected .= '<PARAMS>'; - $expected .= '<ORDER>'; - $expected .= '<ORDERID>' . $orderId . '</ORDERID>'; - $expected .= '<AMOUNT>' . $options['amount'] * 100 . '</AMOUNT>'; - $expected .= '<CURRENCYCODE>' . $options['currency'] . '</CURRENCYCODE>'; - $expected .= '<LANGUAGECODE>' . $options['language'] . '</LANGUAGECODE>'; - $expected .= '<COUNTRYCODE>' . $options['country'] . '</COUNTRYCODE>'; - $expected .= '<MERCHANTREFERENCE>' . $merchantref . '</MERCHANTREFERENCE>'; - - if ( isset( $request ) ) { - $expected .= '<IPADDRESSCUSTOMER>' . $request->getIP() . '</IPADDRESSCUSTOMER>'; - } - - $expected .= '<EMAIL>' . TESTS_EMAIL . '</EMAIL>'; - $expected .= '</ORDER>'; - $expected .= '<PAYMENT>'; - $expected .= '<PAYMENTPRODUCTID>' . $optionsForTestData['payment_product_id'] . '</PAYMENTPRODUCTID>'; - $expected .= '<AMOUNT>' . $options['amount'] * 100 . '</AMOUNT>'; - $expected .= '<CURRENCYCODE>' . $options['currency'] . '</CURRENCYCODE>'; - $expected .= '<LANGUAGECODE>' . $options['language'] . '</LANGUAGECODE>'; - $expected .= '<COUNTRYCODE>' . $options['country'] . '</COUNTRYCODE>'; - $expected .= '<HOSTEDINDICATOR>1</HOSTEDINDICATOR>'; - $expected .= "<RETURNURL>{$wgDonationInterfaceThankYouPage}/{$options['language']}?country={$options['country']}</RETURNURL>"; - $expected .= '<AUTHENTICATIONINDICATOR>0</AUTHENTICATIONINDICATOR>'; - $expected .= '<FIRSTNAME>' . $options['first_name'] . '</FIRSTNAME>'; - $expected .= '<SURNAME>' . $options['last_name'] . '</SURNAME>'; - $expected .= '<STREET>' . $options['street_address'] . '</STREET>'; - $expected .= '<CITY>' . $options['city'] . '</CITY>'; - $expected .= '<STATE>' . $options['state_province'] . '</STATE>'; - $expected .= '<ZIP>' . $options['postal_code'] . '</ZIP>'; - $expected .= '<EMAIL>' . TESTS_EMAIL . '</EMAIL>'; - - // Set the issuer id if it is passed. - if ( isset( $optionsForTestData['descriptor'] ) ) { - $expected .= '<DESCRIPTOR>' . $optionsForTestData['descriptor'] . '</DESCRIPTOR>'; - } - - // Set the issuer id if it is passed. - if ( isset( $optionsForTestData['issuer_id'] ) ) { - $expected .= '<ISSUERID>' . $optionsForTestData['issuer_id'] . '</ISSUERID>'; - } - - // If we're doing Direct Debit... - // @TODO: go ahead and split this out into a "Get the direct debit I_OWP XML block function" the second this gets even slightly annoying. - if ( $optionsForTestData['payment_method'] === 'dd' ) { - $expected .= '<ACCOUNTNAME>' . $optionsForTestData['account_name'] . '</ACCOUNTNAME>'; - $expected .= '<ACCOUNTNUMBER>' . $optionsForTestData['account_number'] . '</ACCOUNTNUMBER>'; - $expected .= '<BANKCODE>' . $optionsForTestData['bank_code'] . '</BANKCODE>'; - $expected .= '<BRANCHCODE>' . $optionsForTestData['branch_code'] . '</BRANCHCODE>'; - $expected .= '<BANKCHECKDIGIT>' . $optionsForTestData['bank_check_digit'] . '</BANKCHECKDIGIT>'; - $expected .= '<DATECOLLECT>' . gmdate( 'Ymd' ) . '</DATECOLLECT>'; // is this cheating? Probably. - $expected .= '<DIRECTDEBITTEXT>' . $optionsForTestData['direct_debit_text'] . '</DIRECTDEBITTEXT>'; - } - - $expected .= '</PAYMENT>'; - $expected .= '</PARAMS>'; - $expected .= '</REQUEST>'; - $expected .= '</XML>'; - - return $expected; - } - - /** - * Get a fresh gateway object of the type specified in the variable - * $this->testAdapterClass. - * @param array $external_data If you want to shoehorn in some external - * data, do that here. - * @param array $setup_hacks An array of things that override stuff in - * the constructor of the gateway object that I can't get to without - * refactoring the whole thing. @TODO: Refactor the gateway adapter - * constructor. - * @return GatewayAdapter The new relevant gateway adapter object. - */ - function getFreshGatewayObject( $external_data = null, $setup_hacks = array() ) { - $data = null; - if ( !is_null( $external_data ) ) { - $data = array( - 'external_data' => $external_data, - ); - } - - if ( $setup_hacks ) { - if ( !is_null( $data ) ) { - $data = array_merge( $data, $setup_hacks ); - } else { - $data = $setup_hacks; - } - } - - $class = $this->testAdapterClass; - $gateway = new $class( $data ); - - $classReflection = new ReflectionClass( $gateway ); - - // FIXME: Find a more elegant way to hackity hacken hack. - // We want to override any define- functions with hacky values. - foreach ( $setup_hacks as $field => $value ) { - if ( property_exists( $class, $field ) ) { - $propertyReflection = $classReflection->getProperty( $field ); - $propertyReflection->setAccessible( true ); - $propertyReflection->setValue( $gateway, $value ); - } - } - - return $gateway; - } - - public static function resetAllEnv() { - $_SESSION = array(); - $_GET = array(); - $_POST = array(); - - $_SERVER = array(); - $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; - $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME; - $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; - $_SERVER['SCRIPT_NAME'] = __FILE__; - - RequestContext::resetMain(); - - self::resetTestingAdapters(); - // Wipe out the $instance of these classes to make sure they're - // re-created with fresh gateway instances for the next test - $singleton_classes = array( - 'Gateway_Extras_ConversionLog', - 'Gateway_Extras_CustomFilters', - 'Gateway_Extras_CustomFilters_Functions', - 'Gateway_Extras_CustomFilters_IP_Velocity', - 'Gateway_Extras_CustomFilters_MinFraud', - 'Gateway_Extras_CustomFilters_Referrer', - 'Gateway_Extras_CustomFilters_Source', - 'Gateway_Extras_SessionVelocityFilter', - ); - foreach ( $singleton_classes as $singleton_class ) { - $unwrapped = TestingAccessWrapper::newFromClass( $singleton_class ); - $unwrapped->instance = null; - } - // Reset SmashPig context - Context::set( null ); - // Clear out our HashBagOStuff, used for testing - wfGetMainCache()->clear(); - DonationLoggerFactory::$overrideLogger = null; - } - - /** - * Instantiates the $special_page_class with supplied $initial_vars, - * yoinks the html output from the output buffer, loads that into a - * DomDocument and performs asserts on the results per the checks - * supplied in $perform_these_checks. - * Optional: Asserts that the gateway has logged nothing at ERROR level. - * - * @param string $special_page_class A testing descendant of GatewayPage - * @param array $initial_vars Array that will be loaded straight into a - * test version of the http request. - * @param array $perform_these_checks Array of checks to perform in the - * following format: - * $perform_these_checks[$element_id][$check_to_perform][$expected_result] - * So far, $check_to_perform can be either 'nodename' or 'innerhtml' - * @param bool $fail_on_log_errors When true, this will fail the current test if there are entries in the gateway's error log. - * @param array $session pre-existing session data. - */ - function verifyFormOutput( $special_page_class, $initial_vars, $perform_these_checks, $fail_on_log_errors = false, $session = null ) { - // Nasty hack to clear output from any previous tests. - $mainContext = RequestContext::getMain(); - $newOutput = new OutputPage( $mainContext ); - $newRequest = new TestingRequest( $initial_vars, false, $session ); - $newTitle = Title::newFromText( 'nonsense is apparently fine' ); - $mainContext->setRequest( $newRequest ); - $mainContext->setOutput( $newOutput ); - $mainContext->setTitle( $newTitle ); - - $globals = array( - 'wgTitle' => $newTitle, - 'wgOut' => $newOutput, - ); - - $this->setMwGlobals( $globals ); - - $this->setLanguage( $initial_vars['language'] ); - - ob_start(); - $formpage = new $special_page_class(); - $formpage->execute( null ); - $formpage->getOutput()->output(); - $form_html = ob_get_contents(); - ob_end_clean(); - - // In the event that something goes crazy, uncomment the next line for much easier local debugging - // file_put_contents( '/tmp/xmlout.txt', $form_html ); - - if ( $fail_on_log_errors ) { - $this->verifyNoLogErrors(); - } - - $dom_thingy = new DomDocument(); - //// DEBUGGING, foo - // if (property_exists($this, 'FOO')) { - // error_log(var_export($formpage->getRequest()->response()->getheader('Location'), true)); - // error_log(var_export($form_html, true)); - // } - - if ( $form_html ) { - // p.s. i'm SERIOUS about the character encoding. - $dom_thingy->loadHTML( '<?xml encoding="UTF-8">' . $form_html ); - $dom_thingy->encoding = 'UTF-8'; - } - - foreach ( $perform_these_checks as $id => $checks ) { - if ( $id == 'headers' ) { - foreach ( $checks as $name => $expected ) { - $actual = $formpage->getRequest()->response()->getheader( $name ); - $this->performCheck( $actual, $expected, "header '$name'" ); - break; - } - continue; - } - unset( $perform_these_checks['headers'] ); - - $input_node = $dom_thingy->getElementById( $id ); - $this->assertNotNull( $input_node, "Couldn't find the '$id' element in html. Log entries: \n" . - print_r( DonationLoggerFactory::$overrideLogger->messages, true ) . "\n\nHTML:\n$form_html" ); - foreach ( $checks as $name => $expected ) { - switch ( $name ) { - case 'nodename': - $this->performCheck( $input_node->nodeName, $expected, "name of node with id '$id'" ); - break; - case 'innerhtml': - $actual_html = self::getInnerHTML( $input_node ); - // Strip comments - $actual_html = preg_replace( '/<!--[^>]*-->/', '', $actual_html ); - $this->performCheck( $actual_html, $expected, "innerHTML of node '$id'" ); - break; - case 'innerhtmlmatches': - $this->assertEquals( 1, preg_match( $expected, self::getInnerHTML( $input_node ) ), "Value of the node with id '$id' does not match pattern '$expected'. It has value " . self::getInnerHTML( $input_node ) ); - break; - case 'value': - $this->performCheck( $input_node->getAttribute( 'value' ), $expected, "value of node with id '$id'" ); - break; - case 'selected': - $selected = null; - if ( $input_node->nodeName === 'select' ) { - $options = $input_node->getElementsByTagName( 'option' ); - foreach ( $options as $option ) { - if ( $option->hasAttribute( 'selected' ) ) { - $selected = $option->getAttribute( 'value' ); - break; - } - } - $this->performCheck( $selected, $expected, "selected option value of node with id '$id'" ); - } else { - $this->fail( "Attempted to test for selected value on non-select node, id '$id'" ); - } - break; - } - } - } - - // Are there untranslated boogers? - if ( preg_match_all( '/<[^<]+(>|>)/', $form_html, $matches ) ) { - $this->fail( 'Untranslated messages present: ' . implode( ', ', $matches[0] ) ); - } - } - - /** - * Performs some sort of assertion on a value. - * - * @param string $value the value to test - * @param string|callable $check - * if $check is callable, it is called with argument $value - * otherwise, $value is asserted to be equal to $check - * @param string $label identifies the value in assertion failures - * @return void - */ - function performCheck( $value, $check, $label = 'Tested value' ) { - if ( is_callable( $check ) ) { - $check( $value ); - return; - } - $this->assertEquals( $check, $value, "Expected $label to be $check, found $value instead." ); - } - /** - * Asserts that there are no log entries of LOG_ERR or worse. - */ - function verifyNoLogErrors() { - $log = DonationLoggerFactory::$overrideLogger->messages; - - $this->assertTrue( is_array( $log ), "Missing the test log" ); - - // for our purposes, an "error" is LOG_ERR or less. - $checklogs = array( - LogLevel::ERROR => "Oops: We've got LOG_ERRors.", - LogLevel::CRITICAL => "Critical errors!", - LogLevel::ALERT => "Log Alerts!", - LogLevel::EMERGENCY => "Logs says the servers are actually on fire.", - ); - - $message = false; - foreach ( $checklogs as $level => $levelmessage ) { - if ( array_key_exists( $level, $log ) ) { - $message = $levelmessage . ' ' . print_r( $log[$level], true ) . "\n"; - } - } - - $this->assertFalse( $message, $message ); // ha - } - - /** - * Finds a relevant line/lines in a gateway's log array - * @param string $log_level One of the constants in \Psr\Log\LogLevel - * @param string $match A regex to match against the log lines. - * @return array All log lines that match $match. - * FIXME: Or false. Return an empty array or throw an exception instead. - */ - public static function getLogMatches( $log_level, $match ) { - $log = DonationLoggerFactory::$overrideLogger->messages; - if ( !array_key_exists( $log_level, $log ) ) { - return false; - } - $return = array(); - foreach ( $log[$log_level] as $line ) { - if ( preg_match( $match, $line ) ) { - $return[] = $line; - } - } - return $return; - } - - static function getInnerHTML( $node ) { - $innerHTML = ''; - $children = $node->childNodes; - foreach ( $children as $child ) { - $innerHTML .= $child->ownerDocument->saveXML( $child ); - } - return $innerHTML; - } - - public static function unsetVariableFields( &$message ) { - $fields = array( - 'date', 'source_enqueued_time', 'source_host', 'source_run_id', 'source_version', 'gateway_account' - ); - foreach ( $fields as $field ) { - unset( $message[$field] ); - } - } - - /** - * Create an orphaned tranaction. - * - * TODO: Reuse SmashPigBaseTest#createMessage - */ - public function createOrphan( $overrides = array() ) { - $uniq = mt_rand(); - $message = $overrides + array( - 'contribution_tracking_id' => $uniq, - 'country' => 'US', - 'first_name' => 'Flighty', - 'last_name' => 'Dono', - 'email' => '[email protected]', - 'gateway' => 'globalcollect', - 'gateway_txn_id' => "txn-{$uniq}", - 'order_id' => "order-{$uniq}", - 'gateway_account' => 'default', - 'payment_method' => 'cc', - 'payment_submethod' => 'mc', - // Defaults to a magic 25 minutes ago, within the process window. - 'date' => time() - 25 * 60, - 'gross' => 123, - 'currency' => 'EUR', - ); - return $message; - } - -} ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/TestConfiguration.php b/tests/phpunit/TestConfiguration.php deleted file mode 100644 index 1ce39c5..0000000 --- a/tests/phpunit/TestConfiguration.php +++ /dev/null @@ -1,260 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -<?php -/** - * Wikimedia Foundation - * - * LICENSE - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This file contains custom options and constants for test configuration. - */ - -/** - * TESTS_MESSAGE_NOT_IMPLEMENTED - * - * Message for code that has not been implemented. - */ -define( 'TESTS_MESSAGE_NOT_IMPLEMENTED', 'Not implemented yet!' ); - -/** - * TESTS_HOSTNAME - * - * The hostname for the system - */ -define( 'TESTS_HOSTNAME', 'localhost' ); - -/** - * TESTS_EMAIL - * - * An email address to use in case test send mail - */ -define( 'TESTS_EMAIL', '[email protected]' ); - -/** - * TESTS_GATEWAY_DEFAULT - * - * This is the default gateway that will be used to implement unit tests. - */ -define( 'TESTS_GATEWAY_DEFAULT', 'GlobalCollectGateway' ); - -/** - * TESTS_ADAPTER_DEFAULT - * - * This is the default adapter that will be used to implement unit tests. - */ -define( 'TESTS_ADAPTER_DEFAULT', 'TestingGlobalCollectAdapter' ); - -global $wgDonationInterfaceTest, - $wgDonationInterfaceMerchantID, - $wgDonationInterfaceGatewayAdapters, - $wgDonationInterfaceAllowedHtmlForms, - $wgDonationInterfaceThankYouPage, - $wgGlobalCollectGatewayAccountInfo, - $wgPaypalGatewayAccountInfo, - $wgPaypalGatewayReturnURL, - $wgPaypalExpressGatewayURL, - $wgPaypalExpressGatewayTestingURL, - $wgPaypalExpressGatewaySignatureURL, - $wgPaypalExpressGatewayAccountInfo, - $wgAmazonGatewayReturnURL, - $wgAmazonGatewayAccountInfo, - $wgAdyenGatewayURL, - $wgAdyenGatewayAccountInfo, - $wgAstroPayGatewayURL, - $wgAstroPayGatewayTestingURL, - $wgAstroPayGatewayAccountInfo, - $wgAstroPayGatewayFallbackCurrency, - $wgDonationInterfaceMinFraudUserId, - $wgDonationInterfaceMinFraudLicenseKey, - $wgDonationInterfaceMinFraudClientOptions, - $wgDonationInterfaceEnableMinFraud, - $wgDonationInterfaceEnableFunctionsFilter, - $wgDonationInterfaceEnableReferrerFilter, - $wgDonationInterfaceEnableSourceFilter, - $wgDonationInterfaceCustomFiltersActionRanges, - $wgDonationInterfaceCustomFiltersRefRules, - $wgDonationInterfaceCustomFiltersSrcRules, - $wgDonationInterfaceCustomFiltersFunctions, - $wgGlobalCollectGatewayCustomFiltersFunctions, - $wgIngenicoGatewayCustomFiltersFunctions, - $wgDonationInterfaceCountryMap, - $wgDonationInterfaceUtmCampaignMap, - $wgDonationInterfaceUtmSourceMap, - $wgDonationInterfaceUtmMediumMap, - $wgDonationInterfaceEmailDomainMap, - $wgMainCacheType; - -$wgMainCacheType = 'hash'; - -$wgDonationInterfaceGatewayAdapters = array( - 'globalcollect' => 'TestingGlobalCollectAdapter', - 'ingenico' => 'IngenicoAdapter', - 'amazon' => 'TestingAmazonAdapter', - 'adyen' => 'TestingAdyenAdapter', - 'astropay' => 'TestingAstroPayAdapter', - 'paypal_ec' => 'TestingPaypalExpressAdapter', - 'paypal' => 'TestingPaypalLegacyAdapter' -); -/** - * Make sure the test setup is used, else we'll have the wrong classes. - */ -/** DonationInterface General Settings **/ -$wgDonationInterfaceTest = true; -$wgDonationInterfaceMerchantID = 'test'; - -$wgDonationInterfaceThankYouPage = 'https://wikimediafoundation.org/wiki/Thank_You'; - -/** GlobalCollect **/ -$wgGlobalCollectGatewayAccountInfo = array(); -$wgGlobalCollectGatewayAccountInfo['test'] = array( - 'MerchantID' => 'test', -); - -/** Paypal **/ -$wgPaypalGatewayAccountInfo = array(); -$wgPaypalGatewayAccountInfo['testing'] = array( - 'AccountEmail' => '[email protected]', -); -$wgPaypalGatewayReturnURL = 'http://donate.wikimedia.org'; // whatever, doesn't matter. - -/** Paypal Express Checkout **/ -$wgPaypalExpressGatewayURL = 'https://api-3t.sandbox.paypal.com/nvp'; -$wgPaypalExpressGatewayTestingURL = 'https://api-3t.sandbox.paypal.com/nvp'; -$wgPaypalExpressGatewaySignatureURL = $wgPaypalExpressGatewayURL; -$wgPaypalExpressGatewayAccountInfo['test'] = array( - 'User' => '[email protected]', - 'Password' => '9876543210', - 'Signature' => 'ABCDEFGHIJKLMNOPQRSTUV-ZXCVBNMLKJHGFDSAPOIUYTREWQ', - 'RedirectURL' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=', -); - -/** Amazon **/ -$wgAmazonGatewayReturnURL = 'https://payments.wikimedia.org/index.php/Special:AmazonGateway'; -$wgAmazonGatewayAccountInfo = array(); -$wgAmazonGatewayAccountInfo['test'] = array( - 'SellerID' => 'ABCDEFGHIJKL', - 'ClientID' => 'amzn1.application-oa2-client.1a2b3c4d5e', - 'ClientSecret' => '12432g134e3421a41234b1341c324123d', - 'MWSAccessKey' => 'N0NSENSEXYZ', - 'MWSSecretKey' => 'iuasd/2jhaslk2j49lkaALksdJLsJLas+', - 'Region' => 'us', - 'WidgetScriptURL' => - 'https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js', - 'ReturnURL' => "https://example.org/index.php/Special:AmazonGateway?debug=true", -); - -/** Adyen **/ -$wgAdyenGatewayURL = 'https://testorwhatever.adyen.com'; -$wgAdyenGatewayAccountInfo = array(); -$wgAdyenGatewayAccountInfo['test'] = array( - 'AccountName' => 'wikitest', - 'Skins' => [ - 'testskin' => [ - 'SharedSecret' => 'C7F1D9E29479CF18131063A742CD2703FB9D48BAB0160693045E3FB7B8508E59', - 'Name' => 'base', - ], - 'altskin' => [ - 'SharedSecret' => 'A78B329F29872E21291063A742CD2703FB9D48BAB01606930421291063A742CD', - 'Name' => 'redirect', - ] - ], -); - -/** AstroPay **/ -$wgAstroPayGatewayURL = 'https://astropay.example.com/'; -$wgAstroPayGatewayTestingURL = 'https://sandbox.astropay.example.com/'; -$wgAstroPayGatewayAccountInfo = array(); -$wgAstroPayGatewayAccountInfo['test'] = array( - 'Create' => array( - 'Login' => 'createlogin', - 'Password' => 'createpass', - ), - 'Status' => array( - 'Login' => 'statuslogin', - 'Password' => 'statuspass', - ), - 'SecretKey' => 'NanananananananananananananananaBatman', -); -$wgAstroPayGatewayFallbackCurrency = false; - -$wgDonationInterfaceMinFraudUserId = 1; -$wgDonationInterfaceMinFraudLicenseKey = 'testkey'; - -$wgDonationInterfaceMinFraudClientOptions = array( - 'host' => 'minfraud.wikimedia.org', -); - -// still can't quite handle minFraud by itself yet, so default like this. -// I will turn it on for individual tests in which I want to verify that it at -// least fails closed when enabled. -$wgDonationInterfaceEnableMinFraud = false; - -// ...but we want these. -$wgDonationInterfaceEnableFunctionsFilter = true; -$wgDonationInterfaceEnableReferrerFilter = true; -$wgDonationInterfaceEnableSourceFilter = true; - -$customFilters = array( - 'getScoreCountryMap' => 50, - 'getScoreUtmCampaignMap' => 50, - 'getScoreUtmSourceMap' => 15, - 'getScoreUtmMediumMap' => 15, - 'getScoreEmailDomainMap' => 75, -); - -$wgDonationInterfaceCustomFiltersActionRanges = array( - 'process' => array( 0, 25 ), - 'review' => array( 25, 50 ), - 'challenge' => array( 50, 75 ), - 'reject' => array( 75, 100 ), -); - -$wgDonationInterfaceCustomFiltersRefRules = array( - '/donate-error/i' => 5, -); - -$wgDonationInterfaceCustomFiltersSrcRules = array( '/wikimedia\.org/i' => 80 ); - -$wgDonationInterfaceCustomFiltersFunctions = $customFilters; - -$wgGlobalCollectGatewayCustomFiltersFunctions = array( - 'getCVVResult' => 20, - 'getAVSResult' => 25, -) + $customFilters; - -$wgIngenicoGatewayCustomFiltersFunctions = $wgGlobalCollectGatewayCustomFiltersFunctions; - -$wgDonationInterfaceCountryMap = array( - 'US' => 40, - 'CA' => 15, - 'RU' => -4, -); - -$wgDonationInterfaceUtmCampaignMap = array( - '/^(C14_)/' => 14, - '/^(spontaneous)/' => 5 -); - -$wgDonationInterfaceUtmSourceMap = array( - '/somethingmedia/' => 70 -); - -$wgDonationInterfaceUtmMediumMap = array( - '/somethingmedia/' => 80 -); - -$wgDonationInterfaceEmailDomainMap = array( - 'wikimedia.org' => 42, - 'wikipedia.org' => 50, -); ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_10486.testresponse b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_10486.testresponse deleted file mode 100644 index 8358957..0000000 --- a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_10486.testresponse +++ /dev/null @@ -1,4 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -TOKEN=EC%2d2D123456D9876543U&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2017%2d02%2d01T20%3a07%3a14Z&CORRELATIONID=d70c9a334455e&ACK=Success&VERSION=204&BUILD=28806785&EMAIL=donor%40generous%2enet&PAYERID=8R297FE87CD8S&PAYERSTATUS=unverified&FIRSTNAME=Fezziwig&LASTNAME=Fowl&COUNTRYCODE=US&BILLINGNAME=Fezziwig%20Fowl&STREET=123%20Notta%20Way&CITY=Whoville&STATE=OR&ZIP=97211&COUNTRY=US&COUNTRYNAME=United%20States&ADDRESSID=PayPal&ADDRESSSTATUS=Confirmed&CURRENCYCODE=USD&AMT=1%2e55&ITEMAMT=1%2e55&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&CUSTOM=45931210&DESC=Donation%20to%20the%20Wikimedia%20Foundation&INVNUM=45931210%2e1&NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&INSURANCEAMT=0&SHIPDISCAMT=0&INSURANCEOPTIONOFFERED=false&L_QTY0=1&L_TAXAMT0=0&L_AMT0=1%2e55&L_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=1%2e55&PAYMENTREQUEST_0_ITEMAMT=1%2e55&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_CUSTOM=45931210&PAYMENTREQUEST_0_DESC=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_INVNUM=45931210%2e1&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=receiver%40wikimedia%2eorg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_TAXAMT0=0&L_PAYMENTREQUEST_0_AMT0=1%2e55&L_PAYMENTREQUEST_0_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUESTINFO_0_ERRORCODE=0 ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_C2.testresponse b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_C2.testresponse deleted file mode 100644 index aa778bb..0000000 --- a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_C2.testresponse +++ /dev/null @@ -1,4 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -TOKEN=EC%2d4V987654XA123456V&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2017%2d02%2d01T20%3a07%3a14Z&CORRELATIONID=d70c9a334455e&ACK=Success&VERSION=204&BUILD=28806785&EMAIL=donor%40generous%2enet&PAYERID=8R297FE87CD8S&PAYERSTATUS=unverified&FIRSTNAME=Fezziwig&LASTNAME=Fowl&COUNTRYCODE=C2&BILLINGNAME=Fezziwig%20Fowl&STREET=123%20Notta%20Way&CITY=Whoville&STATE=OR&ZIP=97211&COUNTRY=US&COUNTRYNAME=United%20States&ADDRESSID=PayPal&ADDRESSSTATUS=Confirmed&CURRENCYCODE=USD&AMT=1%2e55&ITEMAMT=1%2e55&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&CUSTOM=45931210&DESC=Donation%20to%20the%20Wikimedia%20Foundation&INVNUM=45931210%2e1&NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&INSURANCEAMT=0&SHIPDISCAMT=0&INSURANCEOPTIONOFFERED=false&L_QTY0=1&L_TAXAMT0=0&L_AMT0=1%2e55&L_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=1%2e55&PAYMENTREQUEST_0_ITEMAMT=1%2e55&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_CUSTOM=45931210&PAYMENTREQUEST_0_DESC=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_INVNUM=45931210%2e1&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=receiver%40wikimedia%2eorg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_TAXAMT0=0&L_PAYMENTREQUEST_0_AMT0=1%2e55&L_PAYMENTREQUEST_0_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUESTINFO_0_ERRORCODE=0 ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_OK.testresponse b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_OK.testresponse deleted file mode 100644 index 62bbdac..0000000 --- a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_OK.testresponse +++ /dev/null @@ -1,4 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -TOKEN=EC%2d4V987654XA123456V&BILLINGAGREEMENTACCEPTEDSTATUS=0&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2017%2d02%2d01T20%3a07%3a14Z&CORRELATIONID=d70c9a334455e&ACK=Success&VERSION=204&BUILD=28806785&EMAIL=donor%40generous%2enet&PAYERID=8R297FE87CD8S&PAYERSTATUS=unverified&FIRSTNAME=Fezziwig&LASTNAME=Fowl&COUNTRYCODE=US&BILLINGNAME=Fezziwig%20Fowl&STREET=123%20Notta%20Way&CITY=Whoville&STATE=OR&ZIP=97211&COUNTRY=US&COUNTRYNAME=United%20States&ADDRESSID=PayPal&ADDRESSSTATUS=Confirmed&CURRENCYCODE=USD&AMT=1%2e55&ITEMAMT=1%2e55&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&CUSTOM=45931210&DESC=Donation%20to%20the%20Wikimedia%20Foundation&INVNUM=45931210%2e1&NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&INSURANCEAMT=0&SHIPDISCAMT=0&INSURANCEOPTIONOFFERED=false&L_QTY0=1&L_TAXAMT0=0&L_AMT0=1%2e55&L_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=1%2e55&PAYMENTREQUEST_0_ITEMAMT=1%2e55&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_CUSTOM=45931210&PAYMENTREQUEST_0_DESC=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUEST_0_INVNUM=45931210%2e1&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=receiver%40wikimedia%2eorg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_TAXAMT0=0&L_PAYMENTREQUEST_0_AMT0=1%2e55&L_PAYMENTREQUEST_0_DESC0=Donation%20to%20the%20Wikimedia%20Foundation&PAYMENTREQUESTINFO_0_ERRORCODE=0 ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) diff --git a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Recurring-OK.testresponse b/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Recurring-OK.testresponse deleted file mode 100644 index 48f74be..0000000 --- a/tests/phpunit/includes/Responses/paypal_ec/GetExpressCheckoutDetails_Recurring-OK.testresponse +++ /dev/null @@ -1,4 +0,0 @@ -<<<<<<< HEAD (1bece9 Don't require API read rights to report client-side errors) -======= -TOKEN=EC%2d4V987654XA123456V&BILLINGAGREEMENTACCEPTEDSTATUS=1&CHECKOUTSTATUS=PaymentActionNotInitiated&TIMESTAMP=2017%2d04%2d18T16%3a43%3a34Z&CORRELATIONID=38adebcd6cbf8&ACK=Success&VERSION=204&BUILD=32574509&EMAIL=donor%40generous%2enet&PAYERID=8R297FE87CD8S&PAYERSTATUS=unverified&FIRSTNAME=Fezziwig&LASTNAME=Fowl&COUNTRYCODE=US&BILLINGNAME=Fezziwig%20Fowl&STREET=123%20Notta%20Way&CITY=Whoville&STATE=OR&ZIP=97211&COUNTRY=US&COUNTRYNAME=United%20States&ADDRESSID=PayPal&ADDRESSSTATUS=Confirmed&CURRENCYCODE=USD&AMT=1%2e55&ITEMAMT=1%2e55&SHIPPINGAMT=0&HANDLINGAMT=0&TAXAMT=0&NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&INSURANCEAMT=0&SHIPDISCAMT=0&INSURANCEOPTIONOFFERED=false&L_NAME0=Monthly%20donation%20to%20the%20Wikimedia%20Foundation&L_QTY0=1&L_TAXAMT0=0&L_AMT0=1%2e55&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_AMT=1%2e55&PAYMENTREQUEST_0_ITEMAMT=1%2e55&PAYMENTREQUEST_0_SHIPPINGAMT=0&PAYMENTREQUEST_0_HANDLINGAMT=0&PAYMENTREQUEST_0_TAXAMT=0&PAYMENTREQUEST_0_NOTIFYURL=http%3a%2f%2ffundraising%2ewikimedia%2eorg%2fIPNListener_Standalone%2ephp&PAYMENTREQUEST_0_INSURANCEAMT=0&PAYMENTREQUEST_0_SHIPDISCAMT=0&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=tle%40wikimedia%2eorg&PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&L_PAYMENTREQUEST_0_NAME0=Monthly%20donation%20to%20the%20Wikimedia%20Foundation&L_PAYMENTREQUEST_0_QTY0=1&L_PAYMENTREQUEST_0_TAXAMT0=0&L_PAYMENTREQUEST_0_AMT0=1%2e55&PAYMENTREQUESTINFO_0_ERRORCODE=0 ->>>>>>> BRANCH (0d57b2 Handle PaymentActionCompleted in batch mode) -- To view, visit https://gerrit.wikimedia.org/r/387638 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibd8372ca200cf06fd6fc7a26de9a01ebb79d4786 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Mepps <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
