jenkins-bot has submitted this change and it was merged.
Change subject: Adyen form for Israel
......................................................................
Adyen form for Israel
Enable Adyen form in Israel and use Hebrew language.
Includes logic to conditionaly include address fields, as we don't use them
in Israel.
Bug: T128812
Change-Id: Ia9fe1fb229f243ba234a611dc4e598f976dfb89d
---
M DonationInterfaceFormSettings.php
M adyen_gateway/adyen.adapter.php
A adyen_gateway/config/address_required_countries.yaml
M adyen_gateway/config/payment_submethods.yaml
M gateway_forms/Mustache.php
5 files changed, 45 insertions(+), 18 deletions(-)
Approvals:
Ejegg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/DonationInterfaceFormSettings.php
b/DonationInterfaceFormSettings.php
index 832aa47..df130a5 100644
--- a/DonationInterfaceFormSettings.php
+++ b/DonationInterfaceFormSettings.php
@@ -600,8 +600,8 @@
$forms_whitelist['adyen'] = array(
'file' => __DIR__ . '/gateway_forms/mustache/index.html.mustache',
'gateway' => 'adyen',
- 'countries' => array( '+' => 'US',),
- 'currencies' => array( '+' => 'USD',),
+ 'countries' => array( '+' => 'US', 'IL' ),
+ 'currencies' => array( '+' => 'USD', 'ILS' ),
'payment_methods' => array('cc' => array( 'visa', 'mc', 'amex',
'discover' )),
'selection_weight' => 0
);
diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index 7ac18ec..fe8d623 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -30,9 +30,22 @@
return 'namevalue';
}
+ function getAddressRequired() {
+
+ $countries = $this->config[ 'address_required_countries' ];
+ if( in_array( $this->getData_Unstaged_Escaped( 'country' ),
$countries )) {
+ return true;
+ }
+ return false;
+ }
+
public function getRequiredFields() {
+
+ if( $this->getAddressRequired() ) {
+ $this->payment_methods['cc']['validation']['address'] =
true;
+ }
+
$fields = parent::getRequiredFields();
- $fields[] = 'address';
$fields[] = 'payment_submethod';
return $fields;
}
@@ -87,18 +100,11 @@
* Define transactions
*/
function defineTransactions() {
-
+
$this->transactions = array( );
- $this->transactions[ 'donate' ] = array(
- 'request' => array(
+ $requestFields = array(
'allowedMethods',
- 'billingAddress.street',
- 'billingAddress.city',
- 'billingAddress.postalCode',
- 'billingAddress.stateOrProvince',
- 'billingAddress.country',
- 'billingAddressType',
'card.cardHolderName',
'currencyCode',
'merchantAccount',
@@ -118,7 +124,24 @@
//'shopperStatement',
//'merchantReturnData',
//'deliveryAddressType',
- ),
+ );
+
+ // Add address fields for countries that use them.
+ $addressFields = array (
+ 'billingAddress.street',
+ 'billingAddress.city',
+ 'billingAddress.postalCode',
+ 'billingAddress.stateOrProvince',
+ 'billingAddress.country',
+ 'billingAddressType',
+ );
+
+ if ( $this->getAddressRequired() ) {
+ $requestFields = array_merge( $requestFields,
$addressFields );
+ }
+
+ $this->transactions[ 'donate' ] = array(
+ 'request' => $requestFields,
'values' => array(
'allowedMethods' => implode( ',',
$this->getAllowedPaymentMethods() ),
'billingAddressType' => 2, // hide billing UI
fields
diff --git a/adyen_gateway/config/address_required_countries.yaml
b/adyen_gateway/config/address_required_countries.yaml
new file mode 100644
index 0000000..43d02b4
--- /dev/null
+++ b/adyen_gateway/config/address_required_countries.yaml
@@ -0,0 +1 @@
+- US
diff --git a/adyen_gateway/config/payment_submethods.yaml
b/adyen_gateway/config/payment_submethods.yaml
index 5b62732..398a706 100644
--- a/adyen_gateway/config/payment_submethods.yaml
+++ b/adyen_gateway/config/payment_submethods.yaml
@@ -1,40 +1,41 @@
visa:
countries:
US: true
+ IL: true
group: cc
validation:
name: true
email: true
- address: true
amount: true
logo: card-visa.png
amex:
countries:
US: true
+ IL: true
group: cc
validation:
name: true
email: true
- address: true
amount: true
logo: card-amex.png
mc:
countries:
US: true
+ IL: true
group: cc
validation:
name: true
email: true
- address: true
amount: true
logo: card-mc.png
discover:
countries:
US: true
+ IL: true
group: cc
validation:
name: true
email: true
- address: true
amount: true
logo: card-discover.png
+
diff --git a/gateway_forms/Mustache.php b/gateway_forms/Mustache.php
index 042c616..e790b1e 100644
--- a/gateway_forms/Mustache.php
+++ b/gateway_forms/Mustache.php
@@ -150,6 +150,7 @@
}
protected function addRequiredFields( &$data ) {
+
$required_fields = $this->gateway->getRequiredFields();
foreach( $required_fields as $field ) {
$data["{$field}_required"] = true;
@@ -158,7 +159,8 @@
// FIXME this is conflating the meaning of 'address'
with another
// definition in getRequiredFields. These validation
structures
// should be pulled out into config.
- if ( $field === 'address' ) {
+ if ( $field === 'street' ) {
+ $data['address_required'] = true;
$data['city_required'] = true;
$data['postal_code_required'] = true;
$data['address_css_class'] = 'halfwidth';
--
To view, visit https://gerrit.wikimedia.org/r/286949
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia9fe1fb229f243ba234a611dc4e598f976dfb89d
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: XenoRyet <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits