2014-12-21 3 views
0

Parse.com 클라우드 코드의 Paypal을 사용하여 송장을 작성하고 송부하려고했습니다. 다음은 제 코드입니다. 나는 응답 코드 0Parse.com에서 PayPal을 사용하여 CreateAndSendInvoice 클라우드 코드

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\"}]}}}" 

답변

0

확인. 진짜 바보 같은 실수 야. 'X-PAYPAL-APPLICATION-ID와'사이에 공백이 있습니다. PayPal이 인증 실패 메시지로 응답하지 않은 이유가 이상합니다.

관련 문제