1***@qq.com
1***@qq.com
  • 发布:2023-12-07 17:59
  • 更新:2024-05-16 16:10
  • 阅读:345

uniapp App 调起 谷歌支付 在个别手机 无法调起。

分类:uni-app

代码相同的情况下 在个别手机会出现 {"errMsg":"request:fail abort statusCode:-1 connection closed"} 的报错,其他手机正常调起。已经排除 手机型号、VPN、谷歌账号、谷歌三件套版本、移动网WIFI差异、

plus.payment.getChannels((providers) => {  
                    let provider = providers.find(function(e) {  
                        return e.id === "google-pay";  
                    });  
                    let paymentMethodType = "CARD";  
                    let cardPaymentMethodConfig = {  
                        environment: 3, // 必填 1 是product  3是test  
                        paymentMethodType: paymentMethodType, //必填 CARD、PAYPAL  
                        existingPaymentMethodRequired: false, //可选 如果设置为true同时已经准备好了支付allowedPaymentMethods中的付款方式,isReadyToPay就会返回true。  

                        currencyCode: "USD", //必填  
                        countryCode: "US", //在欧洲经济区必填  
                        transactionId: "", //当你想要接收googlepay回调的时候必填  
                        totalPriceStatus: "FINAL", //必填  NOT_CURRENTLY_KNOWN、ESTIMATED、FINAL  
                        totalPrice: "111.00", //必填 满足正则格式^[0-9]+(\.[0-9][0-9])?$  
                        totalPriceLabel: "100heelo", //可选  
                        checkoutOption: "DEFAULT", //可选 DEFAULT、COMPLETE_IMMEDIATE_PURCHASE  

                        merchantName: "Example Merchant", //可选  
                        emailRequired: true, //可选  
                        shippingAddressRequired: true, //可选   
                        shippingPhoneNumberRequired: false, //可选  
                        //allowedCountryCodes: ["US", "GB"], //可选  
                        allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"], //必填  
                        allowedCardNetworks: ["AMEX", "DISCOVER", "JCB", "MASTERCARD", "VISA"], //必填  
                        allowPrepaidCards: false, //可选  
                        // allowCreditCards:false,//可选    
                        assuranceDetailsRequired: false, //可选  
                        billingAddressRequired: true, //可选  
                        billingAddressParametersFormat: "FULL", //可选 MIN  
                        phoneNumberRequired: false, //可选  
                        tokenizationSpecificationType: "DIRECT", //必填 PAYMENT_GATEWAY、DIRECT  
                        gateway: "example", //PAYMENT_GATEWAY时必填  
                        gatewayMerchantId: "xxxx-xxxx-xxx", //PAYMENT_GATEWAY时必填  
                        protocolVersion: "", //DIRECT时必填  
                        publicKey: "", //DIRECT时必填  
                        buildTokenizationSpecification: { //可选,此字段是为了方便开发者自定义构造tokenizationSpecification参数,设置此字段时,会覆盖掉`tokenizationSpecificationType`、`gateway`、`gatewayMerchantId`、`protocolVersion`、`publicKey`字段。(HBuilderX 3.5.1+支持)  
                            "type": "PAYMENT_GATEWAY",  
                            "parameters": {  
                                "gateway": "custom-gateway",  
                                "gatewayMerchantId": "xxxx-xxxx-xxx"  
                            }  
                        }  
                    };  

                    let paypalPaymentMethodConfig = {  
                        environment: 3, // 必填 1 是product  3是test  
                        paymentMethodType: paymentMethodType, //必填 CARD、PAYPAL  
                        existingPaymentMethodRequired: false, //可选 如果设置为true同时已经准备好了支付allowedPaymentMethods中的付款方式,isReadyToPay就会返回true。  

                        currencyCode: "USD", //必填  
                        countryCode: "US", //在欧洲经济区必填  
                        transactionId: "", //当你想要接收googlepay回调的时候必填  
                        totalPriceStatus: "FINAL", //必填  NOT_CURRENTLY_KNOWN、ESTIMATED、FINAL  
                        totalPrice: "111.00", //必填 满足正则格式^[0-9]+(\.[0-9][0-9])?$  
                        totalPriceLabel: "100heelo", //可选  
                        checkoutOption: "DEFAULT", //可选 DEFAULT、COMPLETE_IMMEDIATE_PURCHASE  

                        merchantName: "Example Merchant", //可选  
                        emailRequired: true, //可选  
                        shippingAddressRequired: true, //可选  
                        shippingPhoneNumberRequired: false, //可选  
                        allowedCountryCodes: ["US", "GB"], //可选  
                        merchantId: "xxxx-xxxx-xxx", //必填  
                    };  

                    let statement;  

                    if (paymentMethodType === "CARD") {  
                        statement = {  
                            ...cardPaymentMethodConfig  
                        };  
                    } else {  
                        statement = {  
                            ...paypalPaymentMethodConfig  
                        };  
                    }  

                    console.log(provider);  

                    plus.payment.request(provider, statement, (result) => {  
                        console.log("支付成功 :" + JSON.stringify(result));  
                    }, (e) => {  
                        console.log("支付失败: " + JSON.stringify(e));  
                    })  
                });
2023-12-07 17:59 负责人:无 分享
已邀请:
Answer_Ming

Answer_Ming - 暂无

想问下楼主是怎么走的谷歌支付流程 后端需要用code换取token 但是前端拿code的方式只能通过app去跳转外部浏览器获取code (有更好的办法么?)想问下楼主和服务端是怎样的一个流程呢

  • 1***@qq.com (作者)

    谷歌登录获取到的参数与其他的不一样,只能拿到openId。把拿到的openId给到后端他那边是有办法解决的

    2024-01-24 11:27

我不是地球人

我不是地球人

你好,楼主,我想咨询一下关于谷歌商店的事情,就是我需要创建订阅商品,但是封闭测试一直审核不过去

要回复问题请先登录注册