Skip to content

Commit

Permalink
0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 4, 2017
1 parent 13a081d commit 9219802
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 13 deletions.
103 changes: 95 additions & 8 deletions Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
];}
}
27 changes: 23 additions & 4 deletions Init/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});}
Expand All @@ -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());});}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 9219802

Please sign in to comment.