jenkins-bot has submitted this change and it was merged.
Change subject: AstroPay: look up method and submethod together
......................................................................
AstroPay: look up method and submethod together
Allows decoding one bank code to two different internal names.
Change-Id: I53389c319ad90e18537314fdf6c45acea162af61
---
M PaymentProviders/AstroPay/Audit/AstroPayAudit.php
M PaymentProviders/AstroPay/ReferenceData.php
2 files changed, 97 insertions(+), 75 deletions(-)
Approvals:
Awight: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
index 1a11271..03e896c 100644
--- a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
+++ b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
@@ -118,8 +118,12 @@
$msg['settled_fee'] = $row['Fee']; // settled_fee since it's
given in USD
$msg['gateway_txn_id'] = $row['Reference'];
$msg['log_id'] = $row['Invoice'];
- $msg['payment_method'] = ReferenceData::decodePaymentMethod(
$row['Payment Method Type'] );
- $msg['payment_submethod'] =
ReferenceData::decodePaymentSubmethod( $row['Payment Method'] );
+ list( $method, $submethod ) =
ReferenceData::decodePaymentMethod(
+ $row['Payment Method Type'],
+ $row['Payment Method']
+ );
+ $msg['payment_method'] = $method;
+ $msg['payment_submethod'] = $submethod;
if ( $row['Settlement date'] ) {
$msg['settled_date'] = UtcDate::getUtcTimestamp(
$row['Settlement date'] );
}
diff --git a/PaymentProviders/AstroPay/ReferenceData.php
b/PaymentProviders/AstroPay/ReferenceData.php
index 6231ea5..fe8e56c 100644
--- a/PaymentProviders/AstroPay/ReferenceData.php
+++ b/PaymentProviders/AstroPay/ReferenceData.php
@@ -3,85 +3,103 @@
use OutOfBoundsException;
class ReferenceData {
- public static function decodePaymentSubmethod( $code ) {
- $submethods = array(
- 'AG' => 'argen',
- 'AE' => 'amex',
- 'AU' => 'aura',
- 'B' => 'bradesco',
- 'BB' => 'banco_do_brasil',
- 'BG' => 'cash_provencia_pagos',
- 'BL' => 'cash_boleto',
- 'BM' => 'cash_banamex',
- 'BP' => 'bbva', // Peru, bank transfer
- 'BV' => 'cash_bancomer', // Mexico, aka BBVA
- 'BX' => 'banco_de_chile',
- 'CA' => 'caixa',
- 'CB' => 'baloto',
- 'CL' => 'cabal',
- 'CM' => 'cmr',
- 'CR' => 'carulla',
- 'CS' => 'cencosud',
- 'DA' => 'cash_davivienda',
- 'DC' => 'diners',
- 'DD' => 'dineromail', // (Transfer)
- 'DM' => 'cash_dineromail', // (Cash)
- 'DS' => 'discover',
- 'EF' => 'cash_pago_efectivo',
- 'EL' => 'elo',
- 'EQ' => 'quindio',
- 'EX' => 'almancenes',
- 'EY' => 'cash_efecty',
- 'H' => 'hsbc',
- 'HI' => 'hiper',
- 'I' => 'itau',
- 'IB' => 'interbank',
- 'JC' => 'jcb',
- 'MC' => 'mc',
- 'MD' => 'mc-debit',
- 'MG' => 'magna',
- 'ML' => 'mercadolivre',
- 'NJ' => 'naranja',
- 'NT' => 'nativa',
- 'OC' => 'banco_de_occidente',
- 'OX' => 'cash_oxxo',
- 'PA' => 'bcp', // Peru, "via LatinAmericanPayments"
- 'PC' => 'pse', // Columbia, "all banks"
- 'PF' => 'cash_pago_facil',
- 'PR' => 'presto',
- 'RE' => 'cash_red_pagos',
- 'RL' => 'red_link',
- 'RP' => 'cash_rapipago',
- 'SB' => 'santander', // Brazil
- 'SI' => 'santander_rio', // Argentina
- 'SM' => 'cash_santander', // Mexico
- 'SP' => 'servipag',
- 'SX' => 'surtimax',
- 'TS' => 'shopping',
- 'VD' => 'visa-debit',
- 'VI' => 'visa',
- 'WP' => 'webpay',
- );
- if ( array_key_exists( $code, $submethods ) ) {
- return $submethods[$code];
+ protected static $methods = array(
+ 'Bank Transfer' => 'bt',
+ 'Cash Payment' => 'cash',
+ 'Credit Card' => 'cc',
+ 'Debit Card' => 'cc',
+ );
+
+ protected static $multiTypeSubmethods = array(
+ 'WP' => array(
+ 'cc' => 'webpay',
+ 'bt' => 'webpay_bt',
+ ),
+ );
+
+ protected static $simpleSubmethods = array(
+ 'AG' => 'argen',
+ 'AE' => 'amex',
+ 'AU' => 'aura',
+ 'B' => 'bradesco',
+ 'BB' => 'banco_do_brasil',
+ 'BG' => 'cash_provencia_pagos',
+ 'BL' => 'cash_boleto',
+ 'BM' => 'cash_banamex',
+ 'BP' => 'bbva', // Peru, bank transfer
+ 'BV' => 'cash_bancomer', // Mexico, aka BBVA
+ 'BX' => 'banco_de_chile',
+ 'CA' => 'caixa',
+ 'CB' => 'baloto',
+ 'CL' => 'cabal',
+ 'CM' => 'cmr',
+ 'CR' => 'carulla',
+ 'CS' => 'cencosud',
+ 'DA' => 'cash_davivienda',
+ 'DC' => 'diners',
+ 'DD' => 'dineromail', // (Transfer)
+ 'DM' => 'cash_dineromail', // (Cash)
+ 'DS' => 'discover',
+ 'EF' => 'cash_pago_efectivo',
+ 'EL' => 'elo',
+ 'EQ' => 'quindio',
+ 'EX' => 'almancenes',
+ 'EY' => 'cash_efecty',
+ 'H' => 'hsbc',
+ 'HI' => 'hiper',
+ 'I' => 'itau',
+ 'IB' => 'interbank',
+ 'JC' => 'jcb',
+ 'MC' => 'mc',
+ 'MD' => 'mc-debit',
+ 'MG' => 'magna',
+ 'ML' => 'mercadolivre',
+ 'NJ' => 'naranja',
+ 'NT' => 'nativa',
+ 'OC' => 'banco_de_occidente',
+ 'OX' => 'cash_oxxo',
+ 'PA' => 'bcp', // Peru, "via LatinAmericanPayments"
+ 'PC' => 'pse', // Columbia, "all banks"
+ 'PF' => 'cash_pago_facil',
+ 'PR' => 'presto',
+ 'RE' => 'cash_red_pagos',
+ 'RL' => 'red_link',
+ 'RP' => 'cash_rapipago',
+ 'SB' => 'santander', // Brazil
+ 'SI' => 'santander_rio', // Argentina
+ 'SM' => 'cash_santander', // Mexico
+ 'SP' => 'servipag',
+ 'SX' => 'surtimax',
+ 'TS' => 'shopping',
+ 'VD' => 'visa-debit',
+ 'VI' => 'visa',
+ 'WP' => 'webpay',
+ );
+
+ public static function decodePaymentMethod( $type, $bankCode ) {
+ if ( !array_key_exists( $type, self::$methods ) ) {
+ throw new OutOfBoundsException( "Unknown payment method
type: {$type}" );
}
- throw new OutOfBoundsException( "Unknown payment submethod
code: {$code}" );
+ $method = self::$methods[$type];
+ $submethod = self::decodePaymentSubmethod( $method, $bankCode );
+
+ return array( $method, $submethod );
}
- public static function decodePaymentMethod( $name ) {
- $methods = array(
- 'Bank Transfer' => 'bt',
- 'Cash Payment' => 'cash',
- 'Credit Card' => 'cc',
- 'Debit Card' => 'cc',
- );
-
- if ( array_key_exists( $name, $methods ) ) {
- return $methods[$name];
+ public static function decodePaymentSubmethod( $method, $bankCode ) {
+ if (
+ array_key_exists( $bankCode, self::$multiTypeSubmethods
) &&
+ array_key_exists( $method,
self::$multiTypeSubmethods[$bankCode] )
+ ) {
+ return self::$multiTypeSubmethods[$bankCode][$method];
}
- throw new OutOfBoundsException( "Unknown payment method name:
{$name}" );
+ if ( array_key_exists( $bankCode, self::$simpleSubmethods ) ) {
+ return self::$simpleSubmethods[$bankCode];
+ }
+
+ throw new OutOfBoundsException( "Unknown bank code:
{$bankCode}" );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/281534
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I53389c319ad90e18537314fdf6c45acea162af61
Gerrit-PatchSet: 3
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits