如何使用沙箱测试单笔转账到支付宝账号(java版)

来自    其他 | 
作者:王兰玉  |  更新于:2017-08-11 13:44:14     
说明:
 本帖是利用支付宝沙箱测试“单笔转账到支付宝账户,demo中会配置个人的沙箱账号信息,方便大家测试。
 测试环境:Eclipse+JDK1.6及以上+Tomcat6.0及以上

  正式环境对接支付宝接口必须签约生效方可测试,签约可参考【签约方案

注意事项:
  1.目前仅支持账户余额渠道付款。
  2.转账额度
    1)单日转出累计额度为100万元。
    2)转账给个人支付宝账户,单笔最高5万元;转账给企业支付宝账户,单笔最高10万元。

特殊逻辑注意点:
  1)如果商户重复请求转账,支付宝会幂等返回成功结果,商户必须对重复转账的业务做好幂等处理;如果不判断,
  存在潜在的风险,商户自行承担因此而产生的所有损失。
  2)如果调用alipay.fund.trans.toaccount.transfer掉单时,或返回结果code=20000时,或返回结果code=40004,
  sub_code= SYSTEM_ERROR时,请调用alipay.fund.trans.order.query发起查询,如果未查询到结果,
  请保持原请求不变再次请求alipay.fund.trans.toaccount.transfer接口。
  3)商户处理转账结果时,对于错误码的处理,只能使用sub_code作为后续处理的判断依据,
  不可使用sub_msg作为后续处理的判断依据。

参数解读:
  1.amount 转账金额,只支持2位小数,小数点前最大支持13位,金额必须大于等于0.1元。
  2.payer_show_name付款方姓名(最长支持100个英文/50个汉字)。显示在收款方的账单详情页。如果该字段不传
 则默认显示付款方的支付宝认证姓名或单位名称。
  3.payee_real_name收款方真实姓名(最长支持100个英文/50个汉字),如果本参数不为空,则会校验该账户在支付宝
 登记的实名是否与收款方真实姓名一致。
  4.remark转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元
  remark不能为空。收款方可见,会展示在收款用户的收支详情中。


