【发布时间】:2018-07-18 14:26:07
【问题描述】:
这是 paypal 支付的 java 脚本如何从 swift 4 调用这个以及如何将金额传递给这个脚本,现在支付的金额是硬编码的
paypal.Button.render({
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
production: '<insert production client id>'
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');
我试过的代码是:
@IBAction func buttonActionPay(_ sender: UIButton) {
let htmlPath = Bundle.main.path(forResource: "sampleHTMLCode", ofType: "html")
let url = URL(fileURLWithPath: htmlPath!)
let request = URLRequest(url: url)
webView.load(request)
}
上面的javascript代码来自paypal开发者网站,是否需要修改代码。
【问题讨论】:
标签: javascript ios paypal swift4