paypal SoapClient 不工作

发布于 2024-09-06 08:03:19 字数 1802 浏览 3 评论 0原文

我正在使用 PHP 的 SoapClient 类连接到 paypal。我有很多问题:

  1. 我传递给肥皂调用的参数是 array('ReturnAllCurrency'=>0, 'Version'=>'63.0') 但正如您在在下面的请求中,63.0 被放入 中,无论它是什么。我什至没有在请求中看到 ReturnAllCurrency。

在此请求中,我正在执行 GetBalance 命令:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ebay:api:PayPalAPI" xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
      <SOAP-ENV:Header>
            <ns1:RequesterCredentials>
                  <ns2:Credentials>
                        <ns2:Username>xxxx</ns2:Username>
                        <ns2:Password>xxx</ns2:Password>
                        <ns2:Signature>xxx</ns2:Signature>
                  </ns2:Credentials>
            </ns1:RequesterCredentials>
      </SOAP-ENV:Header>
      <SOAP-ENV:Body>
            <ns1:GetBalanceReq/>
            <param1>63.0</param1>
      </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我通过 SoapClient::__getLastRequest() 找到了上面的请求。它看起来并不完全像贝宝网站上的示例。 GetBalanceReq 标签有什么用?为什么它有 *Req 后缀?

2.当使用生产服务器和wsdl文件时,出现php错误:

SOAP 错误:解析 WSDL: 无法加载自 'https://www.paypal.com/wsdl/PayPalSvc.wsdl&#039 ; : 需要开始标记,'<' 未找到

此外,如果我尝试访问 FireFox 中的生产证书 url (https://api.paypal.com/ 2.0/) 我收到 ssl_error_handshake_failure_alert

我是否应该下载 wsdl 文件并在 SoapClient::__construct 的第一个参数中指向本地版本,或者我是否应该简单地指向 paypal 托管副本?我原本以为是后者,但现在不确定

I am using PHP's SoapClient class to connect to paypal. I have a number of problems:

  1. The paramaters I pass to the soap call are array('ReturnAllCurrencies'=>0, 'Version'=>'63.0') but as you can see in the request below, 63.0 is put in <param1> whatever that is. I don't even see ReturnAllCurrencies in the request.

In this request I am performing a GetBalance command:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ebay:api:PayPalAPI" xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
      <SOAP-ENV:Header>
            <ns1:RequesterCredentials>
                  <ns2:Credentials>
                        <ns2:Username>xxxx</ns2:Username>
                        <ns2:Password>xxx</ns2:Password>
                        <ns2:Signature>xxx</ns2:Signature>
                  </ns2:Credentials>
            </ns1:RequesterCredentials>
      </SOAP-ENV:Header>
      <SOAP-ENV:Body>
            <ns1:GetBalanceReq/>
            <param1>63.0</param1>
      </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I found the request above via SoapClient::__getLastRequest(). It doesn't exacly look like the example on the paypal website. What's with the GetBalanceReq tag? Why does it have the *Req suffix?

2.When using the production server and wsdl files, I get a php error:

SOAP-ERROR: Parsing WSDL:
Couldn't load from
'https://www.paypal.com/wsdl/PayPalSvc.wsdl';
: Start tag expected, '<'
not found

Furthermore if I try to visit the production certificate url in FireFox (https://api.paypal.com/2.0/) I get a ssl_error_handshake_failure_alert

Am I supposed to download the wsdl file and point to a local version in the first argument of SoapClient::__construct or am I simple supposed to point to the paypal hosted copy? I originally assumed the latter, but now I'm not sure

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热情消退 2024-09-13 08:03:19

首先,“ReturnAllCurrency”应该是字符串,而不是整数。此外,您需要将 GetBalanceRequestType 字段包装在 GetBalanceRequest 元素内才能使其正常工作。有关问题第一部分以及有效解决方案的更多信息,请参见此处:

需要 paypal 的简单 php SoapClient 示例

你问题的第二部分听起来像是 Paypal 基础设施的临时问题。最佳实践是不要使用 WSDL 的本地副本,而是打开 WSDL 缓存并让 PHP 决定何时刷新它。

Firstly, "ReturnAllCurrencies" should be a string, not an integer. Also, you need to wrap the GetBalanceRequestType fields inside a GetBalanceRequest element for it to work. For more info regarding the first part of your question along with a working solution, look here:

simple php SoapClient example for paypal needed

The second part of your question sounds like a temporary issue with the Paypal infrastructure. Best practice is to NOT use a local copy of the WSDL but to turn WSDL caching on and let PHP decide when to refresh it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文