测试流程(声明:本demo仅做参考测试使用

1.下载demo,导入java运行环境:单笔转账到支付宝demo.zip
2.在AlipayConfig文件中配置基本信息


正式环境测试需要把“dev”去掉
正式环境网关:https://openapi.alipay.com/gateway.do


正式环境测试配置可参照 RSA密钥生成,支付应用创建


3.测试接口
当收款方类型PayeeType=ALIPAY_USERID:pid,PayeeAccount=pid(以2088开头的16位纯数字)
当收款方类型PayeeType=ALIPAY_LOGONID,PayeeAccount=支付宝账号



pay_date(支付时间):当且仅当转账成功之后,才会返回
order_id(支付宝转账单据号):失败可能不返回也可能返回。


如果大家遇到单笔交易的问题欢迎大家在帖子下面追问,注意一定要提供详细的错误等相关信息方便解答疑问

荧客 | 2017-08-11 16:17:07
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \\logs\ygshop.log (找不到网络路径。)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:669)
at com.alipay.api.internal.util.AlipayLogger.<clinit>(AlipayLogger.java:32)
at com.alipay.api.DefaultAlipayClient.doPost(DefaultAlipayClient.java:459)
at com.alipay.api.DefaultAlipayClient._execute(DefaultAlipayClient.java:404)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:123)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:110)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:104)
at com.yknet.ygshop.controller.AlipayController.main(AlipayController.java:57)
[sdk.biz.err]2017-08-11 16:11:27^_^https://openapi.alipaydev.com/gateway.do?alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2016082000296141&biz_content=%7B%22amount%22%3A%221%22%2C%22out_biz_no%22%3A%222017081015423214234321%22%2C%22payee_account%22%3A%22giajei9522%40sandbox.com%22%2C%22payee_type%22%3A%22ALIPAY_LOGONID%22%2C%22remark%22%3A%22%E8%BD%AC%E8%B4%A6%E5%A4%87%E6%B3%A8%22%7D&charset=utf-8&format=json&method=alipay.fund.trans.toaccount.transfer&sign=jkg3hv%2Bq3t%2BwPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD%2Bs8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF%2FjQyL2%2FC37Ox5n7Qlaub0j27QJoHfPmlzG%2FAvip8GPPAYYS839Zx584I%2BVP3Dq1lwb2JiUmraM%3D&sign_type=RSA2&timestamp=2017-08-11+16%3A11%3A12&version=1.0&sign=jkg3hv%2Bq3t%2BwPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD%2Bs8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF%2FjQyL2%2FC37Ox5n7Qlaub0j27QJoHfPmlzG%2FAvip8GPPAYYS839Zx584I%2BVP3Dq1lwb2JiUmraM%3D
[sdk.biz.err]ErrorScene^_^40002^_^isv.invalid-signature^_^null^_^Windows 7^_^2017-08-11 16:11:27^_^ProtocalMustParams:charset=utf-8&method=alipay.fund.trans.toaccount.transfer&sign=jkg3hv+q3t+wPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD+s8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF/jQyL2/C37Ox5n7Qlaub0j27QJoHfPmlzG/Avip8GPPAYYS839Zx584I+VP3Dq1lwb2JiUmraM=&version=1.0&app_id=2016082000296141&sign_type=RSA2&timestamp=2017-08-11 16:11:12^_^ProtocalOptParams:alipay_sdk=alipay-sdk-java-dynamicVersionNo&format=json^_^ApplicationParams:biz_content={"amount":"1","out_biz_no":"2017081015423214234321","payee_account":"giajei9522@sandbox.com","payee_type":"ALIPAY_LOGONID","remark":"转账备注"}^_^Body:{"alipay_fund_trans_toaccount_transfer_response":{"code":"40002","msg":"Invalid Arguments","sub_code":"isv.invalid-signature","sub_msg":"无效签名"},"sign":"lOB95ne4nhtvCHPPXbUZYRNKxeX4KNu00Lk5V9DGcERBhZm8H3xMcNJdunRT44B57nq6oUbf2WdBlfPOBZxcsdq23yo/xJ4dBt6ox0OQL3YjuqJu2eCoEn4WXHrbdxQkCCx+TJ81vYlkccqnhSL8ATZYMRdS4wNVheVS+up0mCP1F0ZDM5JOuLObpQZt1HyRoKHCX3AInIQ+SnDdRxxfPTHZgwHpx3h7oGXU9fgIJb0rC9B6H3qGJ83FrAFLgOq7Fzf6Nf9XKti/qFU+xRsnfdPFHsVn1ocYTxkLJKV2gXOs4EEb1WfyG18HwUCB7/na/z4upxYTCTspZA+HXfDJrg=="}
{"alipay_fund_trans_tolog4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \\logs\ygshop.log (找不到网络路径。)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:844)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:669)
at com.alipay.api.internal.util.AlipayLogger.<clinit>(AlipayLogger.java:32)
at com.alipay.api.DefaultAlipayClient.doPost(DefaultAlipayClient.java:459)
at com.alipay.api.DefaultAlipayClient._execute(DefaultAlipayClient.java:404)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:123)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:110)
at com.alipay.api.DefaultAlipayClient.execute(DefaultAlipayClient.java:104)
at com.yknet.ygshop.controller.AlipayController.main(AlipayController.java:57)
[sdk.biz.err]2017-08-11 16:11:27^_^https://openapi.alipaydev.com/gateway.do?alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2016082000296141&biz_content=%7B%22amount%22%3A%221%22%2C%22out_biz_no%22%3A%222017081015423214234321%22%2C%22payee_account%22%3A%22giajei9522%40sandbox.com%22%2C%22payee_type%22%3A%22ALIPAY_LOGONID%22%2C%22remark%22%3A%22%E8%BD%AC%E8%B4%A6%E5%A4%87%E6%B3%A8%22%7D&charset=utf-8&format=json&method=alipay.fund.trans.toaccount.transfer&sign=jkg3hv%2Bq3t%2BwPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD%2Bs8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF%2FjQyL2%2FC37Ox5n7Qlaub0j27QJoHfPmlzG%2FAvip8GPPAYYS839Zx584I%2BVP3Dq1lwb2JiUmraM%3D&sign_type=RSA2&timestamp=2017-08-11+16%3A11%3A12&version=1.0&sign=jkg3hv%2Bq3t%2BwPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD%2Bs8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF%2FjQyL2%2FC37Ox5n7Qlaub0j27QJoHfPmlzG%2FAvip8GPPAYYS839Zx584I%2BVP3Dq1lwb2JiUmraM%3D
[sdk.biz.err]ErrorScene^_^40002^_^isv.invalid-signature^_^null^_^Windows 7^_^2017-08-11 16:11:27^_^ProtocalMustParams:charset=utf-8&method=alipay.fund.trans.toaccount.transfer&sign=jkg3hv+q3t+wPmBlhhy1BTdwKauhe16ifzRhficrJHT4H4VYo5e6k8eCjL5HD+s8fDbzmlVxSY5jprvTpXnpkVSz3RH5NUJmF/jQyL2/C37Ox5n7Qlaub0j27QJoHfPmlzG/Avip8GPPAYYS839Zx584I+VP3Dq1lwb2JiUmraM=&version=1.0&app_id=2016082000296141&sign_type=RSA2&timestamp=2017-08-11 16:11:12^_^ProtocalOptParams:alipay_sdk=alipay-sdk-java-dynamicVersionNo&format=json^_^ApplicationParams:biz_content={"amount":"1","out_biz_no":"2017081015423214234321","payee_account":"giajei9522@sandbox.com","payee_type":"ALIPAY_LOGONID","remark":"转账备注"}^_^Body:{"alipay_fund_trans_toaccount_transfer_response":{"code":"40002","msg":"Invalid Arguments","sub_code":"isv.invalid-signature","sub_msg":"无效签名"},"sign":"lOB95ne4nhtvCHPPXbUZYRNKxeX4KNu00Lk5V9DGcERBhZm8H3xMcNJdunRT44B57nq6oUbf2WdBlfPOBZxcsdq23yo/xJ4dBt6ox0OQL3YjuqJu2eCoEn4WXHrbdxQkCCx+TJ81vYlkccqnhSL8ATZYMRdS4wNVheVS+up0mCP1F0ZDM5JOuLObpQZt1HyRoKHCX3AInIQ+SnDdRxxfPTHZgwHpx3h7oGXU9fgIJb0rC9B6H3qGJ83FrAFLgOq7Fzf6Nf9XKti/qFU+xRsnfdPFHsVn1ocYTxkLJKV2gXOs4EEb1WfyG18HwUCB7/na/z4upxYTCTspZA+HXfDJrg=="}
{"alipay_fund_trans_toaccount_transfer_response":{"code":"40002","msg":"Invalid Arguments","sub_code":"isv.invalid-signature","sub_msg":"无效签名"},"sign":"lOB95ne4nhtvCHPPXbUZYRNKxeX4KNu00Lk5V9DGcERBhZm8H3xMcNJdunRT44B57nq6oUbf2WdBlfPOBZxcsdq23yo/xJ4dBt6ox0OQL3YjuqJu2eCoEn4WXHrbdxQkCCx+TJ81vYlkccqnhSL8ATZYMRdS4wNVheVS+up0mCP1F0ZDM5JOuLObpQZt1HyRoKHCX3AInIQ+SnDdRxxfPTHZgwHpx3h7oGXU9fgIJb0rC9B6H3qGJ83FrAFLgOq7Fzf6Nf9XKti/qFU+xRsnfdPFHsVn1ocYTxkLJKV2gXOs4EEb1WfyG18HwUCB7/na/z4upxYTCTspZA+HXfDJrg=="}
account_transfer_response":{"code":"40002","msg":"Invalid Arguments","sub_code":"isv.invalid-signature","sub_msg":"无效签名"},"sign":"lOB95ne4nhtvCHPPXbUZYRNKxeX4KNu00Lk5V9DGcERBhZm8H3xMcNJdunRT44B57nq6oUbf2WdBlfPOBZxcsdq23yo/xJ4dBt6ox0OQL3YjuqJu2eCoEn4WXHrbdxQkCCx+TJ81vYlkccqnhSL8ATZYMRdS4wNVheVS+up0mCP1F0ZDM5JOuLObpQZt1HyRoKHCX3AInIQ+SnDdRxxfPTHZgwHpx3h7oGXU9fgIJb0rC9B6H3qGJ83FrAFLgOq7Fzf6Nf9XKti/qFU+xRsnfdPFHsVn1ocYTxkLJKV2gXOs4EEb1WfyG18HwUCB7/na/z4upxYTCTspZA+HXfDJrg=="}


