support stripe currency

This commit is contained in:
Tokumeikoi 2020-03-05 00:06:40 +08:00
parent e73eaea66c
commit a3837f83cb
3 changed files with 8 additions and 4 deletions

View File

@ -50,6 +50,7 @@ class ConfigController extends Controller
'stripe_alipay_enable' => (int)config('v2board.stripe_alipay_enable'),
'stripe_wepay_enable' => (int)config('v2board.stripe_wepay_enable'),
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
'stripe_currency' => config('v2board.stripe_currency', 'hkd'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret'),

View File

@ -406,14 +406,15 @@ class OrderController extends Controller
private function stripeAlipay($order)
{
$exchange = Helper::exchange('CNY', 'HKD');
$currency = config('stripe_currency', 'hkd');
$exchange = Helper::exchange('CNY', strtoupper($currency));
if (!$exchange) {
abort(500, '货币转换超时,请稍后再试');
}
Stripe::setApiKey(config('v2board.stripe_sk_live'));
$source = Source::create([
'amount' => floor($order->total_amount * $exchange),
'currency' => 'hkd',
'currency' => $currency,
'type' => 'alipay',
'redirect' => [
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'
@ -431,14 +432,15 @@ class OrderController extends Controller
private function stripeWepay($order)
{
$exchange = Helper::exchange('CNY', 'HKD');
$currency = config('stripe_currency', 'hkd');
$exchange = Helper::exchange('CNY', strtoupper($currency));
if (!$exchange) {
abort(500, '货币转换超时,请稍后再试');
}
Stripe::setApiKey(config('v2board.stripe_sk_live'));
$source = Source::create([
'amount' => floor($order->total_amount * $exchange),
'currency' => 'hkd',
'currency' => $currency,
'type' => 'wechat',
'redirect' => [
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'

View File

@ -41,6 +41,7 @@ class ConfigSave extends FormRequest
'stripe_sk_live' => '',
'stripe_pk_live' => '',
'stripe_webhook_key' => '',
'stripe_currency' => 'in:hkd,usd,sgd',
// bitpayx
'bitpayx_enable' => 'in:0,1',
'bitpayx_appsecret' => '',