api - 如何格式化 SOAP 请求?

标签 api soap paypal paypal-adaptive-payments

我正在尝试让自适应支付功能发挥作用(一次向多个用户付款)。我正在尝试以下 SOAP 请求:

    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>|);

这给了我很多错误:

     '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'
        }
      ],

我有点困惑,为什么它说所有这些值都是 undef,即使我清楚地传递了它们?它检测我传入的不同参数,但它似乎不喜欢从中获取值

谁能指出我做错了什么?

更新 2:

我仍然无法让 SetPaymentOptions 功能完全为我工作。

这是我发出的 JSON 请求的示例,用于更新单位/运费等:

 {
    "receiverOptions": [
                        {
                            "receiver":{
                                "email":"andyxxx@gmail.com"
                            },
                            "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"
}

然后,当您使用 PaymentDetails 重新获取交易时,其中没有任何新的运费/税收/单位更改:

'paymentInfoList' => {
                       'paymentInfo' => [
                                          {
                                            'pendingRefund' => 'false',
                                            'receiver' => {
                                                            'accountId' => 'AH92SPWMDXTHJ',
                                                            'email' => 'andyxxx@gmail.com',
                                                            'amount' => '65.00',
                                                            'primary' => 'false',
                                                            'paymentType' => 'GOODS'
                                                          }
                                          }
                                        ]
                     },

真正烦人的部分是,如果我更改运费/总计/税值,使数字与原始“支付”请求不匹配...然后我得到一个错误:

错误:andyxxx@gmail.com 的总发票金额与 test.cgi 第 127 行的付款请求中的金额不匹配。

所以它必须选择值 - 但它只是拒绝在具有相同 payIDPaymentDetails 请求中显示它们

请帮忙 - 因为我现在已经不知所措了!

最佳答案

我认为您需要将命名空间属性添加到 XML 参数中。看看这个工作正常的示例请求。

<?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="">sandbo_1204199080_biz@angelleye.com</email>
    </receiver>
    <receiver xmlns="">
      <amount xmlns="">5.00</amount>
      <email xmlns="">usb_1329725429_biz@angelleye.com</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>

关于api - 如何格式化 SOAP 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22770581/

相关文章:

iphone - 我如何通过iphone开发存储来自SQLite数据库的数据

php - PayPal 从 Sandbox 升级到 Production,未发现错误

javascript - javascript有没有像API这样的概念

javascript - React-Redux API Get 请求操作未执行?

android - 如何从 php webservice 在 android 应用程序 arraylist 中解析

paypal - 我可以结合使用网站支付标准和 Paypal API 来实现 Paypal 吗?

php - 在 Google Analytics 中准确报告使用 PayPal 付款的推荐人

api - 处理 J2ME 中的可选 API

facebook - 使用 Facebook API 获取页面的所有照片

Java 客户端、SOAP 和 Exchange Web 服务 (EWS)