Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/338296 )

Change subject: Factory for payment providers
......................................................................

Factory for payment providers

Don't make anybody new() up the PaymentProvider classes or call on
SmashPig::Configuration from higher level libraries.

Change-Id: I6ff9a837326f2714398d439a5d14a5a17ad4b564
---
M Core/Configuration.php
A PaymentProviders/PaymentProviderFactory.php
M SmashPig.yaml
3 files changed, 28 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/96/338296/1

diff --git a/Core/Configuration.php b/Core/Configuration.php
index 095daec..f94d72c 100644
--- a/Core/Configuration.php
+++ b/Core/Configuration.php
@@ -274,6 +274,9 @@
 
                // Optional keys
                $arguments = array();
+               // It would be nice to be able to provide other objects defined
+               // in config as arguments. We might have had that 
pre-simplification
+               // with nodes that referred to other nodes.
                if ( $this->nodeExists( $node . '/constructor-parameters' ) ) {
                        $arguments = $this->val( $node . 
'/constructor-parameters' );
                }
diff --git a/PaymentProviders/PaymentProviderFactory.php 
b/PaymentProviders/PaymentProviderFactory.php
new file mode 100644
index 0000000..f84f5f2
--- /dev/null
+++ b/PaymentProviders/PaymentProviderFactory.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace SmashPig\PaymentProviders;
+
+use SmashPig\Core\Context;
+
+/**
+ * Instantiates payment provider classes
+ * TODO: standard way to set credentials from config here, instead of
+ * making other classes do it
+ */
+class PaymentProviderFactory {
+
+       public static function getProviderForMethod( $paymentMethod ) {
+               $config = Context::get()->getConfiguration();
+               $node = "payment-provider/$paymentMethod";
+               return $config->object( $node );
+       }
+}
diff --git a/SmashPig.yaml b/SmashPig.yaml
index ce84b07..70655f0 100644
--- a/SmashPig.yaml
+++ b/SmashPig.yaml
@@ -170,6 +170,8 @@
         listener:
             class: SmashPig\PaymentProviders\Adyen\AdyenListener
 
+    # FIXME: let's use this node to map payment methods to classes that
+    # implement doPayment (aka gateway adapters). See ingenico below.
     payment-provider:
         adyen:
             api:
@@ -457,6 +459,10 @@
         key: SMASHPIG_INGENICO_IDEAL_BANK_LIST
         duration: 300
 
+    payment-provider:
+        rtbt:
+            class: SmashPig\PaymentProviders\Ingenico\BankPaymentProvider
+
 # deprecated, delete when projects using SmashPig rename adaptors
 globalcollect:
     <<: *INGENICO

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ff9a837326f2714398d439a5d14a5a17ad4b564
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to