【发布时间】:2015-07-13 19:12:56
【问题描述】:
我必须在我的应用程序中实施 Paypal。在这里,我已将一些产品添加到购物车中。如果我点击购物车,我必须使用 Paypal 支付金额。
单击 Paypal 按钮时,我收到以下错误:
为商品价格、税金和运费指定的金额不等于总金额。
为什么会出现这个错误?
我正在使用以下代码:
$.paypalWindow.addEventListener('open', function(){
var Paypal = require('ti.paypal');
var u = Ti.Android != undefined ? 'dp' : 0;
var status = Ti.UI.createLabel({ top: 20 + u, height: 50 + u, color: '#333', text: 'Loading, please wait...' });
$.paypalWindow.add(status); var price = totalamount;
var invoiceitemslist = JSON.stringify(data);
var button; function addButtonToWindow() {
if (button) { $.paypalWindow.remove(button); button = null; }
button = Paypal.createPaypalButton({ width: 194 + u, height: 37 + u, buttonStyle: Paypal.BUTTON_194x37, top: 20 + u,
language: 'en_US',
appID: 'APP-80W284485P519543T',
paypalEnvironment: Paypal.PAYPAL_ENV_SANDBOX,
feePaidByReceiver: false,
enableShipping: false,
payment: {
paymentType: Paypal.PAYMENT_TYPE_BUSINESS,
subtotal: price,
tax: 0.00,
shipping: 0.00,
currency: 'USD',
recipient: 'thaibusiness@gmail.com',
customID: 'anythingYouWant',
invoiceItems:
[{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":2997,"itemPrice":999,"itemCount":3},
],
ipnUrl: 'http://www.appcelerator.com/',
merchantName: 'EYMOBINS Insurance',
memo: 'For the insurance with EYMOBINS!'
}
});
button.addEventListener('paymentCancelled', function (e) {
alert('Payment cancelled. Please try again!');
addButtonToWindow();
});
button.addEventListener('paymentSuccess', function (e) {
alert('Payment successfull. Please get your Policy No.!'+" "+e.transactionID);
$.paypalWindow.remove(button);
//addButtonToWindow();
});
button.addEventListener('paymentError', function (e) {
alert('Payment Error. Please try again!');
addButtonToWindow();
});
button.addEventListener('buttonDisplayed', function () {
$.paypalWindow.remove(status);
//alert('Please pay '+Ti.App.totalcost+'$ with Paypal!')
});
button.addEventListener('buttonError', function () {
});
$.paypalWindow.add(button);
}
addButtonToWindow();
});
$.paypalWindow.open();
请检查代码并告诉我解决上述问题的想法。
编辑:
这里我面临一个问题:
[{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":999,"itemPrice":999,"itemCount":1},{"name":"Average2Excellent CBSE KG EVS MATHS ENG Educational CD ROMS","totalPrice":547,"itemPrice":547,"itemCount":1}]
这里的总金额是 1546。这里我在控制台中打印了 invoiceitems,我得到的数据如上。
所以我给出了这样的:
invoiceItems:invoiceitems,
点赞表示收到问题(为商品价格、税金和运费指定的金额不等于总金额)。
和我写的代码一样:
invoiceItems:[{"name":"Bajaj 200 mm Ultima PT01 Personal Fan","totalPrice":999,"itemPrice":999,"itemCount":1},{"name":"Average2Excellent CBSE KG EVS MATHS ENG Educational CD ROMS","totalPrice":547,"itemPrice":547,"itemCount":1}]
效果很好。
分配值时它不会动态工作。你能检查一下代码和帮助吗?
编辑:
如果我尝试在 android 设备上运行此代码,就像单击 paypal 按钮一样,没有任何反应。为什么登录表单在安卓设备中打不开。
【问题讨论】:
-
您能否提供从 PayPal 响应返回的关联 ID?
-
我没有在任何地方的代码中提供相关 ID。我必须在哪里创建该 ID?如果你有教程,请给我学习
标签: javascript android ios paypal titanium