首先请到支付宝那边申请一个及时到账的接口账户,需要提交相关材料申请。然后根据即时到账的API文档进行接入。API文档提供了各种语言版本的demo,我这里是下的php版demo,然后再进行相关修改操作。你也可以将demo版本的代码重新整合,我这里暂时为了走通充值及时到账流程,就不进行代码重构了。
API文档:https://doc.open.alipay.com/docs/doc.htm"htmlcode">
<form action="/pay/alipayapi.php" class="tm-panel-small uk-form uk-form-stacked" method="post" target="_blank"> <div class="element" style="margin-top:60px;"> </div> <div class="uk-form-row"> <div class="uk-form-controls"> <label for="form-username" class="uk-form-label" style="display:inline-block;padding: 0 10px;vertical-align: middle;margin-left:-20px;">订单序号:</label> <input class="uk-form-width-large" type="text" name="WIDout_trade_no" id="out_trade_no" value="<" > <br> </div> </div> <div class="uk-form-row"> <div class="uk-form-controls"> <label for="form-username" class="uk-form-label" style="display:inline-block;padding: 0 10px;vertical-align: middle;margin-left:-20px;">商品名称:</label> <input class="uk-form-width-large" type="text" name="WIDsubject" value="<" > <br> </div> </div> <div class="uk-form-row"> <div class="uk-form-controls"> <label for="form-username" class="uk-form-label" style="display:inline-block;padding: 0 10px;vertical-align: middle;margin-left:-20px;">付款金额:</label> <input class="uk-form-width-large" type="text" name="WIDtotal_fee" value="<"> <br> </div> </div> <div class="uk-form-row"> <div class="uk-form-controls"> <label for="form-username" class="uk-form-label" style="display:inline-block;padding: 0 10px;vertical-align: middle;margin-left:-20px;">商品描述:</label> <input class="uk-form-width-large" type="text" name="WIDbody" value="订单测试支付"> <br> </div> </div> <input type="hidden" name="uid" value="<"> <input type="hidden" name="codes" value="<"> <input type="hidden" name="tags" value="<"> <div class="uk-form-row"> <input class="uk-button uk-button-primary uk-button-large uk-width-1-1" type="submit" class="alisubmit" value ="确认支付"> </div> </div> </form>
设置alipay.config.php配置文件,主要配置一下几个参数
$alipay_config['partner'] 设置签约账号ID
$alipay_config['key'] 设置MD5校验key
$alipay_config['notify_url'] 设置异步回调地址
$alipay_config['return_url'] 设置回调返回地址
$alipay_config['transport'] 设置协议类型,默认为http
$alipay_config['partner'] = 'xxxxxxxxxxxx'; //收款支付宝账号,以2088开头由16位纯数字组成的字符串,一般情况下收款账号就是签约账号 $alipay_config['seller_id'] = $alipay_config['partner']; // MD5密钥,安全检验码,由数字和字母组成的32位字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm $alipay_config['key'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // 服务器异步通知页面路径 需http://格式的完整路径,不能加"http://xx.xx.xx.xx/pay/notify_url.php"; // 页面跳转同步通知页面路径 需http://格式的完整路径,不能加"http://xx.xx.xx.xx/pay/return_url.php"; //签名方式 $alipay_config['sign_type'] = strtoupper('MD5'); //字符编码格式 目前支持 gbk 或 utf-8 $alipay_config['input_charset']= strtolower('utf-8'); //ca证书路径地址,用于curl中ssl校验 //请保证cacert.pem文件在当前文件夹目录中 $alipay_config['cacert'] = getcwd().'\\cacert.pem'; //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http $alipay_config['transport'] = 'http'; // 支付类型 ,无需修改 $alipay_config['payment_type'] = "1"; // 产品类型,无需修改 $alipay_config['service'] = "create_direct_pay_by_user";
交易处理完成后会发送订单信息及交易状态到你指定好的回传return_url.php中,你可以通过回传给你的订单状态判断交易是否成功,成功则进入下一步逻辑(你自己的订单处理逻辑),否则返回失败。
<"alipay.config.php"); require_once("lib/alipay_notify.class.php"); "Content-Type" content="text/html; charset=utf-8"> <"alipay"; $user_url = "/user_obj/do_orderinfo.php"; die("<script>;window.location='{$user_url}"); //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 } else { echo "trade_status=".$_GET['trade_status']; } var_dump($verify_result); echo "验证成功<br />"; //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } else { //验证失败 //如要调试,请看alipay_notify.php页面的verifyReturn函数 echo "验证失败"; } ?> <title>支付宝即时到账交易接口</title> </head> <body> </body> </html>
以上所述是小编给大家介绍的PHP 接入支付宝即时到账功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 魔兽世界祖尔格拉布在哪 魔兽世界祖尔格拉布位置介绍
- 群星《名列前茅五大顶级发烧男声》2CD[DTS-WAV]
- 群星《经典再现·国语女声》2CD[DTS-WAV]
- 群星《十大民歌天后》2CD[DTS-WAV分轨]
- 《黑神话:悟空》浮屠牢是最糟糕的部分:但也是做得最好的
- 《艾诺提亚:失落之歌》PC版反向跳票!9月17日PC开玩
- 老外谈《黑神话:悟空》:在我心里10分 但它确实是8分游戏
- 陈秋霞.1977-温馨在我心(LP版)【歌林】【WAV+CUE】
- 张秀卿.2019-感情骗子【豪记】【WAV+CUE】
- 林隆璇.1993-收藏昨日【福茂】【WAV+CUE】
- 魔兽世界wlk德拉诺金钻如何获得 wlk德拉诺金钻获取方法介绍
- 魔兽世界wlk祖阿曼战熊如何获得 wlk祖阿曼战熊获取方式介绍
- 魔兽世界阿奴巴拉克有什么背景故事 阿奴巴拉克背景故事介绍
- NeilYoung-EarlyDaze(2024)[24Bit]WAV
- NeaveTrio-Rooted(2024)[24Bit-WAV]