Payment_PayPal_SOAP
[ class tree: Payment_PayPal_SOAP ] [ index: Payment_PayPal_SOAP ] [ all elements ]

Class: Payment_PayPal_SOAP

Source Location: /Payment_PayPal_SOAP-0.5.1/Payment/PayPal/SOAP.php

Class Overview


An easy to use SOAP client for the PayPal SOAP API


Author(s):

Copyright:

  • 2008-2011 silverorange

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 71]
An easy to use SOAP client for the PayPal SOAP API

By itself, this class isn't very useful. It should be used in combination with the documentation provided by PayPal at https://www.paypal.com/en_US/pdf/PP_APIReference.pdf. This class makes it easier to get up and running, and allows you to begin integration by making requests rather than by figuring out how to set SOAP authentication headers.



[ Top ]


Class Variables

$soapClient =  null

[line 100]

SOAP client used to make PayPal SOAP requests

Type:   SoapClient


[ Top ]

$soapHeader =  null

[line 111]

SOAP header values specific to PayPal SOAP API

This contains PayPal authentication values.


Type:   SoapHeader


[ Top ]

$soapOptions = array(
        'trace'        => true,
        'soap_version' => SOAP_1_1
    )

[line 129]

Options passed to the SOAP client when it is created

PayPal's SOAP implementation uses SOAP 1.1 so the SOAP version option is specified by default. If using local certificates for authentication, the local certificate file is also included in these options.

The API endpoint location is also specified in these options as the endpoint in the WSDL file is not always correct depending on the authentication mechanism used.


Type:   array


[ Top ]

$useLocalWsdl =  false

[line 146]

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.


Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 280]

Payment_PayPal_SOAP __construct( $options)

Creates a new PayPal SOAP client

Either signature-based or certificate-based authentication options are required. The username, password and optional signature fields may be retrieved from your PayPal account in the 'API Credentials' section.

Sandbox and live modes require different PayPal accounts so all option values will require changing if you select a different mode.

The available options are:

  • mode - optional. The mode to use for PayPal API calls. Valid modes are sandbox for development and testing, and live for live payments. If not specified, <em>sandbox</em> is used.
  • username - the username used for authentication.
  • password - the password used for authentication.
  • subject - optional. The third-party on whose behalf requests are to be made.
  • signature - optional. The signature used for signature- based authentication. Not required if certificate-based authentication is used.
  • certificate - optional. The local certificate filename used for certificate-based authentication. Not required if signature-based authentication is used.
  • useLocalWsdl - 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.

  • Throws: InvalidArgumentException if neither a signature nor a certificate file is specified in the options array, or if the username or password options are not specified in the options array.
  • Access: public

Parameters:

array   $options     array of options.

[ Top ]

call   [line 393]

mixed call( string $requestName, [mixed $arguments = array()])

Makes a PayPal SOAP request

If a structured array is used as the arguments, WSDL types with attributes may be specified as:

  1.  $arguments = array(
  2.      'OrderTotal' => array(    // 'OrderTotal' is a type with attributes
  3.          '_' => '1000.00',     // this is the element value
  4.          'currencyID' => 'USD' // this is an attribute value
  5.      )
  6.  );

  • Return: the PayPal SOAP response. If only one value is returned for the request, a simple value (e.g. an integer, a string, etc) is returned. For requests that return multiple values or complex types, a data structure composed of stdClass objects is returned.
  • Throws: Payment_PayPal_SOAP_InvalidRequestNameException if the specified request name is not a valid PayPal SOAP API request name.
  • Throws: Payment_PayPal_SOAP_FaultException if a SOAP initialization error occurs or an unknown SOAP error occurs.
  • Throws: Payment_PayPal_SOAP_MissingPropertyException if a required property for a request type is not specified in the request arguments. Refer to the PayPal SOAP API documentation at https://www.paypal.com/en_US/pdf/PP_APIReference.pdf for information about required fields.
  • Throws: Payment_PayPal_SOAP_ErrorException if a SOAP response contains one or more Error elements. A detailed error message will be present in the exception message and the PayPal error code will be in the exception code.
  • Access: public

