diff --git a/app/Http/Controllers/Admin/ConfigController.php b/app/Http/Controllers/Admin/ConfigController.php index 83d96e4d..1aa3ef85 100755 --- a/app/Http/Controllers/Admin/ConfigController.php +++ b/app/Http/Controllers/Admin/ConfigController.php @@ -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'), diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php index 3001c80d..ab9296c4 100755 --- a/app/Http/Controllers/User/OrderController.php +++ b/app/Http/Controllers/User/OrderController.php @@ -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' diff --git a/app/Http/Requests/Admin/ConfigSave.php b/app/Http/Requests/Admin/ConfigSave.php index de2f5d98..84c608f5 100755 --- a/app/Http/Requests/Admin/ConfigSave.php +++ b/app/Http/Requests/Admin/ConfigSave.php @@ -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' => '',