From 120f781bfd393566ce82558560b6acd0fd874379 Mon Sep 17 00:00:00 2001 From: atnartur Date: Mon, 20 Apr 2020 13:48:32 +0300 Subject: [PATCH 1/3] Add getCommissions method support --- UnitPay.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/UnitPay.php b/UnitPay.php index b9fddd9..3832035 100644 --- a/UnitPay.php +++ b/UnitPay.php @@ -76,10 +76,15 @@ public function getPrice() class UnitPay { private $supportedCurrencies = array('EUR','UAH', 'BYR', 'USD','RUB'); - private $supportedUnitpayMethods = array('initPayment', 'getPayment'); + private $supportedUnitpayMethods = array( + 'initPayment', + 'getPayment', + 'getCommissions', + ); private $requiredUnitpayMethodsParams = array( 'initPayment' => array('desc', 'account', 'sum'), - 'getPayment' => array('paymentId') + 'getPayment' => array('paymentId'), + 'getCommissions' => array('projectId', 'login') ); private $supportedPartnerMethods = array('check', 'pay', 'error'); private $supportedUnitpayIp = array( @@ -344,4 +349,4 @@ public function getErrorHandlerResponse($message) ) )); } -} \ No newline at end of file +} From a8a49d29f3f249a9a24b2fb8f247cf5621224930 Mon Sep 17 00:00:00 2001 From: atnartur Date: Wed, 22 Apr 2020 23:46:41 +0300 Subject: [PATCH 2/3] Add massPayment and massPaymentStatus methods --- UnitPay.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UnitPay.php b/UnitPay.php index 3832035..3f970d3 100644 --- a/UnitPay.php +++ b/UnitPay.php @@ -80,11 +80,15 @@ class UnitPay 'initPayment', 'getPayment', 'getCommissions', + 'massPayment', + 'massPaymentStatus', ); private $requiredUnitpayMethodsParams = array( 'initPayment' => array('desc', 'account', 'sum'), 'getPayment' => array('paymentId'), - 'getCommissions' => array('projectId', 'login') + 'getCommissions' => array('projectId', 'login'), + 'massPayment' => array('login', 'purse', 'transactionId', 'sum', 'paymentType'), + 'massPaymentStatus' => array('login', 'transactionId'), ); private $supportedPartnerMethods = array('check', 'pay', 'error'); private $supportedUnitpayIp = array( From 7d68b1fabdcefec11967184d4e4024c4ef0a32b9 Mon Sep 17 00:00:00 2001 From: atnartur Date: Thu, 23 Apr 2020 14:33:51 +0300 Subject: [PATCH 3/3] Add mass payments in readme --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/README.md b/README.md index a566ecf..9d655d0 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,71 @@ try { } ``` +### Mass payment (withdraw) integration using UnitPay API + +```php +api('massPayment', [ + 'sum' => $orderSum, + 'purse' => $purse, + 'login' => $login, + 'transactionId' => $transactionId, + 'paymentType' => $paymentType, + 'projectId' => $projectId, +]); + +// If need user redirect on Payment Gate +if (isset($response->result)) { + // success result + $statusResponse = $unitpay->api('massPaymentStatus', [ + 'login' => $login, + 'transactionId' => $transactionId + ]); + echo 'Mass payment status: ' . $statusResponse->result->status; +} elseif (isset($response->error->message)) { + $error = $response->error->message; + print 'Error: '.$error; +} +``` + ## Installation ### Install composer package