疯了吧
疯了吧
  • 发布:2022-03-31 14:50
  • 更新:2022-11-16 19:38
  • 阅读:786

【报Bug】支付宝沙盒支付错误

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10

HBuilderX类型: 正式

HBuilderX版本号: 3.4.3

手机系统: Android

手机系统版本号: Android 12

手机厂商: 华为

手机机型: 红米

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

’‘’
后台
private String serverUrl="https://openapi.alipaydev.com/gateway.do";
private String APP_ID="";
// 应用私钥
private String APP_PRIVATE_KEY="";
private String format="json";
private String CHARSET="utf-8";
// 支付宝公钥
private String ALIPAY_PUBLIC_KEY="";
private String signType="RSA2";
@ApiOperation(value = "支付", notes = "支付")
@PostMapping(value = "/getOrderInfo", produces = "application/json")
public String getOrderInfo(){
resultBody = new ResultBody();
//实例化客户端
AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, APP_ID, APP_PRIVATE_KEY, format, CHARSET, ALIPAY_PUBLIC_KEY, signType);
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
model.setBody("我是测试数据");
model.setSubject("App支付测试Java");
// 订单号
model.setOutTradeNo("2134567654565646544243234243534214");
model.setTimeoutExpress("30m");
model.setTotalAmount("0.01");
model.setProductCode("QUICK_MSECURITY_PAY");
request.setBizModel(model);
request.setNotifyUrl("商户外网可以访问的异步地址");
try
{
//这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
System.out.println(response.getBody());
return resultBody.success(CommonEnum.SUCCESS,response.getBody());
// System.out.println(response.getBody());//就是orderString 可以直接给客户端请求,无需再做处理。
} catch(AlipayApiException e) {
System.out.println(e);
return resultBody.error(CommonEnum.ERROR,e);
// e.printStackTrace();
}
}
‘’‘
’‘’
uniapp
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title" @click="zhifu()">{{title}}</text>
</view>
</view>
</template>

<script>
export default {
data() {
return {
title: '支付',
orderInfo: '',

        }  
    },  
    onLoad() {  
        this.getOrder()  
    },  
    methods: {  
        getOrder() {  
            //ajax动态数据  
            uni.request({  
                url: this.$http.http + '/user/getOrderInfo',  
                method: 'POST',  
                success: (res) => {  
                    //把获取来的数据保存到data中  
                    this.orderInfo = res.data.resultData  
                    console.log("or",this.orderInfo)  
                }  
            });  
        },  
        zhifu() {  
            uni.requestPayment({  
                provider: 'alipay',  
                orderInfo: this.orderInfo,  
                success: (e) => {  
                    uni.showModal({  
                        content: "感谢您的赞助",  
                        showCancel: false  
                    })  
                },  
                fail: (e) => {  
                    console.log("e",e)  
                    uni.showModal({  
                        content: "支付失败,原因为: " + e.errMsg,  
                        showCancel: false  
                    })  
                },  
                complete: () => {  
                    console.log("payment结束")  
                    this.loading = false;  
                }  
            })  
        }  
    }  
}  

</script>

<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.logo {  
    height: 200rpx;  
    width: 200rpx;  
    margin-top: 200rpx;  
    margin-left: auto;  
    margin-right: auto;  
    margin-bottom: 50rpx;  
}  

.text-area {  
    display: flex;  
    justify-content: center;  
}  

.title {  
    font-size: 36rpx;  
    color: #8f8f94;  
}  

</style>

‘’‘

操作步骤:

调用支付宝参数

预期结果:

正常支付

实际结果:

不能支付

bug描述:

支付宝沙盒支付时,报错
测试数据:alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2016101700704662&biz_content=%7B%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%222134567654565646544243234243534214%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22subject%22%3A%22App%E6%94%AF%E4%BB%98%E6%B5%8B%E8%AF%95Java%22%2C%22timeout_express%22%3A%2230m%22%2C%22total_amount%22%3A%220.01%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=%E5%95%86%E6%88%B7%E5%A4%96%E7%BD%91%E5%8F%AF%E4%BB%A5%E8%AE%BF%E9%97%AE%E7%9A%84%E5%BC%82%E6%AD%A5%E5%9C%B0%E5%9D%80&sign=r0%2FMKNXrd9qiwmlaCGiEzVT2%2BtGDNDxuZ1WzpnwnrSlA8v2PLUAT9YrJ%2Bq6WpNGkachFb%2B1o37momFtmGq9SAq63U7r%2B17Zg4p4YR84x029fFSwwcX1Ta02txXz1olM1YJdpIFCW4pzp1nKQrFyZz25R6WOJJd1rZJZoUQS49%2BvZJwq%2FrQSMVg9Rzml8y%2BxZg6XrQoreDlYPfQGM%2BY9yATXE7CYsYaFwTzSP4fH3Ut3U4fFuzYTNIzyN77hVKgL1MTCNpUsS%2F8ollANn0%2BX8cabC0RlkeI2NSIZrf69Rv3X877b1w436MPL2ZL2BM9cA7QKaN1t8WQaqf15Tla2iZA%3D%3D&sign_type=RSA2&timestamp=2022-03-31+14%3A45%3A51&version=1.0
测试结果
支付宝App测试调试工具正常
uniapp调用uni.requestPayment报错
报错内容
{
"errMsg": "requestPayment:fail [payment支付宝:62009]未知错误",
"errCode": -100,
"code": -100
}

2022-03-31 14:50 负责人:无 分享
已邀请:
全小区最优秀

全小区最优秀

连个回复都没有

  • BoredApe

    请重新发帖子,详细说明问题

    2022-11-16 19:41

该问题目前已经被锁定, 无法添加新回复