Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/281534
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, 27 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig
refs/changes/34/281534/1
diff --git a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
index 6288a86..bf6b577 100644
--- a/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
+++ b/PaymentProviders/AstroPay/Audit/AstroPayAudit.php
@@ -115,8 +115,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..581a515 100644
--- a/PaymentProviders/AstroPay/ReferenceData.php
+++ b/PaymentProviders/AstroPay/ReferenceData.php
@@ -70,18 +70,33 @@
throw new OutOfBoundsException( "Unknown payment submethod
code: {$code}" );
}
- public static function decodePaymentMethod( $name ) {
+ public static function decodePaymentMethod( $type, $code ) {
$methods = array(
'Bank Transfer' => 'bt',
'Cash Payment' => 'cash',
'Credit Card' => 'cc',
'Debit Card' => 'cc',
);
-
- if ( array_key_exists( $name, $methods ) ) {
- return $methods[$name];
+ $method = null;
+ if ( array_key_exists( $type, $methods ) ) {
+ $method = $methods[$type];
+ } else {
+ throw new OutOfBoundsException( "Unknown payment method
type: {$type}" );
}
-
- throw new OutOfBoundsException( "Unknown payment method name:
{$name}" );
+ $multiTypeSubmethods = array(
+ 'WP' => array(
+ 'cc' => 'webpay',
+ 'bt' => 'webpay_bt',
+ )
+ );
+ if (
+ array_key_exists( $code, $multiTypeSubmethods ) &&
+ array_key_exists( $method, $multiTypeSubmethods[$code] )
+ ) {
+ $submethod = $methods[$type];
+ } else {
+ $submethod = self::decodePaymentSubmethod( $code );
+ }
+ return array( $method, $submethod);
}
}
--
To view, visit https://gerrit.wikimedia.org/r/281534
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I53389c319ad90e18537314fdf6c45acea162af61
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits