关于易宝支付的回调和跨域请求

此次开发是基于小京东商城的开发(ecshop)
1.在支付的SDK里面有个call_back文件,支付的文档里面有个notify参数,里面的地址就写成能访问到call_back.php文件就行,切记,一定要是能访问到此地址
2.易宝支付的服务器会发送一个response参数还有另外一个参数,忽略,response参数里面有所有的订单信息附上代码


    define('IN_ECS', true);
include (dirname(__FILE__)."/includes/modules/payment/conf.php");
require_once (dirname(__FILE__)."/includes/modules/payment/yibao/YopClient.php");
require_once (dirname(__FILE__)."/includes/modules/payment/yibao/YopClient3.php");
require_once (dirname(__FILE__)."/includes/modules/payment/yibao/Util/YopSignUtils.php");
require (dirname(__FILE__) . '/includes/init.php');
//结果通知返回原文数据
function callback($source){
 
       global $merchantno;
   global $private_key;
   global $yop_public_key;
    //返回的密文
    //还原出原文
    return YopSignUtils::decrypt($source,$private_key, $yop_public_key);


}
//$aa = '{"unionID":null,"bankTrxId":"18042210246307468","orderId":"2018041915771","openID":null,"paySuccessDate":"2018-04-22 10:15:52","platformType":"NCPAY","bankPaySuccessDate":"2018-04-22 10:15:52","customerFee":"0.00","uniqueOrderNo":"1001201804220000000102775930","fundProcessType":"REAL_TIME","payAmount":"0.01","orderAmount":"0.01","requestDate":"2018-04-22 10:13:59","parentMerchantNo":"10018335019","paymentProduct":"NCPAY","status":"SUCCESS","merchantNo":"10020290087"}';
//$a = json_decode($aa,true);
//$key='oiwersoiasfqwe762323';
//$sign = MD5($a['orderId'].$a['orderAmount'].$key);




//$url = "http://域名/api/notify/NotifyShopPay".'?orderId='.$a['orderId'].'&uniqueOrderNo='.$a['uniqueOrderNo'].'&status='.$a['status'].'&orderAmount='.$a['orderAmount'].'&payAmount='.$a['payAmount'].'&sign='.$sign;
//var_dump($url);exit;
//$code = "code={"unionID":null,"bankTrxId":"18042210246307468","orderId":"2018042286301","openID":null,"paySuccessDate":"2018-04-22 10:15:52","platformType":"NCPAY","bankPaySuccessDate":"2018-04-22 10:15:52","customerFee":"0.00","uniqueOrderNo":"1001201804220000000102775930","fundProcessType":"REAL_TIME","payAmount":"0.01","orderAmount":"0.01","requestDate":"2018-04-22 10:13:59","parentMerchantNo":"10018335019","paymentProduct":"NCPAY","status":"SUCCESS","merchantNo":"10020290087"}";
$data = $_REQUEST["response"];
$call_pay = callback($data);
$a = json_decode($call_pay,true);
$key='oiwersoiasfqwe762323';
$sign = MD5($a['orderId'].$a['orderAmount'].$key);
$url = "http://域名/api/notify/NotifyShopPay".'?orderId='.$a['orderId'].'&uniqueOrderNo='.$a['uniqueOrderNo'].'&status='.$a['status'].'&orderAmount='.$a['orderAmount'].'&payAmount='.$a['payAmount'].'&sign='.$sign;


//初始化


      $curl = curl_init();
     
     //设置抓取的url
      curl_setopt($curl, CURLOPT_URL, $url);


     //设置头文件的信息作为数据流输出
      curl_setopt($curl, CURLOPT_HEADER, 1);
      //设置获取的信息以文件流的形式返回,而不是直接输出。
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      //执行命令
     // curl_setopt($curlp, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
      $data = curl_exec($curl);
      // var_dump( curl_error($curl));exit;
     //关闭URL请求
     curl_close($curl);
     //显示获得的数据
     var_dump($data);




file_put_contents("pay_log.txt",$url);


echo "SUCCESS"; 
中间的curl操作是将其返回的地址和参数拼接成url对另外一个平台进行请求。(curl进行跨域的请求操作函数)

你可能感兴趣的:(PHP)