jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/385253 )
Change subject: Redirect for Safari + multiskins ...................................................................... Redirect for Safari + multiskins Bug: T176913 Change-Id: Ifb16a8897b03de6d10e079fe5d1b03ab748ec2e9 --- M adyen_gateway/AdyenHostedSignature.php M adyen_gateway/adyen.adapter.php M adyen_gateway/adyen_gateway.body.php M adyen_gateway/config/var_map.yaml M adyen_gateway/forms/js/adyen.js M gateway_common/DonationData.php M gateway_common/donation.api.php M gateway_common/i18n/interface/en.json M gateway_common/i18n/interface/qqq.json M gateway_forms/mustache/index.html.mustache M modules/js/ext.donationInterface.forms.js M tests/phpunit/DonationInterfaceTestCase.php M tests/phpunit/TestConfiguration.php 13 files changed, 85 insertions(+), 25 deletions(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/adyen_gateway/AdyenHostedSignature.php b/adyen_gateway/AdyenHostedSignature.php index fbea66a..3ac51bd 100644 --- a/adyen_gateway/AdyenHostedSignature.php +++ b/adyen_gateway/AdyenHostedSignature.php @@ -45,9 +45,17 @@ ksort( $values, SORT_STRING ); $merged = array_merge( array_keys( $values ), array_values( $values ) ); $joined = implode( ':', $merged ); - $secret = $adapter->getAccountConfig( 'SharedSecret' ); - return base64_encode( - hash_hmac( 'sha256', $joined, pack( "H*", $secret ), true ) - ); + $skinCode = $values['skinCode']; + if ( array_key_exists( $skinCode, $adapter->getAccountConfig( 'Skins' ) ) ) { + $secret = $adapter->getAccountConfig( 'Skins' )[$skinCode]['SharedSecret']; + return base64_encode( + hash_hmac( 'sha256', $joined, pack( "H*", $secret ), true ) + ); + } else { + throw new ResponseProcessingException( + 'Skin code not configured', + ResponseCodes::BAD_SIGNATURE + ); + } } } diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php index 022a2f0..7fae0dd 100644 --- a/adyen_gateway/adyen.adapter.php +++ b/adyen_gateway/adyen.adapter.php @@ -39,7 +39,7 @@ function defineAccountInfo() { $this->accountInfo = array( 'merchantAccount' => $this->account_config[ 'AccountName' ], - 'skinCode' => $this->account_config[ 'SkinCode' ], + 'skins' => $this->account_config[ 'Skins' ], ); } @@ -51,7 +51,7 @@ 'merchantReference' => 'order_id', 'merchantReturnData' => 'return_data', 'pspReference' => 'gateway_txn_id', - 'skinCode' => 'skin_code', + 'skinCode' => 'processor_form', ); } @@ -122,7 +122,6 @@ 'merchantAccount' => $this->accountInfo[ 'merchantAccount' ], 'sessionValidity' => date( 'c', strtotime( '+2 days' ) ), 'shipBeforeDate' => date( 'Y-M-d', strtotime( '+2 days' ) ), - 'skinCode' => $this->accountInfo[ 'skinCode' ], // 'shopperLocale' => language _ country ), 'check_required' => true, @@ -183,6 +182,7 @@ // card entry iframe. If it's sorta-fraudy, the listener // will leave it for manual review. If it's hella fraudy // the listener will cancel it. + $this->addRequestData( array( 'risk_score' => $this->risk_score ) ); $requestParams = $this->buildRequestParams(); diff --git a/adyen_gateway/adyen_gateway.body.php b/adyen_gateway/adyen_gateway.body.php index ca4b450..33fc62b 100644 --- a/adyen_gateway/adyen_gateway.body.php +++ b/adyen_gateway/adyen_gateway.body.php @@ -23,4 +23,14 @@ class AdyenGateway extends GatewayPage { protected $gatewayIdentifier = AdyenAdapter::IDENTIFIER; + + public function setClientVariables( &$vars ) { + parent::setClientVariables( $vars ); + $skins = $this->adapter->getAccountConfig( 'Skins' ); + $skinNames = array(); + foreach ( $skins as $code => $skin ) { + $skinNames[$skin['Name']] = $code; + } + $vars['wgAdyenGatewaySkinNames'] = $skinNames; + } } diff --git a/adyen_gateway/config/var_map.yaml b/adyen_gateway/config/var_map.yaml index 665390d..861be53 100644 --- a/adyen_gateway/config/var_map.yaml +++ b/adyen_gateway/config/var_map.yaml @@ -25,4 +25,4 @@ shopperLocale: language shopperReference: customer_id shopperStatement: statement_template -skinCode: skin_code +skinCode: processor_form diff --git a/adyen_gateway/forms/js/adyen.js b/adyen_gateway/forms/js/adyen.js index f2e3772..863f534 100644 --- a/adyen_gateway/forms/js/adyen.js +++ b/adyen_gateway/forms/js/adyen.js @@ -1,5 +1,23 @@ ( function ( $, mw ) { - var di = mw.donationInterface; + var di = mw.donationInterface, + resultFunction, + skinNames = mw.config.get( 'wgAdyenGatewaySkinNames' ); + + function redirect( result ) { + var $pForm, $payment = $( '#payment-form' ); + $pForm = $( + '<form></form>', { + method: 'post', + action: result.formaction, + id: 'submit-payment' + } + ); + populateHiddenFields( result.gateway_params, $pForm ); + $payment.append( $pForm ); + + $pForm.prop( 'action', result.formaction ); + $pForm.submit(); + } function showIframe( result ) { var $pForm, $payment = $( '#payment-form' ); @@ -25,19 +43,7 @@ id: 'fetch-iframe-form' } ); - $.each( - result.gateway_params, function ( key, value ) { - $pForm.append( - $( - '<input>', { - type: 'hidden', - name: key, - value: value - } - ) - ); - } - ); + populateHiddenFields( result.gateway_params, $pForm ); $payment.append( $pForm ); $payment.find( '#fetch-iframe-form' ).submit(); @@ -48,7 +54,31 @@ $( '#adyen-iframe' ).show( 'blind' ); } + // iframe is base + resultFunction = showIframe; + $( '#processor_form' ).val( skinNames.base ); + if ( window.safari !== undefined ) { + resultFunction = redirect; + $( '#processor_form' ).val( skinNames.redirect ); + } + di.forms.submit = function () { - di.forms.callDonateApi( showIframe ); + di.forms.callDonateApi( resultFunction ); }; + + function populateHiddenFields( values, $form ) { + $.each( + values, function ( key, value ) { + $form.append( + $( + '<input>', { + type: 'hidden', + name: key, + value: value + } + ) + ); + } + ); + } } )( jQuery, mediaWiki ); diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php index 3653241..39d1828 100644 --- a/gateway_common/DonationData.php +++ b/gateway_common/DonationData.php @@ -96,6 +96,7 @@ 'transaction_type', 'form_name', 'ffname', + 'processor_form', 'recurring', 'recurring_paypal', 'redirect', @@ -978,6 +979,7 @@ $fields = self::getMessageFields(); $fields[] = 'order_id'; $fields[] = 'appeal'; + $fields[] = 'processor_form'; $fields[] = 'referrer'; $fields[] = 'contact_id'; $fields[] = 'contact_hash'; diff --git a/gateway_common/donation.api.php b/gateway_common/donation.api.php index 5703a5c..71e8545 100644 --- a/gateway_common/donation.api.php +++ b/gateway_common/donation.api.php @@ -150,6 +150,7 @@ 'cvv' => $this->defineParam( false ), 'payment_method' => $this->defineParam( false ), 'payment_submethod' => $this->defineParam( false ), + 'processor_form' => $this->defineParam( false ), 'language' => $this->defineParam( false ), 'order_id' => $this->defineParam( false ), 'wmf_token' => $this->defineParam( false ), diff --git a/gateway_common/i18n/interface/en.json b/gateway_common/i18n/interface/en.json index 999cfdd..7199a98 100644 --- a/gateway_common/i18n/interface/en.json +++ b/gateway_common/i18n/interface/en.json @@ -449,6 +449,7 @@ "apihelp-donate-param-cvv": "CVV security code.", "apihelp-donate-param-payment_method": "Payment method to use.", "apihelp-donate-param-payment_submethod": "Payment submethod to use.", + "apihelp-donate-param-processor_form": "Which of the processor's form options to use.", "apihelp-donate-param-language": "Language code.", "apihelp-donate-param-order_id": "Order ID (if a donation has already been started).", "apihelp-donate-param-wmf_token": "Edit token.", diff --git a/gateway_common/i18n/interface/qqq.json b/gateway_common/i18n/interface/qqq.json index 4bc4835..5904619 100644 --- a/gateway_common/i18n/interface/qqq.json +++ b/gateway_common/i18n/interface/qqq.json @@ -474,6 +474,7 @@ "apihelp-donate-param-cvv": "{{doc-apihelp-param|donate|cvv}}", "apihelp-donate-param-payment_method": "{{doc-apihelp-param|donate|payment_method}}", "apihelp-donate-param-payment_submethod": "{{doc-apihelp-param|donate|payment_submethod}}", + "apihelp-donate-param-processor_form": "{{doc-apihelp-param|donate|processor_form}}", "apihelp-donate-param-language": "{{doc-apihelp-param|donate|language}}\n{{Identical|Language code}}", "apihelp-donate-param-order_id": "{{doc-apihelp-param|donate|order_id}}", "apihelp-donate-param-wmf_token": "{{doc-apihelp-param|donate|wmf_token}}", diff --git a/gateway_forms/mustache/index.html.mustache b/gateway_forms/mustache/index.html.mustache index b8ca5fe..e27d074 100644 --- a/gateway_forms/mustache/index.html.mustache +++ b/gateway_forms/mustache/index.html.mustache @@ -56,6 +56,7 @@ <input type="hidden" value="{{ gateway }}" name="gateway" id="gateway"/> <input type="hidden" value="{{ recurring }}" name="recurring" id="recurring"/> <input type="hidden" value="{{ variant }}" name="variant" id="variant"/> + <input type="hidden" value="{{ processor_form }}" name="processor_form" id="processor_form"/> <input type="hidden" value="{{ payment_method }}" name="payment_method" id="payment_method"/> </form> </div> diff --git a/modules/js/ext.donationInterface.forms.js b/modules/js/ext.donationInterface.forms.js index 88ae071..c8fa554 100644 --- a/modules/js/ext.donationInterface.forms.js +++ b/modules/js/ext.donationInterface.forms.js @@ -60,6 +60,7 @@ payment_method: $( '#payment_method' ).val(), language: $( '#language' ).val(), payment_submethod: $( 'input[name="payment_submethod"]:checked' ).val().toLowerCase(), + processor_form: $( '#processor_form' ).val(), issuer_id: $( '#issuer_id' ).val(), utm_source: $( '#utm_source' ).val(), utm_campaign: $( '#utm_campaign' ).val(), diff --git a/tests/phpunit/DonationInterfaceTestCase.php b/tests/phpunit/DonationInterfaceTestCase.php index 5578942..5ab3999 100644 --- a/tests/phpunit/DonationInterfaceTestCase.php +++ b/tests/phpunit/DonationInterfaceTestCase.php @@ -325,6 +325,7 @@ 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'" ); diff --git a/tests/phpunit/TestConfiguration.php b/tests/phpunit/TestConfiguration.php index 17ebfe7..ba79ad0 100644 --- a/tests/phpunit/TestConfiguration.php +++ b/tests/phpunit/TestConfiguration.php @@ -156,8 +156,12 @@ $wgAdyenGatewayAccountInfo = array(); $wgAdyenGatewayAccountInfo['test'] = array( 'AccountName' => 'wikitest', - 'SharedSecret' => 'C7F1D9E29479CF18131063A742CD2703FB9D48BAB0160693045E3FB7B8508E59', - 'SkinCode' => 'testskin', + 'Skins' => [ + 'testskin' => [ + 'SharedSecret' => 'C7F1D9E29479CF18131063A742CD2703FB9D48BAB0160693045E3FB7B8508E59', + 'Name' => 'base', + ], + ], ); /** AstroPay **/ -- To view, visit https://gerrit.wikimedia.org/r/385253 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifb16a8897b03de6d10e079fe5d1b03ab748ec2e9 Gerrit-PatchSet: 13 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Mepps <me...@wikimedia.org> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> 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