对接支付宝接口流程(沙箱环境)
生活随笔
收集整理的這篇文章主要介紹了
对接支付宝接口流程(沙箱环境)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1 配置沙箱環境
- 1.1 入駐開放平臺
- 1.2 下載官方DEMO
- 1.3 配置DEMO中的zfbinfo.properties
- 2 測試
- 2.1 運行Main.java,控制臺輸出如下,測試成功
- 2.2 查看返回信息
- 3 整合SpringBoot完整跳轉實例
歡迎技術交流,QQ:569265915,添加了與SpringBoot整合的實例 1
1 配置沙箱環境
1.1 入駐開放平臺
1.2 下載官方DEMO
1.3 配置DEMO中的zfbinfo.properties
配置文件中1、2、3對應沙箱應用截圖中1、2、3。
第一、點擊設置應用公匙。
第二、點擊設置應用公匙。
第三、點擊查看密鑰生成方法
第四、點擊下載對應工具。
第五、解壓下載好的工具,點擊以下運行程序。
第六、點擊生成密匙。
復制私鑰到__zfbinfo.properties__中的__private_key__,復制公鑰到__zfbinfo.properties__中的__public_key__
復制公鑰到沙箱應用應用公鑰,點擊保存。
然后頁面會刷新,點擊查看支付寶公鑰
復制查看內容,填寫到__alipay_public_key__
至此,zfbinfo.properties配置文件修改好了。
2 測試
2.1 運行Main.java,控制臺輸出如下,測試成功
十一月 02, 2018 12:26:28 下午 com.alipay.demo.trade.config.Configs init 信息: 配置文件名: zfbinfo.properties 十一月 02, 2018 12:26:28 下午 com.alipay.demo.trade.config.Configs init 信息: Configs{支付寶openapi網關: https://openapi.alipaydev.com/gateway.do , 支付寶mcloudapi網關域名: http://mcloudmonitor.com/gateway.do , pid: 2088102176529960 , appid: 2016092000557923 , 商戶RSA私鑰: MIIEvA******yZsA== , 商戶RSA公鑰: MIIBIj******IDAQAB , 支付寶RSA公鑰: MIIBIj******IDAQAB , 簽名類型: RSA2 , 查詢重試次數: 5 , 查詢間隔(毫秒): 5000 , 撤銷嘗試次數: 3 , 撤銷重試間隔(毫秒): 2000 , 交易保障調度延遲(秒): 5 , 交易保障調度間隔(秒): 900 } 十一月 02, 2018 12:26:28 下午 com.alipay.demo.trade.service.impl.AbsAlipayTradeService tradePrecreate 信息: trade.precreate bizContent:{"out_trade_no":"tradeprecreate15411327883825138848","seller_id":"","total_amount":"0.01","undiscountable_amount":"0","subject":"xxx品牌xxx門店當面付掃碼消費","body":"購買商品3件共20.00元","goods_detail":[{"goods_id":"goods_id001","goods_name":"xxx小面包","quantity":1,"price":"10"},{"goods_id":"goods_id002","goods_name":"xxx牙刷","quantity":2,"price":"5"}],"operator_id":"test_operator_id","store_id":"test_store_id","extend_params":{"sys_service_provider_id":"2088100200300400500"},"timeout_express":"120m"} 十一月 02, 2018 12:26:30 下午 com.alipay.api.internal.util.AlipayLogger logBizSummary 信息: Summary^_^10000^_^null^_^ProtocalMustParams:charset=utf-8&method=alipay.trade.precreate&sign=eU/2GWboeBFjtSMvuZB6pX4tdGdWNRocbjCno/NwZhe2f8T+ljo/+UbgJA1UXo/1LU5F7TGQgla1RLXNlh9Oa1esCx1HdGHlqb9r/PSA6VtJAuOr055IeZ/V6IBmSeMTwFBX7DFbrHbar4WzerqIXjvjZGIHCkCqdq5XjWKUgD2V605OMDXwAgQVtU/13TOflkygBjxrJx2/sdQyvGSttnr3rSf8ROCCqBkRjbXVALLEcp2lUA0SoJ7gn3YLMSIjZTnIEogaB8md+b+49aTq7cw7KVrmG5mDSKLPa1mn1pj6kkjP6Jek8VH4GJlHdVQiHjuvXx+fqoCAyBMv35TwfA==&version=1.0&app_id=2016092000557923&sign_type=RSA2×tamp=2018-11-02 12:26:28^_^ProtocalOptParams:alipay_sdk=alipay-sdk-java-3.3.0&format=json^_^ApplicationParams:biz_content={"out_trade_no":"tradeprecreate15411327883825138848","seller_id":"","total_amount":"0.01","undiscountable_amount":"0","subject":"xxx品牌xxx門店當面付掃碼消費","body":"購買商品3件共20.00元","goods_detail":[{"goods_id":"goods_id001","goods_name":"xxx小面包","quantity":1,"price":"10"},{"goods_id":"goods_id002","goods_name":"xxx牙刷","quantity":2,"price":"5"}],"operator_id":"test_operator_id","store_id":"test_store_id","extend_params":{"sys_service_provider_id":"2088100200300400500"},"timeout_express":"120m"}^_^883ms,797ms,56ms 十一月 02, 2018 12:26:30 下午 com.alipay.demo.trade.service.impl.AbsAlipayService getResponse 信息: {"alipay_trade_precreate_response":{"code":"10000","msg":"Success","out_trade_no":"tradeprecreate15411327883825138848","qr_code":"https:\/\/qr.alipay.com\/bax020234ydxaolw6ftp0006"},"sign":"xeK8w2spKOKsXe9gglnacZGEE4zN2g6/XgsZeP4X38uBqTnNoc0MtoI5oTiURyhZYro75gNnDilGh72ZHVMPfKwHNnqwSxkbb03+TAlnKUiQy0seMqD7/TiyNv5dA34kgpZpsa+hMPUFgQl0spAYLn9qp60xHzkwmsvq6omVnAFkSNhgOG5Btpqca4/JqbEV02YH4xYk8c06s8HHbp0vAy0qMPlrM6GWyuTLbFQ57dABl2zFsZF26lf+Zt3i7hEvM72/Ma88fVB5jchH2gZ8rtL96xtOKvUALIcxvdPpt8zIuShMSi4F9Xy/F3OsmDHKkergy7azUev+EaXhxyya2g=="} 十一月 02, 2018 12:26:30 下午 com.alipay.demo.trade.Main test_trade_precreate 信息: 支付寶預下單成功: ) 十一月 02, 2018 12:26:30 下午 com.alipay.demo.trade.Main dumpResponse 信息: code:10000, msg:Success 十一月 02, 2018 12:26:30 下午 com.alipay.demo.trade.Main dumpResponse 信息: body:{"alipay_trade_precreate_response":{"code":"10000","msg":"Success","out_trade_no":"tradeprecreate15411327883825138848","qr_code":"https:\/\/qr.alipay.com\/bax020234ydxaolw6ftp0006"},"sign":"xeK8w2spKOKsXe9gglnacZGEE4zN2g6/XgsZeP4X38uBqTnNoc0MtoI5oTiURyhZYro75gNnDilGh72ZHVMPfKwHNnqwSxkbb03+TAlnKUiQy0seMqD7/TiyNv5dA34kgpZpsa+hMPUFgQl0spAYLn9qp60xHzkwmsvq6omVnAFkSNhgOG5Btpqca4/JqbEV02YH4xYk8c06s8HHbp0vAy0qMPlrM6GWyuTLbFQ57dABl2zFsZF26lf+Zt3i7hEvM72/Ma88fVB5jchH2gZ8rtL96xtOKvUALIcxvdPpt8zIuShMSi4F9Xy/F3OsmDHKkergy7azUev+EaXhxyya2g=="} 十一月 02, 2018 12:26:30 下午 com.alipay.demo.trade.Main test_trade_precreate 信息: filePath:/Users/sudo/Desktop/qr-tradeprecreate15411327883825138848.png2.2 查看返回信息
{"alipay_trade_precreate_response": {"code": "10000","msg": "Success","out_trade_no": "tradeprecreate15411327883825138848","qr_code": "https:\/\/qr.alipay.com\/bax020234ydxaolw6ftp0006"},"sign": "xeK8w2spKOKsXe9gglnacZGEE4zN2g6/XgsZeP4X38uBqTnNoc0MtoI5oTiURyhZYro75gNnDilGh72ZHVMPfKwHNnqwSxkbb03+TAlnKUiQy0seMqD7/TiyNv5dA34kgpZpsa+hMPUFgQl0spAYLn9qp60xHzkwmsvq6omVnAFkSNhgOG5Btpqca4/JqbEV02YH4xYk8c06s8HHbp0vAy0qMPlrM6GWyuTLbFQ57dABl2zFsZF26lf+Zt3i7hEvM72/Ma88fVB5jchH2gZ8rtL96xtOKvUALIcxvdPpt8zIuShMSi4F9Xy/F3OsmDHKkergy7azUev+EaXhxyya2g==" }復制qr_code,在線生成二維碼
登錄買家賬號,掃碼便可以完成交易。
3 整合SpringBoot完整跳轉實例
克隆代碼后直接運行,輸入:localhost:8080
SpringBoot整合支付寶實例 ??
總結
以上是生活随笔為你收集整理的对接支付宝接口流程(沙箱环境)的全部內容,希望文章能夠幫你解決所遇到的問題。