我有一个购物车 我想发送一个JSON字符串,该字符串是在用户付款后生成的 我有这个文件.js:
var ProcessOrder = {
// Called when order is successful via PayPal
success : function(order, transactionId){
$.info('Payment Success. TransactionID: ' + transactionId);
$.info('Order Data = ' + JSON.stringify(order));
Ti.UI.createAlertDialog({
title : config.PAYMENT_SUCCESS_MESSAGE.TITLE,
message : config.PAYMENT_SUCCESS_MESSAGE.MESSAGE
}).show();
},
// Called when order was cancelled by user during PayPal flow
cancelled : function(order){
$.info('Payment Canceled');
},
// Called if an error occurs during PayPal transaction
failed : function(order, errorCode, errorMessage){
$.info('Payment Error');
$.info('errorCode: ' + errorCode);
$.info('errorMessage: ' + errorMessage);
alert(errorMessage);
}
};
订单生成后的字符串是:
$.info('Payment Success. TransactionID: ' + transactionId);
$.info('Order Data = ' + JSON.stringify(order));
并包含订单的详细信息。
我想通过电子邮件或某处发送,以便我知道要发送什么? 提前谢谢。
此代码:
$.info('Payment Success. TransactionID: ' + transactionId);
$.info('Order Data = ' + JSON.stringify(order));
生成JSON两个字符串:
[INFO] Payment Success. TransactionID: AP-1YH922698A186825K
[INFO] Order Data = [{"itemID":"003","name":"Product","itemCount":1,"itemPrice":"2.50","totalPrice":2.5,"options":""}]
我想将这些数据保存在数据库中或发送电子邮件。
答案 0 :(得分:0)
将transactionId和订单JSON发布到PHP并在服务器端解析JSON(http://php.net/manual/en/function.json-decode.php)。或者你也可以在客户端解析JSON并将你感兴趣的属性发布到php页面。从JSON中提取数据后,您可以将其保存到数据库或发送邮件等。