Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192736

Change subject: Wrap an empty payment method
......................................................................

Wrap an empty payment method

This reduces the special-casing we have to do in calling code.

Change-Id: I218acb0f3614e0cdc24675482fbd8a84cd4e118f
---
M gateway_common/PaymentMethod.php
1 file changed, 14 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/36/192736/1

diff --git a/gateway_common/PaymentMethod.php b/gateway_common/PaymentMethod.php
index 46f1323..e40205b 100644
--- a/gateway_common/PaymentMethod.php
+++ b/gateway_common/PaymentMethod.php
@@ -51,14 +51,21 @@
                $method->name = PaymentMethod::parseCompoundMethod( 
$method_name, $submethod_name );
                $method->is_recurring = $is_recurring;
 
-               $spec = null;
-               if ( $submethod_name ) {
-                       $spec = $gateway->getPaymentSubmethodMeta( 
$submethod_name );
+               try {
+                       // FIXME: I don't like that we're couple to the gateway 
already.
+                       $spec = null;
+                       if ( $submethod_name ) {
+                               $spec = $gateway->getPaymentSubmethodMeta( 
$submethod_name );
+                       }
+                       if ( $spec === null ) {
+                               $spec = $gateway->getPaymentMethodMeta( 
$method_name );
+                       }
+                       $method->spec = $spec;
+               } catch ( MWException $ex ) {
+                       // Return empty method.
+                       $method->name = "none";
+                       $method->spec = array();
                }
-               if ( $spec === null ) {
-                       $spec = $gateway->getPaymentMethodMeta( $method_name );
-               }
-               $method->spec = $spec;
 
                return $method;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/192736
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I218acb0f3614e0cdc24675482fbd8a84cd4e118f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to