From 9219802d90d02154f72f0b715f9f6bf04a0825cf Mon Sep 17 00:00:00 2001 From: Dmitry Fedyuk Date: Mon, 4 Sep 2017 03:40:50 +0300 Subject: [PATCH] 0.1.4 --- Charge.php | 103 ++++++++++++++++++++++++++++++++++++++++++++---- Init/Action.php | 27 +++++++++++-- composer.json | 2 +- 3 files changed, 119 insertions(+), 13 deletions(-) diff --git a/Charge.php b/Charge.php index 45b572d..729ef41 100644 --- a/Charge.php +++ b/Charge.php @@ -8,19 +8,106 @@ */ final class Charge extends \Df\Payment\Charge { /** - * 2017-09-03 - * @used-by p() + * 2017-09-04 Our local (without the module prefix) internal payment ID. + * @override + * @see \Df\Payment\Operation::id() + * @used-by pRedirect() + * @used-by \Dfe\Qiwi\Init\Action::transId() + * @return string + */ + function id() {return dfc($this, function() {return Identification::get($this->o());});} + + /** + * 2017-09-04 + * @used-by \Dfe\Qiwi\Init\Action::req() * @return array(string, array(string => mixed)) */ - private function pCharge() {$s = $this->s(); return [];} + function pBill() {$s = $this->s(); return [ + + ];} /** - * 2017-09-03 + * 2017-09-04 * @used-by \Dfe\Qiwi\Init\Action::req() * @return array(string, array(string => mixed)) */ - static function p() { - $i = new self(dfpm(__CLASS__)); /** @var self $i */ - return [Identification::get($i->o()), $i->pCharge()]; - } + function pRedirect() {$s = $this->s(); return [ + // 2017-09-04 + // «The URL to which the payer will be redirected + // when creation of Visa QIWI Wallet transaction is unsuccessful. + // URL must be within merchant's site.» + // «URL для переадресации в случае неуспеха при создании транзакции в Visa QIWI Wallet. + // Ссылка должна вести на сайт провайдера. + // Если пользователь выбрал на платежной форме способ оплаты, + // отличный от оплаты с баланса Visa QIWI Wallet, + // то переадресация на сайт провайдера не выполняется.» + // Optional, string. + 'failUrl' => $this->customerReturnRemoteWithFailure() + // 2017-09-04 + // «This parameter (if true) means that invoice page would be opened in "iframe". + // The checkout page appears more compact + // and can be embedded conveniently within the merchant’s site. + // Default value is false.» + // «Признак отображения страницы в iframe + // (более компактный вид, удобный для встраивания ее в сайт провайдера). + // По умолчанию false» + // Optional, true/false. + ,'iframe' => false + // 2017-09-04 + // «Accepts mobile, qw, card, wm, ssk. + // Default payment method to show first for the client. + // Allowed values: + // card – a credit/debit card; + // mobile – client’s cell phone account; + // qw – Visa QIWI Wallet account; + // ssk – payment by cash in a QIWI Terminal; + // wm – linked WebMoney wallet. + // When specified method is inaccessible for the Customer, + // the page contains notice about it and the client can choose another method.» + // «Способ оплаты по умолчанию, + // который необходимо отобразить пользователю при открытии платежной формы. + // Возможные значения: + // card – оплата банковской картой; + // mobile – оплата с баланса мобильного телефона; + // qw – оплата с баланса Visa QIWI Wallet; + // ssk – оплата наличными в терминале QIWI; + // wm – оплата с привязанного кошелька WebMoney. + // Если способ оплаты не доступен, пользователю отображается предупреждение, + // при этом на странице можно выбрать другие способы оплаты.» + // Optional, string. + ,'pay_source' => '' + // 2017-09-04 + // «Merchant’s ID in Visa QIWI Wallet system, + // corresponds to {prv_id} parameter used to create the bill.» + // «Идентификатор провайдера. + // Соответствует параметру {prv_id} из запроса на выставление счета.» + // Required, string. + ,'shop' => $s->merchantID() + // 2017-09-04 + // «The URL to which the payer will be redirected + // in case of successful creation of Visa QIWI Wallet transaction. + // URL must be within merchant's site» + // «URL для переадресации в случае успешного создания транзакции в Visa QIWI Wallet. + // Ссылка должна вести на сайт провайдера. + // Если пользователь выбрал на платежной форме способ оплаты, + // отличный от оплаты с баланса Visa QIWI Wallet, + // то переадресация на сайт провайдера не выполняется.» + // Optional, string. + ,'successUrl' => $this->customerReturnRemote() + // 2017-09-04 + // «"iframe" or empty. + // This parameter means that hyperlink specified in successUrl / failUrl parameter + // opens in "iframe" page.» + // «Флаг, показывающий, что ссылки в параметрах successUrl / failUrl открываются в iframe. + // Если отсутствует, то считается выключенным.» + // Optional, string. + ,'target' => '' + // 2017-09-04 + // «Invoice ID generated by the merchant, + // corresponds to `bill_id` parameter used to create the bill.» + // «Идентификатор счета в информационной системе провайдера. + // Соответствует параметру `bill_id` из запроса на выставление счета.». + // Required, string. + ,'transaction' => $this->id() + ];} } \ No newline at end of file diff --git a/Init/Action.php b/Init/Action.php index c39842c..18e47fc 100644 --- a/Init/Action.php +++ b/Init/Action.php @@ -16,31 +16,42 @@ final class Action extends \Df\Payment\Init\Action { * «4.3. Переадресация для оплаты счета», страница 9. * «Провайдер может предложить пользователю немедленно оплатить счет * с помощью переадресации на страницу оплаты». + * 2017-09-04 + * https://github.com/QIWI-API/pull-payments-docs/blob/40d48cf0/_checkout_en.html.md#checkout-checkout_en + * https://github.com/QIWI-API/pull-payments-docs/blob/40d48cf0/_checkout_ru.html.md#Форма-оплаты-checkout_ru + * https://developer.qiwi.com/ru/pull-payments/index.html#checkout_ru * @override * @see \Df\Payment\Init\Action::redirectUrl() * @used-by \Df\Payment\Init\Action::action() * @return string */ - protected function redirectUrl() {return 'https://bill.qiwi.com/order/external/main.action';} + protected function redirectUrl() {return + 'https://bill.qiwi.com/order/external/main.action?' . http_build_query($this->charge()->pRedirect()) + ;} /** - * 2017-09-03 + * 2017-09-04 + * QIWI Wallet does not provide its own payment ID in a payment response: + * `An example of a response to «PUT https://api.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}»` + * https://mage2.pro/t/4447 + * So we use our internal payment ID as a base for the corresponding Magento transaction ID. * @override * @see \Df\Payment\Init\Action::transId() * @used-by \Df\Payment\Init\Action::action() * @used-by action() * @return string|null */ - protected function transId() {return $this->e2i('', Ev::T_INIT);} + protected function transId() {return $this->e2i($this->charge()->id(), Ev::T_INIT);} /** * 2017-09-03 + * @used-by id() * @used-by res() * @return array(string => mixed) */ private function req() {return dfc($this, function() { /** @var M $m */ /** @var array(string => mixed) $result */ - df_sentry_extra($m = $this->m(), 'Request Params', $result = Charge::p()); + df_sentry_extra($m = $this->m(), 'Request Params', $result = $this->charge()->pBill()); $m->iiaSetTRR($result); return $result; });} @@ -57,4 +68,12 @@ private function res() {return dfc($this, function() { dfp_report($m, $r, 'response'); return $r; });} + + /** + * 2017-09-04 + * @used-by req() + * @used-by transId() + * @return Charge + */ + private function charge() {return dfc($this, function() {return new Charge($this->m());});} } \ No newline at end of file diff --git a/composer.json b/composer.json index 7233c48..6d4ab50 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mage2pro/qiwi" - ,"version": "0.1.3" + ,"version": "0.1.4" ,"description": "The «Visa QIWI Wallet» (QIWI Кошелёк) payment extension for Magento 2." ,"type": "magento2-module" ,"homepage": "https://mage2.pro/c/extensions/qiwi"