php - 由于地址无效,PayPal DoDirectPayment (SOAP API) 交易失败

标签 php paypal paypal-sandbox

我正在尝试将 PayPal 模块集成到我们基于 osCommerce 的网站中 - 一个使用 PayPal DoDirectPayment (SOAP) API 来通过 PayPal 执行信用卡授权/付款的插件。到目前为止,我有:

  • 安装模块并使其正常工作
  • 在启用了 PaymentsPro 的 PayPal 沙盒中设置商家帐户
  • 使用信用卡在 Sandbox 中创建买家帐户
  • 已验证我们网站上的帐单邮寄地址与 为买家账户存储在 PayPal 沙盒中的信用卡

我能够完成结帐流程;但是每次交易失败并显示以下错误消息。

Invalid Data (10540)
The transaction cannot be processed due to an invalid address.

我已经使用单步调试(通过 XDEBUG)来验证结帐表单中指定的地址信息是否已传递到 cUrl 请求中。在发送前不久出现的 SOAP 请求下方找到:

请注意,潜在的敏感信息已更改;然而,我直接将 PayPal 沙盒中的地址与我们网站上的地址进行了比较——它们是相同的,并且符合 API 文档中列出的字段规范 here .第 42 页及以上

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI">
      <Credentials xmlns="urn:ebay:apis:eBLBaseComponents">
        <Username>login_api1.company.com</Username>
        <Password>xxxxxxxxxxxxxxxx</Password>
        <Subject></Subject>
      </Credentials>
    </RequesterCredentials>
  </soap:Header>
  <soap:Body>
    <DoDirectPaymentReq xmlns="urn:ebay:api:PayPalAPI">
      <DoDirectPaymentRequest>
        <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.0</Version>
        <DoDirectPaymentRequestDetails xmlns="urn:ebay:apis:eBLBaseComponents">
          <PaymentAction>Sale</PaymentAction>
          <PaymentDetails>
            <OrderTotal currencyID="USD">13.96</OrderTotal>
            <OrderDescription>Order placed on March 21, 2013, 2:01 pm by   (ID: xx339)</OrderDescription>
            <ItemTotal currencyID="USD">8.45</ItemTotal>
            <ShippingTotal currencyID="USD">4.51</ShippingTotal>
            <HandlingTotal currencyID="USD"></HandlingTotal>
            <TaxTotal currencyID="USD">1</TaxTotal>
            <Custom>Phone: xxx-xxx-xxxx -- Email: xxxxxxxxxx@gmail.com</Custom>
            <InvoiceID></InvoiceID>
            <NotifyURL></NotifyURL>
            <ButtonSource></ButtonSource>
            <ShipToAddress>
              <Name></Name>
              <Street1>1313 Park Forest</Street1>
              <Street2></Street2>
              <CityName>Batavia</CityName> 
              <StateOrProvince>OH</StateOrProvince>
              <PostalCode>45103</PostalCode>
              <Country>US</Country>
            </ShipToAddress>
            <PaymentDetailsItem>
                <Name>Custom Poker Deck</Name>
                <Amount currencyID="USD">5.67</Amount>
                <Number>-</Number>
                <Quantity>1</Quantity>
            </PaymentDetailsItem>
            <PaymentDetailsItem>
                <Name>BRAWL Deck</Name>
                <Amount currencyID="USD">3.78</Amount>
                <Number>-</Number>
                <Quantity>1</Quantity>
            </PaymentDetailsItem>
            <PaymentDetailsItem>
                <Name>Order Total Discrepancy</Name>
                <Amount currencyID="USD">-1.00</Amount>
                <Number>-</Number>
                <Quantity>1</Quantity>
            </PaymentDetailsItem>
          </PaymentDetails>
          <CreditCard>
            <CardOwner>
              <Payer>xxxxxxxxxx@gmail.com</Payer>
              <PayerName>
              <FirstName>John</FirstName>
              <LastName>Doe</LastName>
              </PayerName>
              <Address>
                <Street1>1313 Park Forest</Street1>
                <Street2></Street2>
                <CityName>Batavia</CityName> 
                <StateOrProvince>OH</StateOrProvince>
                <PostalCode>45103</PostalCode>
                <Country>US</Country>
              </Address>
            </CardOwner>
            <CreditCardType>Visa</CreditCardType>
            <CreditCardNumber>4711505238313977</CreditCardNumber>            
            <ExpMonth>03</ExpMonth>
            <ExpYear>2018</ExpYear>
            <CVV2>000</CVV2>            
          </CreditCard>
          <IPAddress>127.0.0.1</IPAddress>
          <MerchantSessionId>iou1mhmkuo1lnmd8e0vvpfbmp5</MerchantSessionId>
        </DoDirectPaymentRequestDetails>
      </DoDirectPaymentRequest>
    </DoDirectPaymentReq>
  </soap:Body>
