Airwallex 中文名称空中云汇 主页是做境外VISA信用卡、银联支付等的一个集成支付接口

公司网址可以搜索空中云汇
一.注册创建支持api key

二.获取到平台登入token
function getToken(){
$token=session('air_token');
$config=$this->config();
$client_id=$config['x-client-id'];
$api_key=$config['x-api-key'];
if(!$token){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.airwallex.com/api/v1/authentication/login',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'x-client-id:'.$client_id.'',
'x-api-key:'.$api_key.'',
),
));
$response = curl_exec($curl);
$data=json_decode($response,true);
//dump($data);exit;
if($data['token']){
session('air_token',$data['token'],60*30);
$token= $data['token'];
}
}
return $token;
}
三. 通过token 去获取沟通平台创建支付意向订单
public function create_order($order)
{
$curl = curl_init();
$token=$this->getToken();
$time=date(DATE_ISO8601);//注意时间格式必须是DATE_ISO8601
//dump($time);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.airwallex.com/api/v1/pa/payment_intents/create',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER=>false,
CURLOPT_SSL_VERIFYHOST=>false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"request_id": "'.$order['merchant_order_id'].'",
"amount": '.$order['amount'].',
"currency": "CNY",
"merchant_order_id": "'.$order['merchant_order_id'].'",
"return_url": "xxxxxxxxxxx"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer '.$token.''
),
));
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response,true);
}
return_url:可选 如果你用的支付模式是跳转到空中云付的托管页面就要填写,支付成功后回跳页面,这里永兴集团用的是内嵌卡片

四、前端设置支付卡片
Payment amount
{$order.order_no}
$ {$total_amount}
Payment successful!