Ejegg has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/334733 )
Change subject: Look up iDEAL banks without Ingenico SDK
......................................................................
Look up iDEAL banks without Ingenico SDK
Working with sandbox credentials!
TODO: check more things in test, handle errors.
Bug: T128692
Change-Id: Ib22f3f18a184038e3c4c663083aed1c0069e5052
---
A PaymentProviders/Ingenico/BankPaymentProvider.php
A PaymentProviders/Ingenico/Tests/Data/productDirectory.response
A PaymentProviders/Ingenico/Tests/phpunit/BankPaymentProviderTest.php
3 files changed, 99 insertions(+), 0 deletions(-)
Approvals:
Cdentinger: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PaymentProviders/Ingenico/BankPaymentProvider.php
b/PaymentProviders/Ingenico/BankPaymentProvider.php
new file mode 100644
index 0000000..9c0891a
--- /dev/null
+++ b/PaymentProviders/Ingenico/BankPaymentProvider.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace SmashPig\PaymentProviders\Ingenico;
+
+/**
+ * Handle bank payments via Ingenico
+ * Will eventually implement PaymentProvider, but right now just looks
+ * up iDEAL banks
+ */
+class BankPaymentProvider extends IngenicoPaymentProvider {
+
+ /**
+ * Look up banks
+ * @param string $country 2 letter country ISO code
+ * @param string $currency 3 letter currency ISO code
+ * @param int $productId Numeric Ingenico id of payment product we're
+ * listing banks for. Defaults to the code for iDEAL, the only product
+ * supported as of early 2017
+ * @return array Keys are bank codes, values are names
+ */
+ public function getBankList( $country, $currency, $productId = 809 ) {
+ $query = array(
+ 'countryCode' => $country,
+ 'currencyCode' => $currency
+ );
+ $path = "products/$productId/directory";
+ $response = $this->makeApiCall( $path, 'GET', $query );
+
+ // TODO: base class should probably decode
+ $decoded = json_decode( $response['body'] );
+
+ $banks = array();
+
+ foreach( $decoded->entries as $entry ) {
+ $banks[$entry->issuerId] = $entry->issuerName;
+ }
+ return $banks;
+ }
+}
diff --git a/PaymentProviders/Ingenico/Tests/Data/productDirectory.response
b/PaymentProviders/Ingenico/Tests/Data/productDirectory.response
new file mode 100644
index 0000000..ecfb28e
--- /dev/null
+++ b/PaymentProviders/Ingenico/Tests/Data/productDirectory.response
@@ -0,0 +1,15 @@
+HTTP/1.1 200 OK
+Date: Mon, 30 Jan 2017 17:58:02 GMT
+Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1t
+X-Powered-By: Servlet/3.0 JSP/2.2
+Transfer-Encoding: chunked
+Content-Type: application/json
+
+{
+ "entries" : [ {
+ "countryNames" : [ "Nederland" ],
+ "issuerId" : "INGBNL2A",
+ "issuerList" : "short",
+ "issuerName" : "Issuer Simulation V3 - ING"
+ } ]
+}
diff --git
a/PaymentProviders/Ingenico/Tests/phpunit/BankPaymentProviderTest.php
b/PaymentProviders/Ingenico/Tests/phpunit/BankPaymentProviderTest.php
new file mode 100644
index 0000000..1db0a84
--- /dev/null
+++ b/PaymentProviders/Ingenico/Tests/phpunit/BankPaymentProviderTest.php
@@ -0,0 +1,45 @@
+<?php
+namespace SmashPig\PaymentProviders\Ingenico\Tests;
+
+use PHPUnit_Framework_MockObject_MockObject;
+use SmashPig\Core\Http\CurlWrapper;
+use SmashPig\PaymentProviders\Ingenico\BankPaymentProvider;
+use SmashPig\Tests\BaseSmashPigUnitTestCase;
+
+/**
+ * @group Ingenico
+ */
+class BankPaymentProviderTest extends BaseSmashPigUnitTestCase {
+
+ /**
+ * @var PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $curlWrapper;
+
+ public function setUp() {
+ $config = $this->setConfig( 'ingenico' );
+ $this->curlWrapper = $this->getMock(
'\SmashPig\Core\Http\CurlWrapper' );
+ $config->overrideObjectInstance( 'curl/wrapper',
$this->curlWrapper );
+ parent::setUp();
+ }
+
+ public function testGetBankList() {
+ $this->setUpResponse( 'productDirectory', 200 );
+ $provider = new BankPaymentProvider();
+ $results = $provider->getBankList( 'NL', 'EUR' );
+ $this->assertEquals(
+ array(
+ 'INGBNL2A' => 'Issuer Simulation V3 - ING'
+ ),
+ $results
+ );
+ }
+
+ protected function setUpResponse( $filename, $statusCode ) {
+ $contents = file_get_contents( __DIR__ .
"/../Data/$filename.response" );
+ $parsed = CurlWrapper::parseResponse(
+ $contents, array( 'http_code' => $statusCode )
+ );
+ $this->curlWrapper->method( 'execute' )->willReturn( $parsed );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/334733
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib22f3f18a184038e3c4c663083aed1c0069e5052
Gerrit-PatchSet: 10
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