Source for file paypal_types.php
Documentation is available at paypal_types.php
* Preparation of WebService DataTypes
* Copyright (C) 2007 Israel Ekpo
* Contains the class which has methods that generates a list of datatypes (arrays) used by the webs service.
* Most of the datatypes are passed to the SoapClient->__soapCall() method as multi-dimensional arrays.
* @author Israel Ekpo <israelekpo@sourceforge.net>
* @copyright Copyright 2007, Israel Ekpo
* @license http://phppaypalpro.sourceforge.net/LICENSE.txt BSD License
* This class contains the list of all the Data Types used when contacting the Paypal webservice
* @author Israel Ekpo <israelekpo@sourceforge.net>
* @copyright Copyright 2007, Israel Ekpo
* @license http://phppaypalpro.sourceforge.net/LICENSE.txt BSD License
* Formats the Amount according to the BasicAmountType
* This method creates a classical example of an element that has an attribute.
* For example <element attribute1='attr1' attribute2='attr2'>value</element>
* will be created as array('_' => 'value', 'attr1' => 'attribute1', 'attr2' => 'attribute2');
* @param string $currencyID
* @usedby PaypalTypes::PaymentDetailsType()
* @usedby PaypalTypes::PaymentDetailsItemType()
* @return BasicAmountType
static public function BasicAmountType($amount =
'0.00', $currencyID =
'USD')
$BasicAmountType['currencyID'] =
$currencyID;
* Prepares the AddressType
* This method is used to generate the AddressType for Payment information.
* @param string $CityName
* @param string $StateOrProvince
* @param string $PostalCode
static public function AddressType($Name =
'', $Street1 =
'', $Street2 =
'', $CityName =
'', $StateOrProvince =
'', $PostalCode =
'', $Country =
'', $Phone =
'')
$AddressType['Name'] =
$Name;
$AddressType['Street1'] =
$Street1;
$AddressType['Street2'] =
$Street2;
$AddressType['CityName'] =
$CityName;
$AddressType['StateOrProvince'] =
$StateOrProvince;
$AddressType['Country'] =
$Country;
$AddressType['PostalCode'] =
$PostalCode;
$AddressType['Phone'] =
$Phone;
* Prepares the PersonNameType
* The person name type is used to format the name information for onward inclusion in the SOAP message.
* @param string $Salutation
* @param string $FirstName
* @param string $MiddleName
* @param string $LastName
static public function PersonNameType($Salutation =
'', $FirstName =
'', $MiddleName =
'', $LastName =
'', $Suffix =
'')
$PersonNameType['Salutation'] =
$Salutation;
$PersonNameType['FirstName'] =
$FirstName;
$PersonNameType['MiddleName'] =
$MiddleName;
$PersonNameType['LastName'] =
$LastName;
$PersonNameType['Suffix'] =
$Suffix;
* Prepares the PayerInfoType
* The PayerInfoType uses the AddressType and PersonNameType to generate a multi-dimensional array
* that will in turn be used as part of a SOAP message.
* @param EmailAddressType $Payer e.g buyer@gmail.com
* @param string $PayerStatus verified, unverified
* @param PersonNameType $PayerName
* @param string $PayerCountry
* @param string $PayerBusiness
* @param AddressType $Address
* @param string $ContactPhone
static public function PayerInfoType($Payer =
'', $PayerID =
'', $PayerStatus =
'verified', $PayerName, $PayerCountry=
'US', $PayerBusiness =
'', $Address, $ContactPhone =
'')
$PayerInfoType['Payer'] =
$Payer;
$PayerInfoType['PayerID'] =
$PayerID;
$PayerInfoType['PayerStatus'] =
$PayerStatus;
$PayerInfoType['PayerName'] =
$PayerName;
$PayerInfoType['PayerCountry'] =
$PayerCountry;
$PayerInfoType['PayerBusiness'] =
$PayerBusiness;
$PayerInfoType['Address'] =
$Address;
$PayerInfoType['ContactPhone'] =
$ContactPhone;
* Makes the CreditCardDetailsType
* This is a very essential data type because it has to be formatted correctly. This method is used to
* generate an array that is going to be part of the payment details submitted to paypal.
* @param string $CreditCardType Visa,MasterCard,Amex,Discover,Solo,Switch
* @param string $CreditCardNumber
* @param PayerInfoType $CardOwner
* @return CreditCardDetailsType
static public function CreditCardDetailsType($CreditCardType, $CreditCardNumber, $ExpMonth, $ExpYear, $CardOwner, $CVV2 =
'')
$CreditCardDetailsType['CreditCardType'] =
$CreditCardType;
$CreditCardDetailsType['CreditCardNumber'] =
$CreditCardNumber;
$CreditCardDetailsType['ExpMonth'] =
$ExpMonth;
$CreditCardDetailsType['ExpYear'] =
$ExpYear;
$CreditCardDetailsType['CardOwner'] =
$CardOwner;
$CreditCardDetailsType['CVV2'] =
$CVV2;
return $CreditCardDetailsType;
* Makes PaymentDetailsItemType
* This generates details about a particular payment item. An array is returned which contains the name, quantity
* and amound of each item added to the payment.
* @param integer $Quantity
* @param BasicAmountType $Tax
* @param BasicAmountType $Amount
* @param string $CurrencyID
* @return PaymentDetailsItemType
static public function PaymentDetailsItemType($Name =
'', $Number =
'', $Quantity =
1, $Tax =
'', $Amount =
'', $CurrencyID =
'USD')
$PaymentDetailsItemType['Name'] =
$Name;
$PaymentDetailsItemType['Number'] =
$Number;
$PaymentDetailsItemType['Quantity'] =
$Quantity;
$PaymentDetailsItemType['Tax'] =
self::BasicAmountType($Tax, $CurrencyID);
$PaymentDetailsItemType['Amount'] =
self::BasicAmountType($Amount, $CurrencyID);
return $PaymentDetailsItemType;
* Creates the PaymentDetailsType
* This is a critical part of the DoDirectPayment and DoExpressCheckOutPayment operations.
* The payment details is an overall summary of the payment to be sent to the paypal web service.
* @param BasicAmountType $OrderTotal
* @param BasicAmountType $ItemTotal
* @param BasicAmountType $ShippingTotal
* @param BasicAmountType $HandlingTotal
* @param BasicAmountType $TaxTotal
* @param string $OrderDescription
* @param string $InvoiceID
* @param string $ButtonSource
* @param string $NotifyURL Paypal IPN URL
* @param AddressType $ShipToAddress
* @param PaymentDetailsItemType $PaymentDetailsItem
* @param string $CurrencyID
* @return PaymentDetailsType
static public function PaymentDetailsType($OrderTotal, $ItemTotal =
'0.00', $ShippingTotal =
'0.00', $HandlingTotal =
'0.00', $TaxTotal =
'0.00', $OrderDescription =
'', $Custom =
'', $InvoiceID =
'', $ButtonSource =
'', $NotifyURL =
'', $ShipToAddress =
'', $PaymentDetailsItem =
array(), $CurrencyID=
'USD')
$PaymentDetailsType['OrderTotal'] =
self::BasicAmountType($OrderTotal, $CurrencyID);
$PaymentDetailsType['ItemTotal'] =
self::BasicAmountType($ItemTotal, $CurrencyID);
$PaymentDetailsType['ShippingTotal'] =
self::BasicAmountType($ShippingTotal, $CurrencyID);
$PaymentDetailsType['HandlingTotal'] =
self::BasicAmountType($HandlingTotal, $CurrencyID);
$PaymentDetailsType['TaxTotal'] =
self::BasicAmountType($TaxTotal, $CurrencyID);
$PaymentDetailsType['OrderDescription'] =
$OrderDescription;
$PaymentDetailsType['Custom'] =
$Custom;
$PaymentDetailsType['InvoiceID'] =
$InvoiceID;
$PaymentDetailsType['ButtonSource'] =
$ButtonSource;
$PaymentDetailsType['NotifyURL'] =
$NotifyURL;
$PaymentDetailsType['ShipToAddress'] =
$ShipToAddress;
$PaymentDetailsType['PaymentDetailsItem'] =
$PaymentDetailsItem;
return $PaymentDetailsType;
* Prepares the DoDirectPaymentRequestDetailsType
* This basically returns a multi-dimensional array with the Payment Action. Credit Card information, User IP
* address and the merchant's session id.
* @param string $PaymentAction This could be a Sale or Order.
* @param PaymentDetailsType $PaymentDetails
* @param CreditCardDetailsType $CreditCard
* @param string $IPAddress
* @param string $MerchantSessionId
* @return DoDirectPaymentRequestDetailsType
$DoDirectPaymentRequestDetailsType['PaymentAction'] =
$PaymentAction;
$DoDirectPaymentRequestDetailsType['PaymentDetails'] =
$PaymentDetails;
$DoDirectPaymentRequestDetailsType['CreditCard'] =
$CreditCard;
$DoDirectPaymentRequestDetailsType['IPAddress'] =
$IPAddress;
$DoDirectPaymentRequestDetailsType['MerchantSessionId'] =
$MerchantSessionId;
return $DoDirectPaymentRequestDetailsType;
* Prepares the SetExpressCheckoutRequestDetailsType
* This is an array with the Amount, Return URL, Cancellation URL and Payment Action (Sale or Order)
* @param BasicAmountType $OrderTotal
* @param string $ReturnURL
* @param string $CancelURL
* @param string $PaymentAction Sale or Order
* @return SetExpressCheckoutRequestDetailsType
$SetExpressCheckoutRequestDetailsType['OrderTotal'] =
self::BasicAmountType($OrderTotal, $currencyID);
$SetExpressCheckoutRequestDetailsType['ReturnURL'] =
$ReturnURL;
$SetExpressCheckoutRequestDetailsType['CancelURL'] =
$CancelURL;
$SetExpressCheckoutRequestDetailsType['PaymentAction'] =
$PaymentAction;
return $SetExpressCheckoutRequestDetailsType;
* Makes the DoExpressCheckoutPaymentRequestDetailsType
* This returns the Payment action, Token value, Payer ID and Payment details as a multi-dimensional array.
* @param string $PaymentAction Order or Sale
* @param PaymentDetailsType $PaymentDetails
* @return DoExpressCheckoutPaymentRequestDetailsType
$DoExpressCheckoutPaymentRequestDetailsType['PaymentAction'] =
$PaymentAction;
$DoExpressCheckoutPaymentRequestDetailsType['Token'] =
$Token;
$DoExpressCheckoutPaymentRequestDetailsType['PayerID'] =
$PayerID;
$DoExpressCheckoutPaymentRequestDetailsType['PaymentDetails'] =
$PaymentDetails;
return $DoExpressCheckoutPaymentRequestDetailsType;
* Makes the UserIdPasswordType
* This prepares the authentication message to be passed to paypal. It is an array
* with the Username, Password and Signature of the user. If the payment is being made on behalf of
* another account then the username of that account has to be passed as the subject.
* @param string $Username
* @param string $Password
* @param string $Signature
* @return UserIdPasswordType
static public function UserIdPasswordType($Username =
'', $Password =
'', $Signature =
'', $Subject=
'')
$UserIdPasswordType['Username'] =
$Username;
$UserIdPasswordType['Password'] =
$Password;
$UserIdPasswordType['Signature'] =
$Signature;
$UserIdPasswordType['Subject'] =
$Subject;
return $UserIdPasswordType;
* Returns the date in the ISO 8601 format
* Generates the ISO 8601 format using the UNIX timestamp supplied. Like 2007-02-02T01:36:06-05:00
* which is basically the year, month, day, 24-hour format, minutes, seconds and time zone like -05:00 for EST
* @param integer $timeStamp the Unix Timestamp
$timeStamp = (int)
$timeStamp;
return date('c', $timeStamp);
* Generates the TransactionSearchRequestType
* Prepares a multi-dimensional array to be used in the search.
* @uses self::dateTimeType
* @param integer $StartDate UNIXTIMESTAMP
* @param intefer $EndDate UNIXTIMESTAMP
* @param string $PayerEmail
* @param string $ReceiverEmail
* @param string $ReceiptID
* @param string $TransactionID
* @param string $PayerName
* @param string $AuctionItemNumber
* @param string $InvoiceID
* @param string $CardNumber
* @param string $TransactionClass
* @param BasicAmountType $Amount
* @param string $CurrencyCode
* @return TransactionSearchRequestType
static public function TransactionSearchRequestType($StartDate, $EndDate =
0, $PayerEmail =
'', $ReceiverEmail =
'', $ReceiptID =
'', $TransactionID =
'', $PayerName =
'', $AuctionItemNumber =
'', $InvoiceID =
'', $CardNumber =
'', $TransactionClass =
'', $Amount =
'', $CurrencyCode =
'', $Status =
'', $currencyID =
'USD')
$TransactionSearchRequestType['StartDate'] =
self::dateTimeType($StartDate);
$TransactionSearchRequestType['EndDate'] =
self::dateTimeType($EndDate);
$TransactionSearchRequestType['Payer'] =
$PayerEmail;
$TransactionSearchRequestType['Receiver'] =
$ReceiverEmail;
$TransactionSearchRequestType['ReceiptID'] =
$ReceiptID;
$TransactionSearchRequestType['TransactionID'] =
$TransactionID;
$TransactionSearchRequestType['PayerName'] =
$PayerName;
$TransactionSearchRequestType['AuctionItemNumber'] =
$AuctionItemNumber;
$TransactionSearchRequestType['InvoiceID'] =
$InvoiceID;
$TransactionSearchRequestType['CardNumber'] =
$CardNumber;
$TransactionSearchRequestType['TransactionClass'] =
$TransactionClass;
$TransactionSearchRequestType['Amount'] =
self::BasicAmountType($Amount, $currencyID);
$TransactionSearchRequestType['CurrencyCode'] =
$CurrencyCode;
$TransactionSearchRequestType['Status'] =
$Status;
return $TransactionSearchRequestType;
Documentation generated on Sat, 03 Feb 2007 20:59:05 -0800 by phpDocumentor 1.3.1