Skip to content

Commit

Permalink
Update: Cancel automatic payment redirection, it is now an optional c…
Browse files Browse the repository at this point in the history
…onfiguration item
  • Loading branch information
hoythan committed Jul 22, 2021
1 parent 1a62d31 commit 0afff09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 21 additions & 9 deletions modules/gateways/mugglepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function mugglepay_config()
),
'Description' => '<br>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' => '<br>是否在创建支付订单后,自动重定向到 MugglePay 支付页面而不是订单详情页,勾选将自动跳转<br>请注意如果开启自动跳转,用户可能在续费支付时直接进入支付页面从而无法选择其他支付方式',
),
'mp_pay_currency' => array(
'FriendlyName' => 'Pay Currency',
'Description' => 'Set the MugglePay default payment gateway',
Expand Down Expand Up @@ -142,20 +147,27 @@ function mugglepay_link($params)
default:
$lang = $params["clientdetails"]["language"] === 'chinese' ? 'zh' : 'en';
$raw_response->payment_url .= '&lang=' . $lang;
return <<<EOT
<script>
$(document).ready(function() {
setTimeout(function() {
window.location = "{$raw_response->payment_url}";
}, 1000)
})
</script>

$html = '';
if( $params['mp_pay_auto_redirect'] === 'on' ) {
$html = <<<HTML
<script>
$(document).ready(function() {
setTimeout(function() {
window.location = "{$raw_response->payment_url}";
}, 1000)
})
</script>
HTML;
}
$html .= <<<HTML
<form action="viewinvoice.php?id={$params["invoiceid"]}" method="POST" enctype="text/plain">
<a href="{$raw_response->payment_url}" class="btn btn-primary btn-sm btn-block spinner-on-click">
{$params["langpaynow"]}
</a>
</form>
EOT;
HTML;
return $html;
break;
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions readme-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 垫片
Expand Down

0 comments on commit 0afff09

Please sign in to comment.