1:安装stripe包
composer require stripe/stripe-php
2:注册stripe账号,获取公钥和秘钥
3:对接支付宝
$secret_key = 密钥
$total_price = 0.5 //支付金额
$baseUrl = '' //支付成功的返回url
$orderNo = '' //订单编号
$username = '' //支付
$stripeClient = new StripeClient($secret_key);
try {
$payRes = $stripeClient->sources->create([
'currency' => 'AUD',
'redirect' => ['return_url' => $baseUrl],
'amount' => ($total_price * 100),
'type' => 'alipay', //ach_credit_transfer
'owner' => [
'email' => $orderNo . '@gmail.com'
],
'metadata' => ['order_no' => $orderNo] //传入的信息 可以根据自己的需要传入
]);
//先需要每个用户在stripe平台注册,返回一个customer id 可根据自己的系统注册
$res = stripeClient ->customers->create(['description' => $username]);
//获取返回的stripe支付的id 然后把id绑定到customer id上
} catch (\Exception $e) {
var_dump($e->getMessage()); //错误信息
}