</soap:Envelope>

从目标 SandBox API 端点 (https://api.sandbox.paypal.com/2.0) 收到的响应是:

<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
        <SOAP-ENV:Header>
            <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"></Security>
            <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
            <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
                <Username xsi:type="xs:string"></Username>
                <Password xsi:type="xs:string"></Password>
                <Signature xsi:type="xs:string"></Signature>
                <Subject xsi:type="xs:string"></Subject>
            </Credentials>
            </RequesterCredentials>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body id="_0">
        <DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
            <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2013-03-22T20:24:12Z</Timestamp>
            <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
            <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">94b4190427bbe</CorrelationID>
            <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
                <ShortMessage xsi:type="xs:string">Invalid Data</ShortMessage>
                <LongMessage xsi:type="xs:string">The transaction cannot be processed due to an invalid address.</LongMessage>
                <ErrorCode xsi:type="xs:token">10540</ErrorCode>
                <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
            </Errors>
            <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.0</Version>
            <Build xmlns="urn:ebay:apis:eBLBaseComponents">5479129</Build>
            <Amount xsi:type="cc:BasicAmountType" currencyID="USD">13.96</Amount>
        </DoDirectPaymentResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这个问题 ( Cannot process transaction using PayPal module ) 表明这是 SandBox 的一个问题,等待可以解决...但是我的帐户是在 19 日创建的,我仍然收到同样神秘的基于地址的拒绝。

我也搜索了 ( paypal direct payment error on sandbox ) 和 ( Paypal Website payment Pro DoDirect Payment Integration issue.This transaction cannot be processed due to an invalid merchant configuration ) 但没有找到任何有用的东西。

如有任何帮助,我们将不胜感激。

最佳答案

请求出错,因为您没有在送货地址字段中传递名称。您需要在此处插入一个名称,然后该请求应该适合您。我进行了一些测试,一旦插入名称,测试就可以正常进行。我用的也是98.0版本,应该是最新版本了。您当前将其设置为 2.0。

<ShipToAddress>
<Name></Name>
<Street1>1313 Park Forest</Street1>
<Street2></Street2>
<CityName>Batavia</CityName> 
<StateOrProvince>OH</StateOrProvince>
<PostalCode>45103</PostalCode>
<Country>US</Country>
</ShipToAddress>

关于php - 由于地址无效,PayPal DoDirectPayment (SOAP API) 交易失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15578855/

相关文章:

ios - 有必要在 PayPal 的 iOS SDK 中验证付款吗?

javascript - 限制对特定页面的访问

php - 基于数据库值创建 HTML 表

php - 接受来自信用卡 php 的 paypal 付款

PayPal 立即购买,获取付款信息

html - 如何用瑞典语打开 PayPal

php - 每年更新一次记录,全年平均分布

php - Laravel: 在闭包的地方加入闭包。 Eloquent

php - 布伦特里 Paypal 整合

javascript - Paypal Express Checkout/React - 发送产品信息