public function payssion()
{
$url = "http://sandbox.payssion.com/api/v1/payment/create";//沙箱测试
$msg = implode('|', array('sandbox_184d7001e5ce33a5', 'payssion_test', '1.00', 'USD', '123456789', '08QV4C8m5tTbGPWiJf5lFhklCg22dpze'));
$api_sig = md5($msg);
$fields = [
'api_key'=>"sandbox_184d7001e5ce33a5",
'api_sig' => $api_sig,
'pm_id' => "payssion_test",
'amount'=>"1.00",
'currency'=>"USD",
'order_id'=>"123456789",
'description'=>"Charge for test"
];
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Cache-Control: no-cache",
));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute post
$result = curl_exec($ch);
$err = curl_error($ch);
$result = json_decode($result,true);
dump($result);die();
}
/**
* 异步回调
*/
public function notify_back()
{
$file_post['input'] = file_get_contents("php://input");
file_put_contents('1.txt','1111');
dump($file_post); die();
$config = D('Api/Getplugmsg')->plug_config_get(24);
$secrct_key = $config['plug_config']['24']['secret_key'];
$key = 'Bearer' . ' ' . $secrct_key;
$reference = self::$postget['reference'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.paystack.co/transaction/verify/$reference",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array(
"Authorization: $key",
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
// echo "cURL Error #:" . $err;
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-failure');//支付失败跳转
exit();
} else {
$response = json_decode($response, true);
// dump($response);die();
$paymsg_info = M('order_paymsg_record')->where(array('out_trade_no' => $reference))->find();
if ($response['message'] == 'Verification successful') {
$paymsg_info['returndata'] = json_encode($response);
$paymsg_info['status'] = 2;
$paymsg_info['paymsg'] = $paymsg_info['paytype'];
$pay = A('Home/Paypalrun')->deal_pay_msg($paymsg_info);
if ($pay == 12) {
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-success');//支付成功
} else {
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-failure');//支付失败
// self::showJson(array('status'=>0,'msg'=>'支付失败')); exit();
}
}
}
}
/**
* 同步回调
*/
public function return_back()
{
$configmsg_all=D("Api/Getplugmsg")->plug_config_get(25);
if($configmsg_all['plug_config']['25']['payssion'] !=1){
return false;
}
$api_key = $configmsg_all['plug_config']['25']['api_key'];
$secret_key = $configmsg_all['plug_config']['25']['secret_key'];
$transacion_id = self::$postget['transaction_id'];
$order_id = self::$postget['order_id'];
$url = "http://sandbox.payssion.com/api/v1/payment/details";//沙箱测试
$msg = implode('|', array($api_key, $transacion_id, $order_id,$secret_key));
$api_sig = md5($msg);
$fields = [
'api_key'=> $api_key,
'api_sig' => $api_sig,
'transaction_id' => $transacion_id,
'order_id'=>$order_id,
];
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Cache-Control: no-cache",
));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute post
$response = curl_exec($ch);
$err = curl_error($ch);
if ($err) {
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-failure');//支付失败跳转
exit();
} else {
$response = json_decode($response, true);
$paymsg_info = M('order_paymsg_record')->where(array('out_trade_no' => $transacion_id))->find();
if ($response['result_code'] == '200') {
$paymsg_info['returndata'] = json_encode($response);
$paymsg_info['status'] = 2;
$paymsg_info['paymsg'] = $paymsg_info['paytype'];
$pay = A('Home/Paypalrun')->deal_pay_msg($paymsg_info);
if ($pay == 12) {
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-success');//支付成功
} else {
header('location: http://' . $_GET['http_website_domain_name'] . '/index/pay-failure');//支付失败
}
}
}
}
payssion支付
最新推荐文章于 2023-10-24 15:09:36 发布