-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
933e8a8
commit b92a6fb
Showing
10 changed files
with
275 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
namespace Dfe\Qiwi\API; | ||
use Dfe\Qiwi\Settings as S; | ||
// 2017-09-03 | ||
final class Client extends \Df\API\Client { | ||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Client::_construct() | ||
* @used-by \Df\API\Client::__construct() | ||
*/ | ||
protected function _construct() { | ||
parent::_construct(); | ||
$this->resJson(); | ||
/** | ||
* [QIWI Wallet] An example of a response to | ||
* «PUT https://api.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}» | ||
* https://mage2.pro/t/4447 | ||
*/ | ||
$this->addFilterRes(function($v) {return $v['response'];}); | ||
} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Client::headers() | ||
* @used-by \Df\API\Client::__construct() | ||
* @used-by \Df\API\Client::p() | ||
* @return array(string => string) | ||
*/ | ||
protected function headers() {/** @var S $s */$s = $this->s(); return [ | ||
/** | ||
* 2017-09-03 | ||
* «Authentication data are transmitted using the standard rules of basic-authorization for HTTP-requests. | ||
* The HTTP header "Authorization" is added to the request. | ||
* The value of this parameter is composed of the word "Basic", | ||
* blank character and encrypted BASE64 pair "API ID:API password"». | ||
* «Авторизационные данные передаются по стандартным правилам basic-аутентификации при запросах по HTTP. | ||
* К запросу добавляется HTTP-заголовок с параметром "Authorization". | ||
* В заголовке указывается строка "Basic " (с пробелом на конце) | ||
* и пара "API_ID:API_password", закодированная в BASE64.» | ||
* `[QIWI Wallet] The REST API specification (v.2.12)`, page 7: https://mage2.pro/t/3745 | ||
* https://en.wikipedia.org/wiki/Basic_access_authentication | ||
*/ | ||
'Authorization' => 'Basic ' . base64_encode("{$s->apiID()}:{$s->password1()}") | ||
/** | ||
* 2017-09-03 | ||
* «Requests from the merchants to QIWI | ||
* are sent in the format of the HTTP-request parameters encoded by UTF-8. | ||
* In response, the data is returned in one of two formats | ||
* in accordance with the value of the "Accept" HTTP header, which is transmitted in the request: | ||
* XML (value of the "Accept" header: "application/xml", "text/xml"); | ||
* JSON (value of the "Accept" header: "application/json", "text/json").» | ||
* «Данные при запросах на сервер Visa QIWI Wallet | ||
* передаются в формате параметров HTTP-запроса в кодировке UTF-8. | ||
* В ответ данные возвращаются в одном из двух форматов | ||
* в соответствии со значением HTTP-заголовка "Accept", передаваемого в запросе: | ||
* XML (значения заголовка "Accept": "application/xml", "text/xml"); | ||
* JSON (значения заголовка "Accept": "application/json", "text/json").» | ||
*/ | ||
,'Accept' => 'application/json' | ||
];} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @see \Df\API\Client::responseValidatorC() | ||
* @used-by \Df\API\Client::p() | ||
* @return string | ||
*/ | ||
final protected function responseValidatorC() {return \Dfe\Qiwi\API\Validator::class;} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Client::uriBase() | ||
* @used-by \Df\API\Client::__construct() | ||
* @used-by \Df\API\Client::_p() | ||
* @return string | ||
*/ | ||
protected function uriBase() {return "https://api.qiwi.com/api/v2/prv/{$this->s()->merchantID()}/bills";} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @used-by headers() | ||
* @used-by uriBase() | ||
* @return S | ||
*/ | ||
private function s() {return dfps($this);} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
namespace Dfe\Qiwi\API; | ||
/** | ||
* 2017-09-03 | ||
* [QIWI Wallet] An example of a response to «PUT https://api.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}» | ||
* https://mage2.pro/t/4447 | ||
* @used-by \Dfe\Qiwi\API\Client::responseValidatorC() | ||
*/ | ||
final class Validator extends \Df\API\Response\Validator { | ||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Exception::long() | ||
* @used-by \Df\API\Client::p() | ||
* @return string | ||
*/ | ||
function long() {return '';} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Exception::short() | ||
* @used-by \Df\API\Client::p() | ||
* @return string | ||
*/ | ||
function short() {return '';} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\API\Response\Validator::valid() | ||
* @used-by \Df\API\Response\Validator::validate() | ||
* @return bool | ||
*/ | ||
function valid() {return !$this->rCode();} | ||
|
||
/** | ||
* 2017-09-03 `[QIWI Wallet] API error codes`: https://mage2.pro/t/4448 | ||
* @used-by valid() | ||
* @return int | ||
*/ | ||
private function rCode() {return dfc($this, function() {return | ||
intval(dfa($this->r(), 'result_code')) | ||
;});} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,23 @@ | ||
<?php | ||
namespace Dfe\Qiwi; | ||
/** | ||
* 2017-04-18 | ||
* 2017-09-03 | ||
* @method Method m() | ||
* @method Settings s() | ||
*/ | ||
final class Charge extends \Df\PaypalClone\Charge { | ||
final class Charge extends \Df\Payment\Charge { | ||
/** | ||
* 2017-08-19 | ||
* @override | ||
* @see \Df\PaypalClone\Charge::k_Amount() | ||
* @used-by \Df\PaypalClone\Charge::p() | ||
* @return string | ||
*/ | ||
protected function k_Amount() {return '';} | ||
|
||
/** | ||
* 2017-08-19 | ||
* @override | ||
* @see \Df\PaypalClone\Charge::k_MerchantId() | ||
* @used-by \Df\PaypalClone\Charge::p() | ||
* @return string | ||
*/ | ||
protected function k_MerchantId() {return '';} | ||
|
||
/** | ||
* 2017-04-18 | ||
* @override | ||
* @see \Df\PaypalClone\Charge::k_RequestId() | ||
* @used-by \Df\PaypalClone\Charge::p() | ||
* @return string | ||
*/ | ||
protected function k_RequestId() {return '';} | ||
|
||
/** | ||
* 2017-04-18 | ||
* @override | ||
* @see \Df\PaypalClone\Charge::k_Signature() | ||
* @used-by \Df\PaypalClone\Charge::p() | ||
* @return string | ||
* 2017-09-03 | ||
* @used-by p() | ||
* @return array(string => mixed) | ||
*/ | ||
protected function k_Signature() {return '';} | ||
private function pCharge() {$s = $this->s(); return [];} | ||
|
||
/** | ||
* 2017-04-18 | ||
* @override | ||
* @see \Df\PaypalClone\Charge::pCharge() | ||
* @used-by \Df\PaypalClone\Charge::p() | ||
* @return array(string => mixed) | ||
* 2017-09-03 | ||
* @used-by \Dfe\Qiwi\Init\Action::req() | ||
* @param Method $m | ||
* @return array(string, array(string => mixed)) | ||
*/ | ||
protected function pCharge() {$s = $this->s(); return [];} | ||
static function p(Method $m) {return (new self($m))->pCharge();} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
namespace Dfe\Qiwi\W; | ||
use Magento\Sales\Model\Order\Payment\Transaction as T; | ||
/** | ||
* 2017-09-03 | ||
*/ | ||
final class Event extends \Df\PaypalClone\W\Event { | ||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\PaypalClone\W\Event::k_idE() | ||
* @used-by \Df\PaypalClone\W\Event::idE() | ||
* @return string | ||
*/ | ||
protected function k_idE() {return '';} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\Payment\W\Event::k_pid() | ||
* @used-by \Df\Payment\W\Event::pid() | ||
* @return string | ||
*/ | ||
protected function k_pid() {return '';} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\PaypalClone\W\Event::k_signature() | ||
* @used-by \Df\PaypalClone\W\Event::signatureProvided() | ||
* @return string | ||
*/ | ||
protected function k_signature() {return '';} | ||
|
||
/** | ||
* 2017-09-03 | ||
* @override | ||
* @see \Df\PaypalClone\W\Event::k_status() | ||
* @used-by \Df\PaypalClone\W\Event::status() | ||
* @return string | ||
*/ | ||
protected function k_status() {return '';} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
0,"Success" | ||
5,"Incorrect data in the request parameters" | ||
13,"Server is busy, try again later" | ||
78,"Operation is forbidden" | ||
150,"Authorization error (e.g. invalid login/password)" | ||
152,"Protocol is not enabled or protocol is disabled" | ||
155,"This merchant’s identifier (API ID) is blocked" | ||
210,"Invoice not found" | ||
215,"Invoice with this bill_id already exists" | ||
241,"Invoice amount is less than allowed" | ||
242,"Invoice amount is greater than allowed. Also returns to refund request when the amount of refund exceeds the initial invoice amount or the amount left after the previous refunds" | ||
298,"User not registered" | ||
300,"Technical error" | ||
303,"Wrong phone number" | ||
316,"Authorization from the blocked merchant" | ||
319,"No rights for the operation" | ||
339,"IP-addresses blocked" | ||
341,"Required parameter is incorrectly specified or absent in the request" | ||
700,"Monthly limit on operations is exceeded" | ||
774,"Visa QIWI Wallet user account temporarily blocked" | ||
1001,"Currency is not allowed for the merchant" | ||
1003,"No convert rate for these currencies" | ||
1019,"Unable to determine wireless operator for MNO balance payment" | ||
1419,"Bill was already payed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
0,"Успех" | ||
5,"Неверные данные в параметрах запроса" | ||
13,"Сервер занят, повторите запрос позже" | ||
78,"Недопустимая операция" | ||
150,"Ошибка авторизации" | ||
152,"Не подключен или отключен протокол" | ||
155,"Данный идентификатор провайдера (API ID) заблокирован" | ||
210,"Счет не найден" | ||
215,"Счет с таким bill_id уже существует" | ||
241,"Сумма слишком мала" | ||
242,"Сумма слишком велика, или сумма, переданная в запросе возврата средств, превышает сумму самого счета либо сумму счета, оставшуюся после предыдущих возвратов" | ||
298,"Кошелек с таким номером не зарегистрирован" | ||
300,"Техническая ошибка" | ||
303,"Неверный номер телефона" | ||
316,"Попытка авторизации заблокированным провайдером" | ||
319,"Нет прав на данную операцию" | ||
339,"Ваш IP-адрес или массив адресов заблокирован" | ||
341,"Обязательный параметр указан неверно или отсутствует в запросе" | ||
700,"Превышен месячный лимит на операции" | ||
774,"Кошелек временно заблокирован" | ||
1001,"Запрещенная валюта для провайдера" | ||
1003,"Не удалось получить курс конвертации для данной пары валют" | ||
1019,"Не удалось определить сотового оператора для мобильной коммерции" | ||
1419,"Нельзя изменить данные счета – он уже оплачивается или оплачен" |