官网示例代码部分:
plus.payment.getChannels((providers) => {
let provider = providers.find(function (e) {
return e.id === "google-pay";
});
let paymentMethodType = "PAYPAL";
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: "MVHSBANAS6KSE", //必填
};
let statement;
if (paymentMethodType === "CARD") {
statement = {
...cardPaymentMethodConfig,
};
} else {
statement = {
...paypalPaymentMethodConfig,
};
}
plus.payment.request(
provider,
statement,
(result) => {
console.log("支付成功 :" + JSON.stringify(result));
},
(e) => {
console.log("支付失败: " + JSON.stringify(e));
}
);
});
plus.payment.request,成功后会有下面的Payment token吗?
Goggle Pay官网Payment token格式
{
"protocolVersion":"ECv2",
"signature":"MEQCIH6Q4OwQ0jAceFEkGF0JID6sJNXxOEi4r+mA7biRxqBQAiAondqoUpU/bdsrAOpZIsrHQS9nwiiNwOrr24RyPeHA0Q\u003d\u003d",
"intermediateSigningKey":{
"signedKey": "{\"keyExpiration\":\"1542323393147\",\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE/1+3HBVSbdv+j7NaArdgMyoSAM43yRydzqdg1TxodSzA96Dj4Mc1EiKroxxunavVIvdxGnJeFViTzFvzFRxyCw\\u003d\\u003d\"}",
"signatures": ["MEYCIQCO2EIi48s8VTH+ilMEpoXLFfkxAwHjfPSCVED/QDSHmQIhALLJmrUlNAY8hDQRV/y1iKZGsWpeNmIP+z+tCQHQxP0v"]
},
"signedMessage":"{\"tag\":\"jpGz1F1Bcoi/fCNxI9n7Qrsw7i7KHrGtTf3NrRclt+U\\u003d\",\"ephemeralPublicKey\":\"BJatyFvFPPD21l8/uLP46Ta1hsKHndf8Z+tAgk+DEPQgYTkhHy19cF3h/bXs0tWTmZtnNm+vlVrKbRU9K8+7cZs\\u003d\",\"encryptedMessage\":\"mKOoXwi8OavZ\"}"
}
https://developers.google.com/pay/api/android/guides/resources/payment-data-cryptography?hl=zh-cn&authuser=1
0 个回复