为什么80%的码农都做不了架构师?>>>
原文链接:http://my.oschina.net/rain21/blog/496780
【适用于国际版PC端支付接口使用】http://global.alipay.com
本文采用简单的MD5验证,安全高效,易于集成。对于单站点使用的仅需简单去重验证即可
付款URL生成:
'create_forex_trade',
'partner' => '2088101122123456',//合作者ID
'_input_charset' => strtolower('utf-8'),
'notify_url' => 'http://domain.com/alipay/notify_url.php',//异步通知URL
'return_url' => 'http://domain.com/alipay/return_url.php',//同步跳转URL
/* 业务参数 */
'subject' => '付款余额',
'out_trade_no' => '201605061456001',//商户订单号,唯一
'total_fee' => '9.99',//金额
'currency' => "CNY"//币种
);
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter AS $key => $val)
{
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1). '760bdzec6y9goq7ctyx96ezkz78287de';
$button = '';
//上面的链接是测试环境,实际请改为https://mapi.alipay.com/gateway.do?
echo $button;
验证异步回调
$data)
{
$_GET[$key] = $data;
}
}
/* 检查数字签名是否正确 */
ksort($_GET);
reset($_GET);
$sign = '';
foreach ($_GET AS $key=>$val)
{
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
{
$sign .= "$key=$val&";
}
}
$sign = substr($sign, 0, -1) . '760bdzec6y9goq7ctyx96ezkz78287de';
if (md5($sign) != $_GET['sign'])
{
return false;
}else{
return true;
}
/*$json='{"notify_id":"8cc4f9dca6ac0bdcc944b0cd51ce41292l","notify_type":"trade_status_sync","sign":"6aa07c5e5119eebc22d5fd9af78e39e1","trade_no":"2015082500001000100080033805","total_fee":"0.01","out_trade_no":"20150825092330","currency":"USD","notify_time":"2015-08-25 09:25:03","trade_status":"TRADE_FINISHED","sign_type":"MD5"}';
$_POST=json_decode($json,true);*/
获取单笔订单信息/单笔交易查询接口
参数,生成规则与之前一致:
$parameter = array(
'service' => 'single_trade_query',
'partner' => '2088101122123456',//合作者ID
'_input_charset' => strtolower('utf-8'),
'out_trade_no' => '201605061457001',//商户订单号,唯一
);
下载对账文件接口
$parameter = array(
'service' => 'forex_compare_file',
'partner' => '2088101122123456',//合作者ID
'start_date'=>'20150829',
'end_date'=>'20150905'
);
tips:间隔不能超过10天,结束日期不能为当天
常见错误编号汇总
http://wenku.baidu.com/link?url=hcEp0lBZm7vqH2RfHXwP77O83sj7Q27jlOClF48hSNPl5bAgwBlGhGDoVuY4TEqQTsoj6Y7oZ431-SOztZKhwc64F7ZVU4vVjdLtA0aFsl_
XML转JSON
function xml_to_json($source) {
$xml_array=simplexml_load_string($source);
$json = json_encode($xml_array); //php5,以及以上,如果是更早版本,请查看JSON.php
return $json;
}
echo(xml_to_json($xml));