

English
For more information, please refer to Operation Guide for Applying to Open Paypal
注意
Parameter Description
Tip: returnURL_android and returnURL_ios can be the same, if they are different, you need to add multiple return URLs to the paypal developer center
Before calling the payment on the App side, you need to generate a payment order on the business server and obtain the orderId
. For details, please refer to the official paypal documentation: Create Order
paypal
, and the orderInfo attribute value is the order objectObject object type
Attribute | Type | Required | Description |
---|---|---|---|
clientId | String | Yes | Client ID, which can be obtained when creating an application in the paypal developer center |
currency | String | No | The currency must be capitalized. For the value, please refer to the official paypal documentation Currency Codes |
environment | String | Yes | The operating environment, which can be sandbox/live, sandbox represents the sandbox environment (for development and testing), and live represents the online environment (officially released) |
orderId | String | Yes | Order id, which can be obtained when the server generates a payment order |
userAction | String | No | Button style, value paynow/continue |
//Order object, obtained from the server
var orderInfo = {
"clientId": "clientId from paypal", //客户端id
"orderId": "orderId from server", //订单id
"userAction": "continue", // paynow/continue
"currency":"USD", // 币种
"environment":"sandbox", //运行环境 sandbox/live
};
uni.getProvider({
service: 'payment',
success: function (res) {
console.log(res.provider)
if (~res.provider.indexOf('paypal')) {
uni.requestPayment({
"provider": "paypal",
"orderInfo": orderInfo,
success: function (res) {
var rawdata = JSON.parse(res.rawdata);
console.log("orderId:" + rawdata.orderId);
},
fail: function (err) {
console.log('fail:' + JSON.stringify(err));
}
});
}
}
});
//Order object, obtained from the server
var orderInfo = {
"clientId": "clientId from paypal", //客户端id
"orderId": "orderId from server", //订单id
"userAction":"continue", // paynow/continue
"currency":"USD", // 币种
"environment":"sandbox", //运行环境 sandbox/live
};
//get payment channel
var paypalSev = null;
plus.payment.getChannels(function(channels){
for (var i in channels) {
var channel = channels[i];
if (channel.id === 'paypal') {
paypalSev = channel;
}
}
//Initiate payment
plus.payment.request(paypalSev, orderInfo, function(result) {
var rawdata = JSON.parse(result.rawdata);
console.log("支付成功");
}, function(e) {
console.log("支付失败:" + JSON.stringify(e));
});
}, function(e){
console.log("获取支付渠道失败:" + JSON.stringify(e));
});
After the payment is initiated on the App side, the order id is returned, and the payment operation has not been completed. The server needs to authorize or capture the order to complete the deduction.