Cdentinger has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278292
Change subject: move worldpay payment methods
......................................................................
move worldpay payment methods
required some light rearranging
Change-Id: I67a4bc07d5e71ba85ac25d40f897e1bb445f26e4
---
A worldpay_gateway/config/payment_method_api_names.yaml
A worldpay_gateway/config/payment_methods.yaml
A worldpay_gateway/config/payment_submethods.yaml
M worldpay_gateway/worldpay.adapter.php
4 files changed, 156 insertions(+), 94 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/92/278292/1
diff --git a/worldpay_gateway/config/payment_method_api_names.yaml
b/worldpay_gateway/config/payment_method_api_names.yaml
new file mode 100644
index 0000000..aa8391e
--- /dev/null
+++ b/worldpay_gateway/config/payment_method_api_names.yaml
@@ -0,0 +1,16 @@
+# api_name: wmf_name
+CB: cb
+VI: visa
+MC: mc
+AX: amex
+BE: visa-beneficial
+DC: diners
+DI: discover
+JC: jcb
+MA: maestro
+MD: mc-debit
+SW: solo
+VD: visa-debit
+VE: visa-electron
+# TODO wtf is this
+XX: ''
diff --git a/worldpay_gateway/config/payment_methods.yaml
b/worldpay_gateway/config/payment_methods.yaml
new file mode 100644
index 0000000..39c1d4c
--- /dev/null
+++ b/worldpay_gateway/config/payment_methods.yaml
@@ -0,0 +1,5 @@
+cc:
+ label: 'Credit Cards'
+ validation:
+ name: true
+ email: true
diff --git a/worldpay_gateway/config/payment_submethods.yaml
b/worldpay_gateway/config/payment_submethods.yaml
new file mode 100644
index 0000000..8b4ab1c
--- /dev/null
+++ b/worldpay_gateway/config/payment_submethods.yaml
@@ -0,0 +1,130 @@
+cb:
+ countries:
+ FR: true
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-cb.png
+visa:
+ countries:
+ FR: true
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-visa.png
+mc:
+ countries:
+ FR: true
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-mc.png
+amex:
+ countries:
+ FR: true
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-amex.png
+visa-beneficial:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-visa-beneficial.png
+diners:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-diners.png
+discover:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-discover.png
+jcb:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-jcb.png
+maestro:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-maestro.png
+mc-debit:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-mc-debit.png
+solo:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-solo.png
+visa-debit:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-visa-debit.png
+visa-electron:
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-visa-electron.png
+'':
+ countries: { }
+ group: cc
+ validation:
+ name: true
+ email: true
+ address: false
+ amount: true
+ logo: card-.png
diff --git a/worldpay_gateway/worldpay.adapter.php
b/worldpay_gateway/worldpay.adapter.php
index cd4cca9..7593dd5 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -34,58 +34,6 @@
'OTTResultURL'
);
- // TODO we should store these keys in a config file
- // TODO the way the cards are ordered on the page is the order of this
- // array. make that a "weight" that could be controlled by a url param
- static $CARD_INFO = array(
- 'cb' => array( // Carte Bleu
- 'api_name' => 'CB',
- 'countries' => array( 'FR' => true ),
- ),
- 'visa' => array(
- 'api_name' => 'VI',
- 'countries' => array( 'FR' => true ),
- ),
- 'mc' => array(
- 'api_name' => 'MC',
- 'countries' => array( 'FR' => true ),
- ),
- 'amex' => array(
- 'api_name' => 'AX',
- 'countries' => array( 'FR' => true ),
- ),
- 'visa-beneficial' => array(
- 'api_name' => 'BE',
- ),
- 'diners' => array(
- 'api_name' => 'DC',
- ),
- 'discover' => array(
- 'api_name' => 'DI',
- ),
- 'jcb' => array(
- 'api_name' => 'JC',
- ),
- 'maestro' => array(
- 'api_name' => 'MA',
- ),
- 'mc-debit' => array(
- 'api_name' => 'MD',
- ),
- 'solo' => array(
- 'api_name' => 'SW'
- ),
- 'visa-debit' => array(
- 'api_name' => 'VD',
- ),
- 'visa-electron' => array(
- 'api_name' => 'VE',
- ),
- '' /* TODO wat */ => array(
- 'api_name' => 'XX',
- ),
- );
-
/**
* @var string[] ISO Currency code letters to numbers (from appendix B
of the
* integration manual). These are also apparently all the currencies
that
@@ -327,38 +275,6 @@
// NarrativeStatement1
'narrative_statement_1' => array( 'type' =>
'alphanumeric', 'length' => 50 ),
);
- }
-
- function definePaymentMethods() {
- $this->payment_methods = array();
- $this->payment_methods['cc'] = array(
- 'label' => 'Credit Cards',
- 'validation' => array(
- 'name' => true,
- 'email' => true
- ),
- );
-
- $this->payment_submethods = array();
-
- foreach( self::$CARD_INFO as $name => $info ) {
-
- $countries = array();
- if ( isset( $info['countries'] ) ) {
- $countries = $info['countries'];
- }
- $this->payment_submethods[$name] = array(
- 'countries' => $countries,
- 'group' => 'cc',
- 'validation' => array(
- 'name' => true,
- 'email' => true,
- 'address' => false,
- 'amount' => true,
- ),
- 'logo' => "card-{$name}.png",
- );
- }
}
/**
@@ -806,15 +722,6 @@
$this->data_transformers = parent::getCoreDataTransformers();
}
- private function get_payment_method_name_from_api_name ( $api_name ) {
- foreach ( self::$CARD_INFO as $name => $info ) {
- if ( $api_name === $info['api_name'] ) {
- return $name;
- }
- }
- return null;
- }
-
/**
* Check if the currently-staged store ID is configured for special
treatment.
* Certain store IDs (just FR so far) do not get AVS results, and
always get
@@ -827,6 +734,10 @@
return array_key_exists( 'SpecialSnowflakeStoreIDs',
$this->account_config )
&& array_key_exists( 'wp_storeid', $this->staged_data )
&& in_array( $this->staged_data['wp_storeid'],
$this->account_config['SpecialSnowflakeStoreIDs'] );
+ }
+
+ public function getBasedir() {
+ return __DIR__;
}
public function doPayment() {
@@ -1175,7 +1086,7 @@
$paymentSubmethod = $this->getData_Staged( 'payment_submethod'
);
if ( $paymentMethod == 'cc' ) {
$this->unstaged_data['payment_submethod'] =
- $this->get_payment_method_name_from_api_name(
$paymentSubmethod );
+ $this->payment_method_api_names[
$paymentSubmethod ];
}
}
--
To view, visit https://gerrit.wikimedia.org/r/278292
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I67a4bc07d5e71ba85ac25d40f897e1bb445f26e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Cdentinger <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits