2012-11-05 3 views
4

나는 내 인생에서 무슨 일이 일어나고 있는지 알 수 없습니다. 저는 PayPal의 Adaptive Payments API에 대한 기본 호출 인 Pay 콜을 사용하려고합니다. 나는 node.js로 이것을 달성하려고 노력하고있다. curl으로 전화를 걸 수 있지만 노드는 단순히 거절합니다. 'Invalid request: {0}' 오류 메시지가 지속됩니다. 오류 ID는 580001입니다. 저는 오랫동안 해결책을 찾았습니다. 많은 사람들이 겉보기에는 비슷한 문제를 가지고 있었지만 문제는 내 문제와 달랐습니다. 그래서 그들의 해결책은 효과가 없었습니다.PayPal과 관련된 문제 Node.js의 Adaptive Payments

당신이 제공 할 수있는 도움이 MUCH입니다.

{ responseEnvelope: 
    { timestamp: '2012-11-05T03:50:08.216-08:00', 
    ack: 'Failure', 
    correlationId: 'b1dbb6fea8378', 
    build: '4110101' }, 
    error: 
    [ { errorId: '580001', 
     domain: 'PLATFORM', 
     subdomain: 'Application', 
     severity: 'Error', 
     category: 'Application', 
     message: 'Invalid request: {0}' } ] } 

가 여기 내 노드 코드입니다 : (참고 : 나는 request 모듈을 사용하고 있습니다 : https://github.com/mikeal/request를)

request = require 'request' 

body = JSON.stringify 

    actionType: "PAY" 
    senderEmail: "[email protected]" 
    receiverList: 
    receiver: [ 
     email: "[email protected]" 
     amount: "1.00" 
    ] 
    currencyCode: "USD" 
    feesPayer: "EACHRECEIVER" 
    memo: "This is a test" 
    cancelUrl: "http://cancelurl" 
    returnUrl: "http://returnUrl" 
    ipnNotificationUrl: "http://your_ipn_notification_url" 
    requestEnvelope: 
    errorLanguage: "en_US" 

console.log body 

console.log request 

    url: 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay' 

    headers: 
    "X-PAYPAL-SECURITY-USERID": "happy_1349101075_biz_api1.onehappystudent.com" 
    "X-PAYPAL-SECURITY-PASSWORD": "1349101103" 
    "X-PAYPAL-SECURITY-SIGNATURE": "AFcWxV21C7fd0v3bYYYRCpSSRl31Avw12OuF33eJo9IbQpXMS6wrOp1." 

    "X-PAYPAL-REQUEST-DATA-FORMAT": "JSON" 
    "X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON" 

    "X-PAYPAL-APPLICATION-ID": "APP-80W284485P519543T" 

    "Content-Type": "application/json" 

    body: body 

, (err, res, bod) -> 

    console.log bod 

여기 출력의 여기

내가 점점 계속 응답 (prettified)입니다 위의 코드를 실행하는 경우 :

{"actionType":"PAY","senderEmail":"[email protected]","receiverList":{"receiver":[{"email":"[email protected]","amount":"1.00"}]},"currencyCode":"USD","feesPayer":"EACHRECEIVER","memo":"This is a test","cancelUrl":"http://cancelurl","returnUrl":"http://returnUrl","ipnNotificationUrl":"http://your_ipn_notification_url","requestEnvelope":{"errorLanguage":"en_US"}} 
{ readable: true, 
    writable: true, 
    headers: 
    { 'X-PAYPAL-SECURITY-USERID': 'happy_1349101075_biz_api1.onehappystudent.com', 
    'X-PAYPAL-SECURITY-PASSWORD': '1349101103', 
    'X-PAYPAL-SECURITY-SIGNATURE': 'AFcWxV21C7fd0v3bYYYRCpSSRl31Avw12OuF33eJo9IbQpXMS6wrOp1.', 
    'X-PAYPAL-REQUEST-DATA-FORMAT': 'JSON', 
    'X-PAYPAL-RESPONSE-DATA-FORMAT': 'JSON', 
    'X-PAYPAL-APPLICATION-ID': 'APP-80W284485P519543T', 
    'Content-Type': 'application/json', 
    host: 'svcs.sandbox.paypal.com', 
    'content-length': 409 }, 
    body: <Buffer 7b 22 61 63 74 69 6f 6e 54 79 70 65 22 3a 22 50 41 59 22 2c 22 73 65 6e 64 65 72 45 6d 61 69 6c 22 3a 22 68 61 70 70 79 5f 31 33 34 39 31 30 31 30 37 35 ...>, 
    callback: [Function], 
    pool: {}, 
    dests: [], 
    __isRequestRequest: true, 
    _callback: [Function], 
    _events: 
    { error: [Function], 
    complete: [Function], 
    pipe: { [Function: g] listener: [Function] } }, 
    uri: 
    { protocol: 'https:', 
    slashes: true, 
    host: 'svcs.sandbox.paypal.com', 
    hostname: 'svcs.sandbox.paypal.com', 
    href: 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay', 
    pathname: '/AdaptivePayments/Pay', 
    path: '/AdaptivePayments/Pay', 
    port: 443 }, 
    _redirectsFollowed: 0, 
    maxRedirects: 10, 
    followRedirect: true, 
    followAllRedirects: false, 
    redirects: [], 
    setHost: true, 
    originalCookieHeader: undefined, 
    _jar: undefined, 
    port: 443, 
    host: 'svcs.sandbox.paypal.com', 
    clientErrorHandler: [Function], 
    _parserErrorHandler: [Function], 
    path: '/AdaptivePayments/Pay', 
    httpModule: 
    { Server: { [Function: Server] super_: [Object] }, 
    createServer: [Function], 
    globalAgent: 
     { options: {}, 
     requests: {}, 
     sockets: {}, 
     maxSockets: 5, 
     _events: [Object], 
     createConnection: [Function: createConnection] }, 
    Agent: { [Function: Agent] super_: [Object] }, 
    request: [Function], 
    get: [Function] }, 
    agentClass: 
    { [Function: Agent] 
    super_: { [Function: Agent] super_: [Function: EventEmitter], defaultMaxSockets: 5 } }, 
    agent: 
    { options: {}, 
    requests: {}, 
    sockets: {}, 
    maxSockets: 5, 
    _events: { free: [Function] }, 
    createConnection: [Function: createConnection] } } 
{"responseEnvelope":{"timestamp":"2012-11-05T03:50:08.216-08:00","ack":"Failure","correlationId":"b1dbb6fea8378","build":"4110101"},"error":[{"errorId":"580001","domain":"PLATFORM","subdomain":"Application","severity":"Error","category":"Application","message":"Invalid request: {0}"}]} 

여기에 성공했습니다.:

curl -s --insecure \ 
-H "X-PAYPAL-SECURITY-USERID: happy_1349101075_biz_api1.onehappystudent.com" \ 
-H "X-PAYPAL-SECURITY-PASSWORD: 1349101103" \ 
-H "X-PAYPAL-SECURITY-SIGNATURE: AFcWxV21C7fd0v3bYYYRCpSSRl31Avw12OuF33eJo9IbQpXMS6wrOp1." \ 
-H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" \ 
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" \ 
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" \ 
-H "host: svcs.sandbox.paypal.com" \ 
https://svcs.sandbox.paypal.com/AdaptivePayments/Pay -d '{ 
    "actionType":"PAY", 
    "senderEmail":"[email protected]", 
    "receiverList":{ 
    "receiver":[{ 
     "email":"[email protected]", 
     "amount":"1.00" 
    }] 
    }, 
    "currencyCode":"USD", 
    "feesPayer":"EACHRECEIVER", 
    "memo":"This is a test", 
    "cancelUrl":"http://cancelurl", 
    "returnUrl":"http://returnUrl", 
    "ipnNotificationUrl":"http://your_ipn_notification_url", 
    "requestEnvelope":{ 
    "errorLanguage":"en_US" 
    } 
}' 

