使用来自 Parse.com 云代码PayPal创建和发送发票



我一直在尝试使用 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);
  }
});

  });

有什么建议吗?云代码中没有错误。

我已使用 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没有响应身份验证失败消息。

相关内容

  • 没有找到相关文章

最新更新