Skip to content

Commit

Permalink
feat: add confirmation mode, when customer waits while operator confi…
Browse files Browse the repository at this point in the history
…rm the order
  • Loading branch information
Ivan Klimchuk committed Oct 12, 2021
1 parent 4f80aa1 commit 00c4020
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ class ConfigurablePaymentHandler {}
WebPay::OPTION_FAILURE_PAGE => ['xtype' => 'mspp-combo-resource', 'value' => 0],
WebPay::OPTION_UNPAID_PAGE => ['xtype' => 'mspp-combo-resource', 'value' => 0],
WebPay::OPTION_DEVELOPER_MODE => ['xtype' => 'combo-boolean', 'value' => true],
WebPay::OPTION_CONFIRMATION_MODE=> ['xtype' => 'combo-boolean', 'value' => false],
WebPay::OPTION_CHECKOUT_URL_TEST=> ['xtype' => 'textfield', 'value' => 'https://securesandbox.webpay.by'],
WebPay::OPTION_GATE_URL_TEST => ['xtype' => 'textfield', 'value' => 'https://sandbox.webpay.by'],
];

$settings = [];
foreach ($list as $k => $v) {
/** @var xPDO $xpdo */
$setting = $xpdo->newObject(modSystemSetting::class);
$setting->fromArray(array_merge([
'key' => WebPay::getPrefix() . '_' . $k,
Expand Down
3 changes: 3 additions & 0 deletions core/components/minishop2/lexicon/be/msp.webpay.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
$_lang['setting_ms2_payment_webpay_developer_mode'] = 'Рэжым здзяйснення тэставых плацяжоў';
$_lang['setting_ms2_payment_webpay_developer_mode_desc'] = 'Пры значэнні "Так", усе запыты аплаты будуць адпраўляцца на тэставую сераду апрацоўкі плацяжоў WebPay. Пры ўключэнні дадзенага рэжыму налады checkout_url і gate_url ігнаруюцца.';

$_lang['setting_ms2_payment_webpay_confirmation_mode'] = 'Рэжым пацверджання';
$_lang['setting_ms2_payment_webpay_confirmation_mode_desc'] = 'Пры значэнні «Так» пасля завяршэння замовы карыстальнік не будзе адпраўлены на старонку аплаты. Замест гэтага карыстальнік будзе прытрымлівацца патоку, калі заказ павінен быць пацверджаны перад аплатай. Пасля пацверджання будзе адпраўлена спасылка на старонку аплаты.';

$_lang['setting_ms2_payment_webpay_currency'] = 'Прапанаваная валюта плацяжу';
$_lang['setting_ms2_payment_webpay_currency_desc'] = 'Карыстальнік можа змяніць яе ў працэсе аплаты. Літарны трохзначны код валюты згодна ISO4271. Даступныя варыянты: BYN, USD, EUR, RUB. У рэжыме тэставання даступная толькі BYN.';

Expand Down
3 changes: 3 additions & 0 deletions core/components/minishop2/lexicon/en/msp.webpay.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
$_lang['setting_ms2_payment_webpay_developer_mode'] = 'Test mode of payments';
$_lang['setting_ms2_payment_webpay_developer_mode_desc'] = 'If the value "Yes", all requests payments will be send to a WebPay testing environment of payment processing. If you enabled this mode settings checkout_url and gate_url will be ignored.';

$_lang['setting_ms2_payment_webpay_confirmation_mode'] = 'Confirmation mode';
$_lang['setting_ms2_payment_webpay_confirmation_mode_desc'] = 'It the value "Yes", after order completed user won\'t be send to the payment page. Instead user will follow flow, when order should be confirmed before payment. After confirmation link to the payment page will be send.';

$_lang['setting_ms2_payment_webpay_currency'] = 'The proposed currency of payment';
$_lang['setting_ms2_payment_webpay_currency_desc'] = 'User can change it while paying. Literal-digit currency code according to ISO4271. Available variants: <strong>BYN</strong>, <strong>USD</strong>, <strong>EUR</strong>, <strong>RUB</strong>. In developer mode available only BYN.';

Expand Down
3 changes: 3 additions & 0 deletions core/components/minishop2/lexicon/ru/msp.webpay.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
$_lang['setting_ms2_payment_webpay_developer_mode'] = 'Режим совершения тестовых платежей';
$_lang['setting_ms2_payment_webpay_developer_mode_desc'] = 'При значении "Да", все запросы оплаты будут отправляться на тестовую среду обработки платежей WebPay. При включении данного режима настройки checkout_url и gate_url игнорируются.';

$_lang['setting_ms2_payment_webpay_confirmation_mode'] = 'Режим подтверждения';
$_lang['setting_ms2_payment_webpay_confirmation_mode_desc'] = 'При значении «Да» после завершения заказа пользователь не будет отправлен на страницу оплаты. Вместо этого пользователь будет следовать потоку, когда заказ должен быть подтвержден перед оплатой. После подтверждения будет отправлена ссылка на страницу оплаты.';

$_lang['setting_ms2_payment_webpay_currency'] = 'Предлагаемая валюта платежа';
$_lang['setting_ms2_payment_webpay_currency_desc'] = 'Пользователь может изменить ее в процессе оплаты. Буквенный трехзначный код валюты согласно ISO4271. Доступны варианты: BYN, USD, EUR, RUB. В режиме тестирования доступна только BYN.';

Expand Down
7 changes: 7 additions & 0 deletions core/components/mspwebpay/WebPay.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class WebPay extends ConfigurablePaymentHandler
public const OPTION_CURRENCY = 'currency';

public const OPTION_DEVELOPER_MODE = 'developer_mode';
public const OPTION_CONFIRMATION_MODE = 'confirmation_mode';
public const OPTION_CHECKOUT_URL_TEST = 'checkout_url_test';
public const OPTION_GATE_URL_TEST = 'gate_url_test';

Expand Down Expand Up @@ -81,6 +82,12 @@ public function __construct(xPDOObject $object, $config = [])
*/
public function send(msOrder $order)
{
$this->config = $this->getProperties($order->getOne('Payment'));

if ($this->config[self::OPTION_CONFIRMATION_MODE]) {
return parent::send($order);
}

if (!$link = $this->getPaymentLink($order)) {
return $this->error('Token and redirect url can not be requested. Please, look at error log.');
}
Expand Down

0 comments on commit 00c4020

Please sign in to comment.