Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a useLocalWsdl option to Payment_PayPal_SOAP.

  • Loading branch information...
commit b861c08c83572e3dd76a958ef7a3196b1fddae61 1 parent ea24f18
Michael Gauthier authored
View
113 Payment/PayPal/SOAP.php
@@ -16,7 +16,7 @@
*
* LICENSE:
*
- * Copyright (c) 2008-2009 silverorange
+ * Copyright (c) 2008-2011 silverorange
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -64,7 +64,7 @@
* @category Payment
* @package Payment_PayPal_SOAP
* @author Michael Gauthier <mike@silverorange.com>
- * @copyright 2008-2010 silverorange
+ * @copyright 2008-2011 silverorange
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link http://pear.php.net/package/Payment_PayPal_SOAP
*/
@@ -131,6 +131,20 @@ class Payment_PayPal_SOAP
'soap_version' => SOAP_1_1
);
+ /**
+ * Whether or not to use a local copy of the PayPal WSDL
+ *
+ * If true, a local copy of the PayPal WSDL is used instead of the copy
+ * hosted on PayPal's servers. This can be used if PayPal breaks the hosted
+ * WSDL files, as has happened in the past.
+ *
+ * @var boolean
+ *
+ * @see Payment_PayPal_SOAP::__construct()
+ * @see Payment_PayPal_SOAP::getWsdlFile()
+ */
+ protected $useLocalWsdl = false;
+
// }}}
// {{{ private properties
@@ -198,16 +212,6 @@ class Payment_PayPal_SOAP
private $_subject = '';
/**
- * WSDL files for the PayPal SOAP API indexed by mode
- *
- * @var array
- */
- static private $_wsdlFiles = array(
- 'sandbox' => 'https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl',
- 'live' => 'https://www.paypal.com/wsdl/PayPalSvc.wsdl'
- );
-
- /**
* API endpoints indexed by mode and security mode
*
* Certificate-based authentication uses a different API endpoint than
@@ -243,23 +247,28 @@ class Payment_PayPal_SOAP
*
* The available options are:
*
- * - <kbd>mode</kbd> - optional. The mode to use for PayPal API
- * calls. Valid modes are <kbd>sandbox</kbd>
- * for development and testing, and
- * <kbd>live</kbd> for live payments. If not
- * specified, <em><kbd>sandbox</kbd></em> is
- * used.
- * - <kbd>username</kbd> - the username used for authentication.
- * - <kbd>password</kbd> - the password used for authentication.
- * - <kbd>subject</kbd> - optional. The third-party on whose behalf
- * requests are to be made.
- * - <kbd>signature</kbd> - optional. The signature used for signature-
- * based authentication. Not required if
- * certificate-based authentication is used.
- * - <kbd>certificate</kbd> - optional. The local certificate filename used
- * for certificate-based authentication. Not
- * required if signature-based authentication is
- * used.
+ * - <kbd>mode</kbd> - optional. The mode to use for PayPal API
+ * calls. Valid modes are <kbd>sandbox</kbd>
+ * for development and testing, and
+ * <kbd>live</kbd> for live payments. If not
+ * specified, <em><kbd>sandbox</kbd></em> is
+ * used.
+ * - <kbd>username</kbd> - the username used for authentication.
+ * - <kbd>password</kbd> - the password used for authentication.
+ * - <kbd>subject</kbd> - optional. The third-party on whose behalf
+ * requests are to be made.
+ * - <kbd>signature</kbd> - optional. The signature used for signature-
+ * based authentication. Not required if
+ * certificate-based authentication is used.
+ * - <kbd>certificate</kbd> - optional. The local certificate filename used
+ * for certificate-based authentication. Not
+ * required if signature-based authentication is
+ * used.
+ * - <kbd>useLocalWsdl</kbd> - optional. When sepecified as true, a local
+ * copy of the PayPal WSDL is used instead of
+ * the copy hosted on PayPal's servers. This
+ * can be used if PayPal breaks the hosted
+ * WSDL files, as has happened in the past.
*
* @param array $options array of options.
*
@@ -300,6 +309,10 @@ public function __construct(array $options)
$hasCertificate = true;
$this->setCertificateFile($value);
break;
+
+ case 'useLocalWsdl':
+ $this->useLocalWsdl = ($value) ? true : false;
+ break;
}
}
@@ -584,7 +597,7 @@ protected function getSoapClient()
{
if (!($this->soapClient instanceof SoapClient)) {
$this->soapClient = new SoapClient(
- self::$_wsdlFiles[$this->_mode],
+ $this->getWsdlFile(),
$this->soapOptions
);
}
@@ -757,6 +770,46 @@ protected function setMode($mode)
}
// }}}
+ // {{{ getWsdlFile()
+
+ /**
+ * Gets the WSDL file to use when building the SOAP object
+ *
+ * @return string the WSDL file to use when building the SOAP object.
+ */
+ protected function getWsdlFile()
+ {
+ if ($this->useLocalWsdl) {
+ $path = '@data-dir@/Payment_PayPal_SOAP/data/wsdl';
+ if (substr($path, 0, 1) === '@') {
+ $path = dirname(__FILE__) . '/../../data/wsdl';
+ }
+
+ switch ($this->_mode) {
+ case 'live':
+ $file = $path . '/live/PayPalSvc.wsdl';
+ break;
+ case 'sandbox':
+ default:
+ $file = $path . '/sandbox/PayPalSvc.wsdl';
+ break;
+ }
+ } else {
+ switch ($this->_mode) {
+ case 'live':
+ $file = 'https://www.paypal.com/wsdl/PayPalSvc.wsdl';
+ break;
+ case 'sandbox':
+ default:
+ $file = 'https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl';
+ break;
+ }
+ }
+
+ return $file;
+ }
+
+ // }}}
}
?>
View
53 data/wsdl/live/CoreComponentTypes.xsd
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="urn:ebay:apis:CoreComponentTypes" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:apis:CoreComponentTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:import namespace="urn:ebay:apis:eBLBaseComponents" schemaLocation="eBLBaseComponents.xsd"/>
+ <!-- Definition of AmountType -->
+ <xs:complexType name="AmountType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="currencyID" type="ebl:CurrencyCodeType" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="BasicAmountType">
+ <xs:annotation><xs:documentation>On requests, you must set the currencyID attribute to one of the three-character currency codes for any of the supported PayPal currencies.
+<br/><br/>
+Limitations: Must not exceed $10,000 USD in any currency. No currency symbol. Decimal separator must be a period (.), and the thousands separator must be a comma (,).
+</xs:documentation></xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="currencyID" type="ebl:CurrencyCodeType" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of MeasureType -->
+ <xs:complexType name="MeasureType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="unit" type="xs:token" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of QuantityType -->
+ <xs:complexType name="QuantityType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="unit" type="xs:token" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of UUIDType (as a simpleType)-->
+ <xs:simpleType name="UUIDType">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies a universally unique identifier. The UUID can
+ only contain digits from 0-9 and letters from A-F. The
+ UUID must be 32 characters long. For example,
+ 1FB02B2-9D27-3acb-ABA2-9D539C374228
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:string">
+ <xs:length value="36"/>
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
View
25 data/wsdl/live/EnhancedDataTypes.xsd
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="urn:ebay:apis:EnhancedDataTypes" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ns="urn:ebay:apis:EnhancedDataTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="EnhancedCheckoutDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPaymentDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedItemDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPaymentInfoType">
+ </xs:complexType>
+ <xs:element name="EnhancedInitiateRecoupRequestDetails" type="ns:EnhancedInitiateRecoupRequestDetailsType"/>
+ <xs:element name="EnhancedCompleteRecoupRequestDetails" type="ns:EnhancedCompleteRecoupRequestDetailsType"/>
+ <xs:element name="EnhancedCompleteRecoupResponseDetails" type="ns:EnhancedCompleteRecoupResponseDetailsType"/>
+ <xs:element name="EnhancedCancelRecoupRequestDetails" type="ns:EnhancedCancelRecoupRequestDetailsType"/>
+ <xs:complexType name="EnhancedInitiateRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCompleteRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCompleteRecoupResponseDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCancelRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPayerInfoType">
+ </xs:complexType>
+</xs:schema>
View
4,457 data/wsdl/live/PayPalSvc.wsdl
4,457 additions, 0 deletions not shown
View
13,909 data/wsdl/live/eBLBaseComponents.xsd
13,909 additions, 0 deletions not shown
View
53 data/wsdl/sandbox/CoreComponentTypes.xsd
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="urn:ebay:apis:CoreComponentTypes" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:apis:CoreComponentTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:import namespace="urn:ebay:apis:eBLBaseComponents" schemaLocation="eBLBaseComponents.xsd"/>
+ <!-- Definition of AmountType -->
+ <xs:complexType name="AmountType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="currencyID" type="ebl:CurrencyCodeType" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="BasicAmountType">
+ <xs:annotation><xs:documentation>On requests, you must set the currencyID attribute to one of the three-character currency codes for any of the supported PayPal currencies.
+<br/><br/>
+Limitations: Must not exceed $10,000 USD in any currency. No currency symbol. Decimal separator must be a period (.), and the thousands separator must be a comma (,).
+</xs:documentation></xs:annotation>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="currencyID" type="ebl:CurrencyCodeType" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of MeasureType -->
+ <xs:complexType name="MeasureType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="unit" type="xs:token" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of QuantityType -->
+ <xs:complexType name="QuantityType">
+ <xs:simpleContent>
+ <xs:extension base="xs:double">
+ <xs:attribute name="unit" type="xs:token" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <!-- Definition of UUIDType (as a simpleType)-->
+ <xs:simpleType name="UUIDType">
+ <xs:annotation>
+ <xs:documentation>
+ Specifies a universally unique identifier. The UUID can
+ only contain digits from 0-9 and letters from A-F. The
+ UUID must be 32 characters long. For example,
+ 1FB02B2-9D27-3acb-ABA2-9D539C374228
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:string">
+ <xs:length value="36"/>
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
View
25 data/wsdl/sandbox/EnhancedDataTypes.xsd
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="urn:ebay:apis:EnhancedDataTypes" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ns="urn:ebay:apis:EnhancedDataTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="EnhancedCheckoutDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPaymentDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedItemDataType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPaymentInfoType">
+ </xs:complexType>
+ <xs:element name="EnhancedInitiateRecoupRequestDetails" type="ns:EnhancedInitiateRecoupRequestDetailsType"/>
+ <xs:element name="EnhancedCompleteRecoupRequestDetails" type="ns:EnhancedCompleteRecoupRequestDetailsType"/>
+ <xs:element name="EnhancedCompleteRecoupResponseDetails" type="ns:EnhancedCompleteRecoupResponseDetailsType"/>
+ <xs:element name="EnhancedCancelRecoupRequestDetails" type="ns:EnhancedCancelRecoupRequestDetailsType"/>
+ <xs:complexType name="EnhancedInitiateRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCompleteRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCompleteRecoupResponseDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedCancelRecoupRequestDetailsType">
+ </xs:complexType>
+ <xs:complexType name="EnhancedPayerInfoType">
+ </xs:complexType>
+</xs:schema>
View
4,457 data/wsdl/sandbox/PayPalSvc.wsdl
4,457 additions, 0 deletions not shown
View
13,909 data/wsdl/sandbox/eBLBaseComponents.xsd
13,909 additions, 0 deletions not shown
View
19 package.php
@@ -40,15 +40,14 @@
require_once 'PEAR/PackageFileManager2.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
-$api_version = '0.3.0';
+$api_version = '0.4.0';
$api_state = 'beta';
-$release_version = '0.3.0';
+$release_version = '0.4.0';
$release_state = 'beta';
$release_notes =
- " * Add support for 'subject' field in SOAP headers to make requests " .
- " on behalf of third parties.\n" .
- " * Add fluent-interface to setter methods.\n";
+ " * Add 'useLocalWsdl' that can work around bad WSDL files hosted by " .
+ "PayPal\n";
$description =
"This package provides an easy-to-use wrapper of PHP 5's SOAP client " .
@@ -70,7 +69,8 @@
'Payment' => 'php',
'Payment/PayPal' => 'php',
'Payment/PayPal/SOAP' => 'php',
- 'tests' => 'test'
+ 'tests' => 'test',
+ 'data' => 'data'
),
'ignore' => array(
'package.php'
@@ -94,6 +94,13 @@
$package->setAPIVersion($api_version);
$package->setAPIStability($api_state);
+$package->addReplacement(
+ 'Payment/PayPal/SOAP.php',
+ 'pear-config',
+ '@data-dir@',
+ 'data_dir'
+);
+
$package->addMaintainer(
'lead',
'gauthierm',
View
42 package.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+<package packagerversion="1.9.3" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
@@ -17,11 +17,11 @@ Note: Due to a PHP bug, PHP versions 5.2.2 to 5.2.6 are incompatible with this p
<email>mike@silverorange.com</email>
<active>yes</active>
</lead>
- <date>2010-03-29</date>
- <time>13:33:09</time>
+ <date>2011-08-05</date>
+ <time>11:16:22</time>
<version>
- <release>0.3.0</release>
- <api>0.3.0</api>
+ <release>0.4.0</release>
+ <api>0.4.0</api>
</version>
<stability>
<release>beta</release>
@@ -29,17 +29,34 @@ Note: Due to a PHP bug, PHP versions 5.2.2 to 5.2.6 are incompatible with this p
</stability>
<license uri="http://www.opensource.org/licenses/mit-license.html">MIT</license>
<notes>
-* Add support for &apos;subject&apos; field in SOAP headers to make requests on behalf of third parties.
- * Add fluent-interface to setter methods.
+* Add &apos;useLocalWsdl&apos; that can work around bad WSDL files hosted by PayPal
</notes>
<contents>
<dir baseinstalldir="/" name="/">
+ <dir name="data">
+ <dir name="wsdl">
+ <dir name="live">
+ <file name="CoreComponentTypes.xsd" role="data" />
+ <file name="eBLBaseComponents.xsd" role="data" />
+ <file name="EnhancedDataTypes.xsd" role="data" />
+ <file name="PayPalSvc.wsdl" role="data" />
+ </dir> <!-- /data/wsdl/live -->
+ <dir name="sandbox">
+ <file name="CoreComponentTypes.xsd" role="data" />
+ <file name="eBLBaseComponents.xsd" role="data" />
+ <file name="EnhancedDataTypes.xsd" role="data" />
+ <file name="PayPalSvc.wsdl" role="data" />
+ </dir> <!-- /data/wsdl/sandbox -->
+ </dir> <!-- /data/wsdl -->
+ </dir> <!-- /data -->
<dir name="Payment">
<dir name="PayPal">
<dir name="SOAP">
<file name="Exceptions.php" role="php" />
</dir> <!-- /Payment/PayPal/SOAP -->
- <file name="SOAP.php" role="php" />
+ <file name="SOAP.php" role="php">
+ <tasks:replace from="@data-dir@" to="data_dir" type="pear-config" />
+ </file>
</dir> <!-- /Payment/PayPal -->
</dir> <!-- /Payment -->
<dir name="tests">
@@ -74,18 +91,17 @@ Note: Due to a PHP bug, PHP versions 5.2.2 to 5.2.6 are incompatible with this p
<changelog>
<release>
<version>
- <release>0.3.0</release>
- <api>0.3.0</api>
+ <release>0.4.0</release>
+ <api>0.4.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
- <date>2010-03-29</date>
+ <date>2011-08-05</date>
<license uri="http://www.opensource.org/licenses/mit-license.html">MIT</license>
<notes>
-* Add support for &apos;subject&apos; field in SOAP headers to make requests on behalf of third parties.
- * Add fluent-interface to setter methods.
+* Add &apos;useLocalWsdl&apos; that can work around bad WSDL files hosted by PayPal
</notes>
</release>
</changelog>
Please sign in to comment.
Something went wrong with that request. Please try again.