Mepps has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/366565 )
Change subject: WIP Approve and Cancel payment
......................................................................
WIP Approve and Cancel payment
Bug: T163952
Change-Id: I17545aeb79eef027b046dfab62b3df40763677d0
---
M PaymentProviders/Ingenico/IngenicoPaymentProvider.php
A PaymentProviders/Ingenico/Tests/Data/approvedPayment.response
M PaymentProviders/Ingenico/Tests/phpunit/IngenicoPaymentProviderTest.php
3 files changed, 71 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig
refs/changes/65/366565/1
diff --git a/PaymentProviders/Ingenico/IngenicoPaymentProvider.php
b/PaymentProviders/Ingenico/IngenicoPaymentProvider.php
index e30a10e..83633d3 100644
--- a/PaymentProviders/Ingenico/IngenicoPaymentProvider.php
+++ b/PaymentProviders/Ingenico/IngenicoPaymentProvider.php
@@ -24,4 +24,21 @@
$response = $this->api->makeApiCall($path, 'GET');
return $response;
}
+
+ public function approvePayment($paymentId){
+ $path = "payments/$paymentId/approve";
+ $params = array(
+ "directDebitPaymentMethodSpecificInput" => array(
+ "dateCollect" => Date("Ymd"),
+// "token" => $token, //FIXME: do we need this?
+ ),
+ "order" => array(
+ "references" => array(
+// "merchantReference" =>
$this->api->merchantId, //FIXME: Do we need this?
+ ),
+ ),
+ );
+ $response = $this->api->makeApiCall($path, 'POST', $params);
+ return $response;
+ }
}
diff --git a/PaymentProviders/Ingenico/Tests/Data/approvedPayment.response
b/PaymentProviders/Ingenico/Tests/Data/approvedPayment.response
new file mode 100644
index 0000000..ac311f9
--- /dev/null
+++ b/PaymentProviders/Ingenico/Tests/Data/approvedPayment.response
@@ -0,0 +1,42 @@
+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
+
+{
+ "payment": {
+ "id": "000000850010000188180000200001",
+ "paymentOutput": {
+ "amountOfMoney": {
+ "amount": 2890,
+ "currencyCode": "EUR"
+ },
+ "references": {
+ "paymentReference": "0"
+ },
+ "paymentMethod": "card",
+ "cardPaymentMethodSpecificOutput": {
+ "paymentProductId": 1,
+ "authorisationCode": "123456",
+ "card": {
+ "cardNumber": "************7977",
+ "expiryDate": "1220"
+ },
+ "fraudResults": {
+ "avsResult": "0",
+ "cvvResult": "M",
+ "fraudServiceResult": "no-advice"
+ }
+ }
+ },
+ "status": "CAPTURE_REQUESTED",
+ "statusOutput": {
+ "isCancellable": false,
+ "statusCode": 800,
+ "statusCodeChangeDateTime": "20140627140735",
+ "isAuthorized": true
+ }
+ }
+}
\ No newline at end of file
diff --git
a/PaymentProviders/Ingenico/Tests/phpunit/IngenicoPaymentProviderTest.php
b/PaymentProviders/Ingenico/Tests/phpunit/IngenicoPaymentProviderTest.php
index eaa54a6..d78e474 100644
--- a/PaymentProviders/Ingenico/Tests/phpunit/IngenicoPaymentProviderTest.php
+++ b/PaymentProviders/Ingenico/Tests/phpunit/IngenicoPaymentProviderTest.php
@@ -32,4 +32,16 @@
$response = $this->provider->getPaymentStatus($paymentId);
$this->assertEquals($paymentId, $response['id']);
}
+
+ public function testApprovePayment(){
+ $paymentId = '000000850010000188180000200001';
+ $this->setUpResponse(__DIR__ . '/../Data/approvedPayment.response',
200);
+ $this->curlWrapper->expects( $this->once() )
+ ->method( 'execute' )->with(
+
$this->equalTo("https://api-sandbox.globalcollect.com/v1/1234/payments/$paymentId/approve"),
+ $this->equalTo('POST')
+ );
+ $response = $this->provider->approvePayment($paymentId);
+ $this->assertEquals($paymentId, $response['payment']['id']);
+ }
}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/366565
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17545aeb79eef027b046dfab62b3df40763677d0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Mepps <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits