From 0afff0980f1606108c4b184f5ddf9e48622d4c77 Mon Sep 17 00:00:00 2001 From: Hoyt Date: Thu, 22 Jul 2021 14:52:51 +0800 Subject: [PATCH] Update: Cancel automatic payment redirection, it is now an optional configuration item --- README.md | 2 ++ modules/gateways/mugglepay.php | 30 +++++++++++++++++++++--------- readme-zh-CN.md | 2 ++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 38c0d3d..1ca1859 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ English | [简体中文](./readme-zh-CN.md) ![image.png](https://i.loli.net/2021/07/19/RAE4xvd9m8lP6wa.png) # Changelog +## 1.0.2 ## +1. Cancel automatic payment redirection, it is now an optional configuration item ## 1.0.1 ## 1. Allow custom payment methods 2. Add JS URLSearchParams polyfill diff --git a/modules/gateways/mugglepay.php b/modules/gateways/mugglepay.php index 916967f..f473839 100644 --- a/modules/gateways/mugglepay.php +++ b/modules/gateways/mugglepay.php @@ -37,6 +37,11 @@ function mugglepay_config() ), 'Description' => '
The currency in which you wish to price your merchandise; used to define price parameter.', ), + 'mp_pay_auto_redirect' => array( + 'FriendlyName' => 'Automatic Redirect Payment URL', + 'Type' => 'yesno', + 'Description' => '
是否在创建支付订单后,自动重定向到 MugglePay 支付页面而不是订单详情页,勾选将自动跳转
请注意如果开启自动跳转,用户可能在续费支付时直接进入支付页面从而无法选择其他支付方式', + ), 'mp_pay_currency' => array( 'FriendlyName' => 'Pay Currency', 'Description' => 'Set the MugglePay default payment gateway', @@ -142,20 +147,27 @@ function mugglepay_link($params) default: $lang = $params["clientdetails"]["language"] === 'chinese' ? 'zh' : 'en'; $raw_response->payment_url .= '&lang=' . $lang; - return << - $(document).ready(function() { - setTimeout(function() { - window.location = "{$raw_response->payment_url}"; - }, 1000) - }) - + + $html = ''; + if( $params['mp_pay_auto_redirect'] === 'on' ) { + $html = << + $(document).ready(function() { + setTimeout(function() { + window.location = "{$raw_response->payment_url}"; + }, 1000) + }) + + HTML; + } + $html .= << {$params["langpaynow"]} - EOT; + HTML; + return $html; break; } } else { diff --git a/readme-zh-CN.md b/readme-zh-CN.md index 2ef5d7a..16349b8 100644 --- a/readme-zh-CN.md +++ b/readme-zh-CN.md @@ -23,6 +23,8 @@ ![image.png](https://i.loli.net/2021/07/19/RAE4xvd9m8lP6wa.png) # Changelog +## 1.0.2 ## +1. 取消自动支付重定向,转为可选配置项 ## 1.0.1 ## 1. 允许自定义多个支付网关 2. 添加 JS URLSearchParams 垫片