그리고 여기에 응답이다 :

{ responseEnvelope: 
    { timestamp: '2012-11-05T03:40:10.613-08:00', 
    ack: 'Success', 
    correlationId: 'abaf5b13c5515', 
    build: '4110101' }, 
    payKey: 'AP-4B1870921M506553S', 
    paymentExecStatus: 'COMPLETED' } 

는 다시, 당신이 제공 할 수있는 모든 도움을 주시면 감사 훨씬입니다 (사용자의 편의를 위해 prettified).

답변

3

오, 하나님이 내가 한 줄을 실종됐다 ... 바보가 된 기분을 .. .

method: 'POST' 

수업은 배운 -하지 코드를 할 때 피곤

(아마도 당신이 커피의 대규모 공급이없는 경우)

3

하지 않도록 당신이 당신의 코드가 올바른 붙여 넣은하지만이 코드는 나를 위해 작동하는 경우 - 당신은 차이를 찾을 수 있는지 :

var request = require('request'); 
body = JSON.stringify(
    {actionType: "PAY", 
    senderEmail: "[email protected]", 
    receiverList: { receiver: 
    [{ 
     email: "[email protected]", 
     amount: "1.00" 
    }]}, 
    currencyCode: "USD", 
    feesPayer: "EACHRECEIVER", 
    memo: "This is a test", 
    cancelUrl: "http://cancelurl", 
    returnUrl: "http://returnUrl", 
    ipnNotificationUrl: "http://your_ipn_notification_url", 
    requestEnvelope: { 
    errorLanguage: "en_US" } 
    }) 

console.log(body) 

request.post({ 
     headers: {"X-PAYPAL-SECURITY-USERID": "happy_1349101075_biz_api1.onehappystudent.com", "X-PAYPAL-SECURITY-PASSWORD": "1349101103", "X-PAYPAL-SECURITY-SIGNATURE": "AFcWxV21C7fd0v3bYYYRCpSSRl31Avw12OuF33eJo9IbQpXMS6wrOp1.", "X-PAYPAL-REQUEST-DATA-FORMAT": "JSON", "X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON", "X-PAYPAL-APPLICATION-ID": "APP-80W284485P519543T", "Content-Type": "application/json"}, 
     url: 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay', 
     body: body 
     }, function(error, response, body){ 
      console.log(body); 
    }); 
+0

Praveen에게 감사드립니다. 실제로 작동합니다. 당신의 예제를 보았을 때, 나는 나의 코드에 정확한 이슈를 위치 시켰고, 다소 당혹 스럽다. – LukeGT

관련 문제