[英]CreateAndSendInvoice using PayPal from Parse.com Cloud Code
我一直在尝试使用Parse.com云代码中的Paypal创建和发送发票。 下面是我的代码。 我收到此错误请求失败,响应代码为0
Parse.Cloud.define("send_paypal_invoice", function(request, response){
var headerParams = [{ //Setting PayPal request headers
'X-PAYPAL-SECURITY-USERID' : '****************',
'X-PAYPAL-SECURITY-PASSWORD' : '***********',
'X-PAYPAL-SECURITY-SIGNATURE' : '****************',
// Global Sandbox Application ID
'X-PAYPAL-APPLICATION-ID ' : 'APP-80W284485P519543T',
// Input and output formats
'X-PAYPAL-REQUEST-DATA-FORMAT' : 'JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT' : 'JSON'
}];
var payload = {
requestEnvelope: {
errorLanguage: 'en_US'
},
invoice: {
merchantEmail: '*****************',
payerEmail: '*****************',
currencyCode: 'SGD',
paymentTerms: 'DueOnReceipt',
itemList: [{ name:'BananaPlant',
quantity:'1',
unitPrice:'38.95'
},
{ name:'testPlant',
quantity:'2',
unitPrice:'18.20'}]
}
};
var bodyJsonParams = JSON.stringify(payload);
var headerJsonParams = JSON.stringify(headerParams);
Parse.Cloud.httpRequest({
url: 'https://svcs.sandbox.paypal.com/Invoice/CreateAndSendInvoice',
headers: headerJsonParams,
body: bodyJsonParams,
success: function(httpResponse) {
console.log(httpResponse.text);
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
});
有什么建议么? 没有错误来自cloudcode。
我已经使用curl命令来验证我的通话是否有效。
curl -s -v -D --insecure -H "X-PAYPAL-SECURITY-USERID: *************" -H "X-PAYPAL-SECURITY-PASSWORD: *************" -H "X-PAYPAL-SECURITY-SIGNATURE: *************" -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" https://svcs.sandbox.paypal.com/Invoice/CreateAndSendInvoice -d \
"{\"requestEnvelope\":{\"errorLanguage\":\"en_US\"},\"invoice\":{\"merchantEmail\":\"*************\",\"payerEmail\":\"*************\",\"currencyCode\":\"USD\",\"paymentTerms\":\"DueOnReceipt\",\"itemList\":{\"item\":[{\"name\":\"BananaPlant\",\"quantity\":\"1\",\"unitPrice\":\"38.95\"},{\"name\":\"PeachTree\",\"quantity\":\"2\",\"unitPrice\":\"18.95\"}]}}}"
好。 这是一个真正的愚蠢错误。 X-PAYPAL-APPLICATION-ID与'之间有一个空格。 PayPal没有以Auth失败消息响应的原因很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.