dolibarr 18.0.6
paypal.lib.php File Reference

Library for common paypal functions. More...

Go to the source code of this file.

Functions

 paypaladmin_prepare_head ()
 Define head array for tabs of paypal tools setup pages.
 
 print_paypal_redirect ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag)
 Send redirect to paypal to browser.
 
 callSetExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum, $email='', $desc='')
 
 getDetails ($token)
 Prepares the parameters for the GetExpressCheckoutDetails API Call.
 
 confirmPayment ($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
 Validate payment.
 
 hash_call ($methodName, $nvpStr)
 This function makes a DoDirectPayment API call.
 
 deformatNVP ($nvpstr)
 This function will take NVPString and convert it to an Associative Array and it will decode the response.
 
 getApiError ()
 Get API errors.
 

Detailed Description

Library for common paypal functions.

Definition in file paypal.lib.php.

Function Documentation

◆ callSetExpressCheckout()

callSetExpressCheckout ( $paymentAmount,
$currencyCodeType,
$paymentType,
$returnURL,
$cancelURL,
$tag,
$solutionType,
$landingPage,
$shipToName,
$shipToStreet,
$shipToCity,
$shipToState,
$shipToCountryCode,
$shipToZip,
$shipToStreet2,
$phoneNum,
$email = '',
$desc = '' )

Purpose: Prepares the parameters for the SetExpressCheckout API Call. Inputs: paymentAmount: Total value of the shopping cart currencyCodeType: Currency code value the PayPal API paymentType: paymentType has to be one of the following values: Sale or Order or Authorization returnURL: the page where buyers return to after they are done with the payment review on PayPal cancelURL: the page where buyers return to when they cancel the payment review on PayPal shipToName: the Ship to name entered on the merchant's site shipToStreet: the Ship to Street entered on the merchant's site shipToCity: the Ship to City entered on the merchant's site shipToState: the Ship to State entered on the merchant's site shipToCountryCode: the Code for Ship to Country entered on the merchant's site shipToZip: the Ship to ZipCode entered on the merchant's site shipToStreet2: the Ship to Street2 entered on the merchant's site phoneNum: the phoneNum entered on the merchant's site email: the buyer email desc: Product description See https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/

Parameters
double$paymentAmountPayment amount
string$currencyCodeTypeCurrency
string$paymentTypePayment type
string$returnURLReturn Url
string$cancelURLCancel Url
string$tagFull tag
string$solutionTypeType ('Mark' or 'Sole')
string$landingPageLanding page ('Login' or 'Billing')
string$shipToNameShip to name
string$shipToStreetShip to street
string$shipToCityShip to city
string$shipToStateShip to state
string$shipToCountryCodeShip to country code
string$shipToZipShip to zip
string$shipToStreet2Ship to street2
string$phoneNumPhone
string$emailEmail
string$descDescription
Returns
array Array

Definition at line 202 of file paypal.lib.php.

References getUserRemoteIP(), and hash_call().

Referenced by print_paypal_redirect().

◆ confirmPayment()

confirmPayment ( $token,
$paymentType,
$currencyCodeType,
$payerID,
$ipaddress,
$FinalPaymentAmt,
$tag )

Validate payment.

Parameters
string$tokenToken
string$paymentTypeType
string$currencyCodeTypeCurrency
string$payerIDPayer ID
string$ipaddressIP Address
string$FinalPaymentAmtAmount
string$tagFull tag
Returns
array

Definition at line 357 of file paypal.lib.php.

References hash_call().

◆ deformatNVP()

deformatNVP ( $nvpstr)

This function will take NVPString and convert it to an Associative Array and it will decode the response.

It is usefull to search for a particular key and displaying arrays.

Parameters
string$nvpstrNVPString
Returns
array nvpArray = Associative Array

Definition at line 576 of file paypal.lib.php.

Referenced by hash_call().

◆ getApiError()

getApiError ( )

Get API errors.

Returns
array Array of errors

Definition at line 602 of file paypal.lib.php.

◆ getDetails()

getDetails ( $token)

Prepares the parameters for the GetExpressCheckoutDetails API Call.

Parameters
string$tokenToken
Returns
array The NVP Collection object of the GetExpressCheckoutDetails Call Response.

Definition at line 308 of file paypal.lib.php.

References hash_call().

◆ hash_call()

hash_call ( $methodName,
$nvpStr )

This function makes a DoDirectPayment API call.

paymentType: paymentType has to be one of the following values: Sale or Order or Authorization paymentAmount: total value of the shopping cart currencyCode: currency code value the PayPal API firstName: first name as it appears on credit card lastName: last name as it appears on credit card street: buyer's street address line as it appears on credit card city: buyer's city state: buyer's state countryCode: buyer's country code zip: buyer's zip creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) creditCardNumber: buyers credit card number without any spaces, dashes or any other characters expDate: credit card expiration date cvv2: Card Verification Value

Returns
array The NVP Collection object of the DoDirectPayment Call Response. hash_call: Function to perform the API call to PayPal using API signature
Parameters
string$methodNameis name of API method.
string$nvpStris nvp string.
Returns
array returns an associtive array containing the response from the server.

Definition at line 451 of file paypal.lib.php.

References deformatNVP(), dol_syslog(), and GETPOST().

Referenced by callSetExpressCheckout(), confirmPayment(), and getDetails().

◆ paypaladmin_prepare_head()

paypaladmin_prepare_head ( )

Define head array for tabs of paypal tools setup pages.

Returns
Array of head

Definition at line 33 of file paypal.lib.php.

References complete_head_from_modules().

◆ print_paypal_redirect()

print_paypal_redirect ( $paymentAmount,
$currencyCodeType,
$paymentType,
$returnURL,
$cancelURL,
$tag )

Send redirect to paypal to browser.

Parameters
float$paymentAmountAmount
string$currencyCodeTypeCurrency code
string$paymentTypePayment type
string$returnURLUrl to use if payment is OK
string$cancelURLUrl to use if payment is KO
string$tagFull tag
Returns
string No return (a redirect is done) if OK, or Error message if KO

Definition at line 70 of file paypal.lib.php.

References callSetExpressCheckout(), and dol_syslog().