Parameters:

string   $requestName     the name of the request. This should be a request documented in the PayPal SOAP API reference manual. Sending a request of an invalid type will cause a SoapFault to be thrown.
mixed   $arguments     optional. Either a structured array or an object representing the SOAP request arguments. If the request requires no arguments, this parameter may be ommitted.

[ Top ]

getLastRequest   [line 532]

boolean|string getLastRequest( )

Gets the XML sent in the last SOAP request
  • Return: the XML sent in the last SOAP request. If no request has been performed, false is returned.
  • Access: public

[ Top ]

getLastResponse   [line 552]

boolean|string getLastResponse( )

Gets the XML returned in the last SOAP response
  • Return: the XML used in the last SOAP response. If no response has been retrieved, false is returned.
  • Access: public

[ Top ]

getSoapClient   [line 621]

SoapClient getSoapClient( )

Gets the SOAP client used to make PayPal SOAP calls

If the client doesn't exist, it is created and stored in the protected property PaymentPayPal_SOAP::$soapClient.


[ Top ]

getSoapHeaders   [line 582]

SoapHeader getSoapHeaders( )

Gets the SOAP headers required for PayPal authentication

If the header doesn't exist, it is created and stored in the protected property PaymentPayPal_SOAP::$soapHeader.

This header is passed to all PayPal SOAP calls.


[ Top ]

getWsdlFile   [line 805]

string getWsdlFile( )

Gets the WSDL file to use when building the SOAP object
  • Return: the WSDL file to use when building the SOAP object.
  • Access: protected

[ Top ]

setCertificateFile   [line 754]

Payment_PayPal_SOAP setCertificateFile( string $certificateFile)

Sets the local certificate file used for certificate-based authentication

This file is downloaded from your API credentials page when logged into your PayPal account.


Parameters:

string   $certificateFile     the local certificate file used for certificate-based authentication.

[ Top ]

setMode   [line 781]

Payment_PayPal_SOAP setMode( string $mode)

Sets the mode to use for API calls
  • Return: the current object, for fluent interface.
  • See: Payment_PayPal_SOAP::__construct()
  • Throws: Payment_PayPal_SOAP_InvalidModeException if an invalid mode is specified.
  • Access: protected

Parameters:

string   $mode     the mode to use for PayPal API calls. Valid modes are:
  • sandbox - for development and testing
  • live - for live payments.

[ Top ]

setPassword   [line 683]

Payment_PayPal_SOAP setPassword( string $password)

Sets the API password used for authentication

Parameters:

string   $password     the API password used for authentication.

[ Top ]

setSignature   [line 703]

Payment_PayPal_SOAP setSignature( string $signature)

Sets the API signature used for signature-based authentication

Parameters:

string   $signature     the API signature used for signature-based authentication.

[ Top ]

setSoapClient   [line 645]

Payment_PayPal_SOAP setSoapClient( $client)

Sets a SOAP client to use for SOAP requests

This is useful for testing.

  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

SoapClient   $client     the SOAP client to use.

[ Top ]

setSubject   [line 730]

Payment_PayPal_SOAP setSubject( string $subject)

Sets the subject used for making requests on behalf of a third-party

For example, you may be running a marketplace where customers will purchase goods directlry from your clients through your market. In this case, you can use the client's PayPal email address as the subject to initiate a checkout for the customer in your marketplace.


Parameters:

string   $subject     the email address of the third-party. Your API username may require explicit access be granted from the third-party before certain API actions will work.

[ Top ]

setUsername   [line 664]

Payment_PayPal_SOAP setUsername( string $username)

Sets the API username used for authentication

Parameters:

string   $username     the API username used for authentication.

[ Top ]


Documentation generated on Tue, 25 Sep 2012 14:30:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.