Permalink
Browse files

Add a useLocalWsdl option to Payment_PayPal_SOAP.

  • Loading branch information...
Michael Gauthier
Michael Gauthier committed Aug 5, 2011
1 parent ea24f18 commit b861c08c83572e3dd76a958ef7a3196b1fddae61
View
@@ -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
@@ -197,16 +211,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
*
@@ -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
);
}
@@ -756,6 +769,46 @@ protected function setMode($mode)
return $this;
}
+ // }}}
+ // {{{ 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;
+ }
+
// }}}
}
@@ -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>
@@ -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>
Oops, something went wrong.

0 comments on commit b861c08

Please sign in to comment.