Mepps has uploaded a new change for review. (
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 modules/js/ext.donationInterface.forms.js
10 files changed, 62 insertions(+), 19 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/53/385253/1
diff --git a/adyen_gateway/AdyenHostedSignature.php
b/adyen_gateway/AdyenHostedSignature.php
index fbea66a..6456ff5 100644
--- a/adyen_gateway/AdyenHostedSignature.php
+++ b/adyen_gateway/AdyenHostedSignature.php
@@ -45,7 +45,8 @@
ksort( $values, SORT_STRING );
$merged = array_merge( array_keys( $values ), array_values(
$values ) );
$joined = implode( ':', $merged );
- $secret = $adapter->getAccountConfig( 'SharedSecret' );
+ $skinName = $values['skinName'];
+ $secret = $adapter->getAccountConfig( 'Skins'
)[$skinName]['SharedSecret'];
return base64_encode(
hash_hmac( 'sha256', $joined, pack( "H*", $secret ),
true )
);
diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index 022a2f0..6e20ede 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' ],
);
}
@@ -52,6 +52,7 @@
'merchantReturnData' => 'return_data',
'pspReference' => 'gateway_txn_id',
'skinCode' => 'skin_code',
+ 'skinName' => 'processor_form',
);
}
@@ -88,6 +89,7 @@
'sessionValidity',
'shipBeforeDate',
'skinCode',
+ 'skinName',
'shopperLocale',
'shopperEmail',
// TODO more fields we might want to send to
Adyen
@@ -122,7 +124,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,7 +184,10 @@
// 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 ) );
+
+ $skinName =
$this->getTransactionSpecificValue( 'skinName' );
+ $skinCode =
$this->accountInfo['skins'][$skinName]['SkinCode'];
+ $this->addRequestData( array(
'risk_score' => $this->risk_score, 'skin_code' => $skinCode ) );
$requestParams =
$this->buildRequestParams();
diff --git a/adyen_gateway/adyen_gateway.body.php
b/adyen_gateway/adyen_gateway.body.php
index ca4b450..a8abd45 100644
--- a/adyen_gateway/adyen_gateway.body.php
+++ b/adyen_gateway/adyen_gateway.body.php
@@ -23,4 +23,5 @@
class AdyenGateway extends GatewayPage {
protected $gatewayIdentifier = AdyenAdapter::IDENTIFIER;
+
}
diff --git a/adyen_gateway/config/var_map.yaml
b/adyen_gateway/config/var_map.yaml
index 665390d..e8eca81 100644
--- a/adyen_gateway/config/var_map.yaml
+++ b/adyen_gateway/config/var_map.yaml
@@ -26,3 +26,4 @@
shopperReference: customer_id
shopperStatement: statement_template
skinCode: skin_code
+skinName: processor_form
\ No newline at end of file
diff --git a/adyen_gateway/forms/js/adyen.js b/adyen_gateway/forms/js/adyen.js
index f2e3772..a278ee2 100644
--- a/adyen_gateway/forms/js/adyen.js
+++ b/adyen_gateway/forms/js/adyen.js
@@ -1,5 +1,30 @@
( function ( $, mw ) {
- var di = mw.donationInterface;
+ var di = mw.donationInterface, resultFunction = showIframe;
+
+ $('#processor_form').val('iframe');
+ if ( window.safari !== undefined ) {
+ resultFunction = redirect;
+ $('#processor_form').val('redirect');
+ }
+
+ function redirect( result ) {
+ // We don't actually want to enable the form on redirect or in
the
+ // complete phase of callDonateApi, so we override enable here.
+ var $pForm, $payment = $( '#payment-form' );
+ di.forms.enable = function(){};
+ $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 +50,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();
@@ -49,6 +62,23 @@
}
di.forms.submit = function () {
- di.forms.callDonateApi( showIframe );
+ di.forms.callDonateApi( resultFunction );
};
+
+ var populateHiddenFields = function( 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 2673df7..b5a5316 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';
return $fields;
}
diff --git a/gateway_common/donation.api.php b/gateway_common/donation.api.php
index f488033..de4fab2 100644
--- a/gateway_common/donation.api.php
+++ b/gateway_common/donation.api.php
@@ -148,6 +148,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 1f3f453..fe7690a 100644
--- a/gateway_common/i18n/interface/en.json
+++ b/gateway_common/i18n/interface/en.json
@@ -447,6 +447,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 61e7711..faa4eaa 100644
--- a/gateway_common/i18n/interface/qqq.json
+++ b/gateway_common/i18n/interface/qqq.json
@@ -472,6 +472,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/modules/js/ext.donationInterface.forms.js
b/modules/js/ext.donationInterface.forms.js
index f11019c..c7049e1 100644
--- a/modules/js/ext.donationInterface.forms.js
+++ b/modules/js/ext.donationInterface.forms.js
@@ -58,6 +58,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(),
--
To view, visit https://gerrit.wikimedia.org/r/385253
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb16a8897b03de6d10e079fe5d1b03ab748ec2e9
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