这是咋回事啊
王兰玉 | 2017-08-11 16:20:35
荧客:log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \\logs\ygshop.log (找不到网络路径。)
at java.io.File...
回到原帖
这是自己集成的报错还是下载我的demo测试报错?
王兰玉 | 2017-08-11 16:34:00
荧客:log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \\logs\ygshop.log (找不到网络路径。)
at java.io.File...
回到原帖
如果是我的demo,建议你重新生成密钥再做测试
荧客 | 2017-08-11 16:59:02
王兰玉:这是自己集成的报错还是下载我的demo测试报错?回到原帖
直接copy你的 里面的密钥是我自己生成的
王兰玉 | 2017-08-11 17:04:01
荧客:直接copy你的 里面的密钥是我自己生成的回到原帖
密钥重新生成一对测试一下,如果还是失败的,截图发下你的代码我看看
王兰玉 | 2017-08-11 17:07:48
荧客:直接copy你的 里面的密钥是我自己生成的回到原帖
无效签名可参照该贴进行排查:https://openclub.alipay.com/read.php?tid=1568&fid=46
荧客 | 2017-08-11 17:08:32
王兰玉:无效签名可参照该贴进行排查:https://openclub.alipay.com/read.php?tid=1568&fid=46回到原帖
我看下谢谢
荧客 | 2017-08-11 17:13:47
重新生成后变成未知错误吗了
王兰玉 | 2017-08-11 17:28:16
荧客:重新生成后变成未知错误吗了回到原帖
用我的demo测试,值把appid和密钥修改测试一下,看报不报错,如果报错那就是你的密钥还有问题,如果没报错了那就是你的参数有问题
荧客 | 2017-08-11 17:29:18
王兰玉:用我的demo测试,值把appid和密钥修改测试一下,看报不报错,如果报错那就是你的密钥还有问题,如果没报错了那就是你的参数有问题回到原帖
我用了你给我的网页测试过了密钥没问题
王兰玉 | 2017-08-11 17:32:30
荧客:我用了你给我的网页测试过了密钥没问题回到原帖
私信旺旺号发我,加个旺旺处理吧
荧客 | 2017-08-11 17:33:32
王兰玉:私信旺旺号发我,加个旺旺处理吧回到原帖
调用成功了但是还是报错
王兰玉 | 2017-08-11 17:38:19
荧客:调用成功了但是还是报错回到原帖
已私信
花花 | 2017-08-31 09:25:19
咨询一下,单笔支付中的  应用网关,和 授权信用 地址 这个需要填写吗。我只是从我的账户中转账给其他店铺
我的回复
回复数
  37
阅读数
  6381

返回顶部