support bitpayx, notify is not work

This commit is contained in:
root 2019-12-27 01:50:26 +08:00
parent 9385add291
commit d197566922
3 changed files with 46 additions and 1 deletions

View File

@ -44,7 +44,10 @@ class ConfigController extends Controller
'stripe_pk_live' => config('v2board.stripe_pk_live'),
'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_webhook_key' => config('v2board.stripe_webhook_key'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret')
],
'server' => [
'server_token' => config('v2board.server_token')

View File

@ -13,6 +13,7 @@ use App\Utils\Helper;
use Omnipay\Omnipay;
use Stripe\Stripe;
use Stripe\Source;
use Library\BitpayX;
class OrderController extends Controller
{
@ -142,6 +143,15 @@ class OrderController extends Controller
'type' => 0,
'data' => $this->stripeWepay($order)
]);
case 4:
// bitpayX
if (!(int)config('v2board.bitpayx_enable')) {
abort(500, '支付方式不可用');
}
return response([
'type' => 1,
'data' => $this->bitpayX($order)
]);
default:
abort(500, '支付方式不存在');
}
@ -186,6 +196,14 @@ class OrderController extends Controller
array_push($data, $stripeWepay);
}
if ((int)config('v2board.bitpayx_enable')) {
$bitpayX = new \StdClass();
$bitpayX->name = '虚拟货币';
$bitpayX->method = 4;
$bitpayX->icon = 'bitcoin';
array_push($data, $bitpayX);
}
return response([
'data' => $data
]);
@ -262,4 +280,23 @@ class OrderController extends Controller
Redis::expire($source['id'], 3600);
return $source['wechat']['qr_code_url'];
}
private function bitpayX ($order) {
$bitpayX = new BitpayX(config('v2board.bitpayx_appsecret'));
$params = [
'merchant_order_id' => 'V2Board_' . $order->trade_no,
'price_amount' => $order->total_amount / 100,
'price_currency' => 'CNY',
'title' => '支付单号:' . $order->trade_no,
'description' => '充值:' . $order->total_amount / 100 . ' 元',
'callback_url' => url('/api/v1/guest/order/bitpayXNotify'),
'success_url' => config('v2board.app_url', env('APP_URL')) . '/#/order',
'cancel_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'
];
$strToSign = $bitpayX->prepareSignId($params['merchant_order_id']);
$params['token'] = $bitpayX->sign($strToSign);
$result = $bitpayX->mprequest($params);
Log::info('bitpayXSubmit: ' . json_encode($result));
return isset($result['payment_url']) ? $result['payment_url'] : false;
}
}

View File

@ -32,6 +32,9 @@ class ConfigSave extends FormRequest
'stripe_alipay_enable',
'stripe_wepay_enable',
'stripe_webhook_key',
// bitpayx,
'bitpayx_enable',
'bitpayx_appsecret',
// tutorial
'apple_id',
'apple_id_password'
@ -65,6 +68,8 @@ class ConfigSave extends FormRequest
// stripe
'stripe_alipay_enable' => 'in:0,1',
'stripe_wepay_enable' => 'in:0,1',
// bitpayx
'bitpayx_enable' => 'in:0,1',
// tutorial
'apple_id' => 'email'
];