原文链接:http://my.oschina.net/rain21/blog/496780
【适用于国际版PC端支付接口使用】http://global.alipay.com
本文采用简单的MD5验证,安全高效,易于集成。对于单站点使用的仅需简单去重验证即可
<?php $parameter = array( 'service' => 'create_forex_trade', 'partner' => '2088101122136241',//合作者ID '_input_charset' => strtolower('utf-8'), 'notify_url' => 'http://wsy.zy62.com/alipay/notify_url.php',//异步通知URL 'return_url' => 'http://wsy.zy62.com/alipay/return_url.php',//同步跳转URL /* 业务参数 */ 'subject' => '付款余额', 'out_trade_no' => sprintf("%s-%s",$client_id,date("YmdHis")),//商户订单号,唯一 'total_fee' => '0.01',//金额 'currency' => "USD"//币种 ); 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 = '<div style="text-align:center"><input type="button" onclick="window.open(\'https://mapi.alipay.net/gateway.do?'.$param. '&sign='.md5($sign).'&sign_type=MD5\')" value="' .'确定'. '" /></div>'; //上面的链接是测试环境,实际请改为https://mapi.alipay.com/gateway.do? echo $button;
<?php if (!empty($_POST)) { foreach($_POST as $key => $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' => '2088101122136241',//合作者ID '_input_charset' => strtolower('utf-8'), 'out_trade_no' => '1-1441531218',//商户订单号,唯一 );
$parameter = array( 'service' => 'forex_compare_file', 'partner' => '2088101122136241',//合作者ID 'start_date'=>'20150829', 'end_date'=>'20150905' );
tips:间隔不能超过10天,结束日期不能为当天
http://wenku.baidu.com/link?url=hcEp0lBZm7vqH2RfHXwP77O83sj7Q27jlOClF48hSNPl5bAgwBlGhGDoVuY4TEqQTsoj6Y7oZ431-SOztZKhwc64F7ZVU4vVjdLtA0aFsl_
Username : [email protected]
Login Password : 111111
Payment password ; 111111
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));