dolibarr 21.0.0-beta
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<string,string> Array

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

References $conf, getDolGlobalString(), 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<string,string>

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

References $conf, and 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 useful to search for a particular key and displaying arrays.

Parameters
string$nvpstrNVPString
Returns
array<string,string> nvpArray = Associative Array

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

Referenced by hash_call().

◆ getApiError()

getApiError ( )

Get API errors.

Returns
string[] Array of errors

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

◆ getDetails()

getDetails ( $token)

Prepares the parameters for the GetExpressCheckoutDetails API Call.

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

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

References $conf, and 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<string,string> 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<string,string> returns an associative array containing the response from the server.

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

References $conf, deformatNVP(), dol_syslog(), getDolGlobalString(), 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<array{0:string,1:string,2:string}> Array of tabs to show

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

References $conf, $object, and 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 71 of file paypal.lib.php.

References $conf, callSetExpressCheckout(), dol_syslog(), and getDolGlobalString().