例子,php支付宝支付接口开发参数详解。
<?php $service = isset( $_GET [ 'service' ]) ? $_GET [ 'service' ] : 'create_direct_pay_by_user' ; $services = array( //交易类型 'create_direct_pay_by_user' => '即时到账' , 'create_partner_trade_by_buyer' => '担保交易' , ); if(! array_key_exists ( $service , $services )) exit( '错误的交易类型' ); ?> <p style="border:2px dotted blue;width:auto;"> <label>请选择交易类型:</label> <?php foreach ( $services as $key => $val ): ?> <?php if( $service == $key ): ?> <b style="color:red"><?php echo $val ; ?> </b> <?php else: ?> <b><a href="<?php echo url (array( 'service' => $key )); ?> "><?php echo $val ; ?> </a></b> <?php endif; ?> <?php endforeach; ?> </p> <?php //php支付宝支付接口参数 //(合作商户编号,加密串,返回url, 默认编码,商品名称,商品简介,商户订单号,物流配送费用) function getRequestUrl ( $partner , $scode , $return_url , $charset , $subject , $body , $order , $lfee ) { global $data , $service ; # 支付宝交易类型 $data [ 'service' ] = $service ; //create_partner_trade_by_buyer[担保交易]create_direct_pay_by_user[即时到账] # 合作商户编号 $data [ 'partner' ] = $partner ; # 请求返回地址 $data [ 'return_url' ] = $return_url ; # 默认编码 $data [ '_input_charset' ] = $charset ; # 默认支付渠道 $data [ 'paymenthod' ] = 'bankPay' ; # 默认的网银 $data [ 'defaultbank' ] = 'ICBCB2C' ; # 商品名称 $data [ 'subject' ] = $subject ; # 商品展示URL $data [ 'show_url' ] = ’‘ ; # 异步通知返回 $data [ 'notify_url' ] = ’‘ ; # 商品简介 $data [ 'body' ] = $body ; # 商户订单号 $data [ 'out_trade_no' ] = $order ; # 物流配送费用 $data [ 'logistics_fee' ] = $lfee ; # 物流费用付款方式 $data [ 'logistics_payment' ] = 'SELLER_PAY' ; //SELLER_PAY(卖家支付)、BUYER_PAY(买家支付)、BUYER_PAY_AFTER_RECEIVE(货到付款) # 物流配送方式 $data [ 'logistics_type' ] = 'POST' ; //物流配送方式:POST(平邮)、EMS(EMS)、EXPRESS(其他快递) # 价格 $data [ 'price' ] = '10.00' ; #$data['total_fee'] = '10.00'; # 付款方式 $data [ 'payment_type' ] = '1' ; # 商品数量 $data [ 'quantity' ] = '1' ; # 卖家email $data [ 'seller_email' ] = 'chen@sjolzy.cn' ; $data = array_filter ( $data ); ksort ( $data ); reset ( $data ); $data [ 'sign' ] = md5 ( urldecode ( http_build_query ( $data )). $scode ); $data [ 'sign_type' ] = 'MD5' ; $url = 'https://www.alipay.com/cooperate/gateway.do?' . http_build_query ( $data ); return $url ; } //把支付宝接口的参数 带入进去测试 $url = getRequestUrl ( '2010101908738750' , 'ma0werwert6s2bsd1frg7hisaiaz5xjr' , 'http://www.jb200.com/demo/pay/callback.php ?gateway=alipay' , 'UTF-8' , '测试商品' , '测试内容' , uniqid (), '0.00' );