2014-03-31 5 views
0

나는 (여러 명의 사용자에게 한 번에 지불하는) Adaptive 지불 항목을 작동 시키려고합니다. 비록,SOAP 요청을 형식화하는 방법은 무엇입니까?

 'error' => [ 
     { 
      'parameter' => [ 
         'requestEnvelope', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: requestEnvelope cannot be null' 
     }, 
     { 
      'parameter' => [ 
         'actionType', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: actionType cannot be null' 
     }, 
     { 
      'parameter' => [ 
         'cancelUrl', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: cancelUrl cannot be null' 
     }, 
     { 
      'parameter' => [ 
         'currencyCode', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: currencyCode cannot be null' 
     }, 
     { 
      'parameter' => [ 
         'receiverList', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: receiverList cannot be null' 
     }, 
     { 
      'parameter' => [ 
         'returnUrl', 
         'null' 
         ], 
      'domain' => 'PLATFORM', 
      'category' => 'Application', 
      'subdomain' => 'Application', 
      'errorId' => '580022', 
      'severity' => 'Error', 
      'message' => 'Invalid request parameter: returnUrl cannot be null' 
     } 
     ], 

의 말을 모든 값이 미확정 왜 내가 조금에 관해서는 당황 해요 :

my $content = sprintf($format, qq|<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
      <soapenv:Body> 
     <actionType>PayRequest</actionType> 
     <PayRequest> 
     <requestEnvelope> 
      <errorLanguage>en_US</errorLanguage> 
      <currencyCode>USD</currencyCode> 
      <receiverList> 
       <receiver> 
       <amount>5</amount> 
       <email>test email here -but wont let me post it!</email> 
       </receiver> 
      </receiverList> 
      <returnUrl>silly forum wont let me post a test link here???</returnUrl> 
      <cancelUrl>silly forum wont let me post a test link here???</cancelUrl> 
     </requestEnvelope> 
     <payKey>AP-xxxxxxxxxxxxx</payKey>', 
     </PayRequest> 
    </soapenv:Body> 
    </soapenv:Envelope>|); 

나에게 오류의 톤을 제공합니다 : 나는 다음 SOAP 요청을하려고 해요 나는 그들을 분명히 지나쳤 을까? 그것들이 전달하는 다른 매개 변수를 감지하지만, 단지 값을 얻는 것을 좋아하지 않는 것 같습니다.

누구든지 내가 뭘 잘못하고 있다고 제안 할 수 있습니까?

업데이트 2 :

는 아직도 데 문제가 SetPaymentOptions 기능이 나를 위해 완벽하게 작동하도록 점점 보내고 있습니다. 여기

는 단위/운송 등 업데이트 내가 만들고있어 JSON 요청의 예입니다 : 당신이 PaymentDetails를 사용하여 트랜잭션을 다시 잡아 때 다음

{ 
    "receiverOptions": [ 
         { 
          "receiver":{ 
           "email":"[email protected]" 
          }, 
          "invoiceData":{ 
           "totalShipping":10, 
           "totalTax":5, 
           "item":[ 
             { 
              "itemPrice":25, 
              "name":"ITEM1", 
              "price":50, 
              "itemCount":2 
             } 
             ] 
          }, 
          "SenderOptions":{ 
           "requireShippingAddressSelection":1, 
           "addressOverride":1 
          }, 
          "customId":"foo123" 
         } 
         ], 
    "requestEnvelope":{ 
         "errorLanguage":"en_US", 
         "detailLevel":"ReturnAll" 
         }, 
    "payKey":"AP-8AK803068V089131W" 
} 

를, 그것은하지 않습니다 거기에 새로운 배송/세금/단위 변경 사항 :

'paymentInfoList' => { 
         'paymentInfo' => [ 
              { 
              'pendingRefund' => 'false', 
              'receiver' => { 
                  'accountId' => 'AH92SPWMDXTHJ', 
                  'email' => '[email protected]', 
                  'amount' => '65.00', 
                  'primary' => 'false', 
                  'paymentType' => 'GOODS' 
                  } 
              } 
             ] 
        }, 

정말 짜증나는 부분은, 내가 운송/전체/세금 값을 변경하는 경우, 너무 수가 엄마하지 않습니다 만드는 것입니다 -하지만 그냥 같은과 PaymentDetails 요청을 보여 거부 그래서

ERROR: The total invoiced amount for [email protected] does not match the amount in the pay request at test.cgi line 127.

는 값을 따기해야합니다 TCH는 원래 "유료"요청까지 ... 다음 오류가 발생합니다 payID

제발 도와주세요 - 지금 내 재능이 끝났습니다.

답변

0

좋아, (어떤 이유로 SOAP 요청은 나를 위해 싶지 일했다 - 그것은 내가 SOAP11 또는이다 SOAP12를 사용하는 데 필요한 것을 신음 유지 WAS)

다음

내가 JSON 방법을 사용하여, 페이팔 병렬 지불 작업있어 것입니다!

use HTTP::Request::Common; 
    use LWP::UserAgent;my $user   = 'foobar.user'; 
    my $password  = '1396280437'; 
    my $signature  = 'the secret sig'; 
    my $application_id = 'APP-80W284485P519543T'; 

    my $url   = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay'; 

    my $ua  = LWP::UserAgent->new(); 
    my $headers = HTTP::Headers->new(
      'X-PAYPAL-SECURITY-USERID' => $user, 
      'X-PAYPAL-SECURITY-PASSWORD' => $password, 
      'X-PAYPAL-SECURITY-SIGNATURE' => $signature, 
      'X-PAYPAL-APPLICATION-ID'  => $application_id, 
      'X-PAYPAL-DEVICE-IPADDRESS' => $ENV{REMOTE_ADDR}, 
      'X-PAYPAL-REQUEST-DATA-FORMAT' => 'JSON', 
      'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'JSON' 
      ); 

     my $json_var = { 
      requestEnvelope => { 
       detailLevel => "ReturnAll", 
       errorLanguage => "en_US", 
      }, 
      actionType => "PAY", 
      currencyCode => "USD", 
      receiverList => { 
       receiver => [ 
       { 
        amount => 5, 
        email => '[email protected]' 
       }, 
       { 
        amount => 15, 
        email => '[email protected]' 
       } 
       ], 
      }, 
      returnUrl => 'http://sitexx.com/return.cgi', 
      cancelUrl => 'http://sitexx.com/cancel.html' 
     }; 

     use JSON; 
     my $new_json = JSON::to_json($json_var); 

    my $request = HTTP::Request->new('POST', $url, $headers, $new_json); 
    my $response = $ua->request($request); 

    my $json_returned = decode_json($response->decoded_content); 

    print qq|Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=$json_returned->{payKey} \n\n|; 

내가 운동 할 수있는 유일한 방법은, 다른 운송 가격을 제공해야하는 방법이다 각 사람. 당신이 단지 수있는 일반 HTML 양식을 사용 :

<input type="hidden" name="shipping" value="9"> 

그러나, "수신기"섹션에서, 값으로 "배송"을 전달하려고 작동하지 않습니다. anyones가 그것에 대한 제안을 가지고 있는지 확실하지 않은가요?

UPDATE : 음 실제로, 어쩌면 그 작동하지

. 이 페이지에 따르면 https://developer.paypal.com/docs/classic/api/adaptive-payments/SetPaymentOptions_API_Operation/, 형식이 있어야합니다 같은 : &receiverOptions[0][email protected]&receiverOptions[0].invoiceData.item[0].name=ITEM1&receiverOptions[0].invoiceData.item[0].price=50.0&receiverOptions[0].invoiceData.item[0].itemCount=2&receiverOptions[0].invoiceData.item[0].itemPrice=25.0&receiverOptions[0].invoiceData.totalTax=25.0&receiverOptions[0].invoiceData.totalShipping=25.0

내 JSON이 함께 통과로 온다되고 :

{"receiverOptions":[{"receiver":{"email":"[email protected]"},"invoiceData":{"item":[{"name","ITEM1","price",50,"itemCount",2,"itemPrice",25,"totalTax",5,"totalShipping",10}]}},{"receiver":{"email":"[email protected]"},"invoiceData":{"item":[{"name","ITEM2","price",15,"itemCount",1,"itemPrice",15,"totalTax",0,"totalShipping",20}]}}],"requestEnvelope":{"errorLanguage":"en_US","detailLevel":"ReturnAll"},"payKey":"AP-2LN695598Y955615N"}

응답은 다시 온다 :

 'responseEnvelope' => { 
           'correlationId' => '0ba8c3bf33425', 
           'timestamp' => '2014-04-01T07:10:07.752-07:00', 
           'ack' => 'Success', 
           'build' => '10273932' 
          } 

. .. 그래서 그것 치명적이지 않은. .. 그러나 내가 지불 페이지에 갈 때, 나는 어떤 운송, 수량 (또는 내가 여기에 추가하는 무엇이라도)을 보지 않는다. 나는 이것이 왜 그런지에 대해 다소 당혹 스럽다.

쉽게 읽을 수 (JSON으로 변환하기 전에 펄 변수에) 그 JSON의 더 예쁜 버전 :

receiverOptions => [ 
     { 
      receiver => { 
       email => '[email protected]' 
      }, 
      invoiceData => { 
       item => [{ 
       name  => "ITEM1", 
       price  => 50, 
       itemCount => 2, 
       itemPrice => 25, 
       totalTax => 5, 
       totalShipping => 10, 
       }] 
      } 

     },{ 
      receiver => { 
       email => '[email protected]' 
      }, 
      invoiceData => { 
       item => [{ 
       name  => "ITEM2", 
       price  => 15, 
       itemCount => 1, 
       itemPrice => 15, 
       totalTax => 0, 
       totalShipping => 20, 
       }] 
      } 
     } 
    ] 

어떤 제안?

1

네임 스페이스 속성을 XML params에 추가해야한다고 생각합니다. 잘 작동하는 샘플 요청을 살펴보십시오. 결국 내가 JSON을 사용할 수 있습니다 발견 있도록

<?xml version="1.0" encoding="utf-8"?> 
<PayRequest xmlns="http://svcs.paypal.com/types/ap"> 
    <requestEnvelope xmlns=""> 
    <detailLevel>ReturnAll</detailLevel> 
    <errorLanguage>en_US</errorLanguage> 
    </requestEnvelope> 
    <actionType xmlns="">PAY</actionType> 
    <cancelUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Cancel.php</cancelUrl> 
    <clientDetails xmlns=""> 
    <applicationId xmlns="">APP-80W284485P519543T</applicationId> 
    <ipAddress xmlns="">37.187.79.225</ipAddress> 
    <partnerName xmlns="">Always Give Back</partnerName> 
    </clientDetails> 
    <currencyCode xmlns="">USD</currencyCode> 
    <receiverList xmlns=""> 
    <receiver xmlns=""> 
     <amount xmlns="">10.00</amount> 
     <email xmlns="">[email protected]</email> 
    </receiver> 
    <receiver xmlns=""> 
     <amount xmlns="">5.00</amount> 
     <email xmlns="">[email protected]</email> 
     <invoiceId xmlns="">123-ABCDEF</invoiceId> 
    </receiver> 
    </receiverList> 
    <sender> 
    <useCredentials xmlns=""></useCredentials> 
    </sender> 
    <account xmlns=""> 
    <phone xmlns=""></phone> 
    </account> 
    <returnUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Return.php</returnUrl> 
</PayRequest> 
+0

포인터 주셔서 감사합니다. 나는 여전히 SOAP 요소를 사용할 수 없으므로 위에 게시 한 JSON 코드를 사용하게되었습니다. 1 인당 기준으로 배송하는 방법에 대해 알고 있다면 확실하지 않은가요? 나는 그것이 가능할 것이라고 추측하고있다 - 그러나 다시, 그것에 관한 어떤 문서도 찾을 수 없다 :/ –

1

CREATE로 설정된 작업으로 Pay API를 호출 한 다음 그로부터 얻은 Paykey를 SetPaymentOptions으로 전달합니다. 이를 통해 트랜잭션의 각 수신자에 대한 항목, 배송 정보 등의 추가 매개 변수를 설정할 수 있습니다.

+0

고마워. - 그것은 나에게 일하고 싶지 않은 어떤 이유 때문에. 내 recieveList에서, 나는 : amount => 50, email => 'andy.newby @ gmail.com'을 가지고 다음에 전달 된'SetPaymentOptions'를 사용했다 : 'invoiceData => {name => "ITEM1" price => 50, itemCount => 2, itemPrice => 25, totalTax => 0}'어떤 이유로 인해 오류가 발생합니다 :'[email protected]의 총 인보이스 금액이 유료 요청'2 번째 요청의 가격이 반드시 첫 번째 '유료'요청에서 얻은 것까지 계산하면됩니까? –

+0

아, 알겠습니다 : 서브 어레이가 필요했습니다. 어떻게 사용했는지 알 필요가 없습니다. 따라서 형식은 다음과 같아야합니다 :'invoiceData => {item => {name => "ITEM1", price => 50, itemCount => 2, itemPrice => 25, totalTax => 0}}'... 조금 복잡하지만 지금은 효과가있는 것처럼 보입니다. 당신의 도움을 주셔서 감사합니다! –

+0

음, 실제로 그 일을하지 않았습니다 (내 값 중 아무 것도 구원받지 못하는 것 같습니다). 내 마지막 답장에서 "업데이트"후 업데이트를 확인하십시오. (더 많은 예제 코드를 추가하고 더 자세한 내용을 설명했습니다) –

관련 문제