PHP Classes

Angell EYE PayPal Payments Pro and Adaptive Payments Library: Process Web site payments using Paypal API

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (478)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (3 days ago) RSS 2.0 feedStarStarStarStar 62%Total: 1,761 This week: 2All time: 2,227 This week: 204Up
Version License PHP version Categories
angell-eye-paypal 1.13GNU General Publi...5.0PHP 5, E-Commerce, Web services
Description 

Author

This package can process Web site payments using Paypal API.

There are several classes that can handle payments by sending HTTP request to Paypal Web services servers of APIs PayPal Payments Pro, Adaptive Payments, and the PayFlow Pro Gateway.

The package classes can send the requests to the different API functions and return the results in arrays.

Innovation Award
PHP Programming Innovation award nominee
November 2011
Number 4


Prize: One downloadable e-book of choice by O'Reilly
Paypal Adaptive payments allow that the money of payment be split among multiple sellers involved in the sale of each product.

This class provides means to communicate with Paypal API in order to make it easier to implement adaptive payments in any PHP e-commerce Web site.

Manuel Lemos
Picture of Andrew Angell
Name: Andrew Angell <contact>
Classes: 2 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 1x

 

Recommendations

What is the best PHP payment api class?
need payment api can work with transaction

Example

<?php
require_once('../../includes/config.php');
require_once(
'../../autoload.php');

$PayPalConfig = array(
                   
'Sandbox' => $sandbox,
                   
'APIUsername' => $api_username,
                   
'APIPassword' => $api_password,
                   
'APISignature' => $api_signature,
                   
'PrintHeaders' => $print_headers,
                   
'LogResults' => $log_results,
                   
'LogPath' => $log_path,
                    );

$PayPal = new angelleye\PayPal\PayPal($PayPalConfig);

/*
 * Here we call GetExpressCheckoutDetails to obtain payer information from PayPal
 */
$GECDResult = $PayPal -> GetExpressCheckoutDetails($_SESSION['SetExpressCheckoutResult']['TOKEN']);
echo
'<b>GetExpressCheckoutDetails</b><br /><pre>';
print_r($GECDResult);
echo
'<br /><br /></pre>';

$DECPFields = array(
                   
'token' => $_SESSION['SetExpressCheckoutResult']['TOKEN'], // Required. A timestamped token, the value of which was returned by a previous SetExpressCheckout call.
                   
'payerid' => $GECDResult['PAYERID'], // Required. Unique PayPal customer id of the payer. Returned by GetExpressCheckoutDetails, or if you used SKIPDETAILS it's returned in the URL back to your RETURNURL.
                   
'returnfmfdetails' => '1', // Flag to indicate whether you want the results returned by Fraud Management Filters or not. 1 or 0.
                   
'giftmessage' => '', // The gift message entered by the buyer on the PayPal Review page. 150 char max.
                   
'giftreceiptenable' => '', // Pass true if a gift receipt was selected by the buyer on the PayPal Review page. Otherwise pass false.
                   
'giftwrapname' => '', // The gift wrap name only if the gift option on the PayPal Review page was selected by the buyer.
                   
'giftwrapamount' => '', // The amount only if the gift option on the PayPal Review page was selected by the buyer.
                   
'buyermarketingemail' => '', // The buyer email address opted in by the buyer on the PayPal Review page.
                   
'surveyquestion' => '', // The survey question on the PayPal Review page. 50 char max.
                   
'surveychoiceselected' => '', // The survey response selected by the buyer on the PayPal Review page. 15 char max.
                   
'allowedpaymentmethod' => '', // The payment method type. Specify the value InstantPaymentOnly.
                   
'buttonsource' => '' // ID code for use by third-party apps to identify transactions in PayPal.
               
);
                       
$Payments = array();
$Payment = array(
               
'amt' => '100.00', // Required. The total cost of the transaction to the customer. If shipping cost and tax charges are known, include them in this value. If not, this value should be the current sub-total of the order.
               
'currencycode' => 'USD', // A three-character currency code. Default is USD.
               
'itemamt' => '80.00', // Required if you specify itemized L_AMT fields. Sum of cost of all items in this order.
               
'shippingamt' => '15.00', // Total shipping costs for this order. If you specify SHIPPINGAMT you mut also specify a value for ITEMAMT.
               
'insuranceoptionoffered' => '', // If true, the insurance drop-down on the PayPal review page displays the string 'Yes' and the insurance amount. If true, the total shipping insurance for this order must be a positive number.
               
'handlingamt' => '', // Total handling costs for this order. If you specify HANDLINGAMT you mut also specify a value for ITEMAMT.
               
'taxamt' => '5.00', // Required if you specify itemized L_TAXAMT fields. Sum of all tax items in this order.
               
'desc' => 'This is a test order.', // Description of items on the order. 127 char max.
               
'custom' => '', // Free-form field for your own use. 256 char max.
               
'invnum' => '', // Your own invoice or tracking number. 127 char max.
               
'notifyurl' => '', // URL for receiving Instant Payment Notifications
               
'shiptoname' => '', // Required if shipping is included. Person's name associated with this address. 32 char max.
               
'shiptostreet' => '', // Required if shipping is included. First street address. 100 char max.
               
'shiptostreet2' => '', // Second street address. 100 char max.
               
'shiptocity' => '', // Required if shipping is included. Name of city. 40 char max.
               
'shiptostate' => '', // Required if shipping is included. Name of state or province. 40 char max.
               
'shiptozip' => '', // Required if shipping is included. Postal code of shipping address. 20 char max.
               
'shiptocountry' => '', // Required if shipping is included. Country code of shipping address. 2 char max.
               
'shiptophonenum' => '', // Phone number for shipping address. 20 char max.
               
'notetext' => 'This is a test note before ever having left the web site.', // Note to the merchant. 255 char max.
               
'allowedpaymentmethod' => '', // The payment method type. Specify the value InstantPaymentOnly.
               
'paymentaction' => 'Sale', // How you want to obtain the payment. When implementing parallel payments, this field is required and must be set to Order.
               
'paymentrequestid' => '', // A unique identifier of the specific payment request, which is required for parallel payments.
               
'sellerpaypalaccountid' => '' // A unique identifier for the merchant. For parallel payments, this field is required and must contain the Payer ID or the email address of the merchant.
               
);
               
$PaymentOrderItems = array();
$Item = array(
           
'name' => 'Widget 123', // Item name. 127 char max.
           
'desc' => 'Widget 123', // Item description. 127 char max.
           
'amt' => '40.00', // Cost of item.
           
'number' => '123', // Item number. 127 char max.
           
'qty' => '1', // Item qty on order. Any positive integer.
           
'taxamt' => '', // Item sales tax
           
'itemurl' => 'http://www.angelleye.com/products/123.php', // URL for the item.
           
'itemweightvalue' => '', // The weight value of the item.
           
'itemweightunit' => '', // The weight unit of the item.
           
'itemheightvalue' => '', // The height value of the item.
           
'itemheightunit' => '', // The height unit of the item.
           
'itemwidthvalue' => '', // The width value of the item.
           
'itemwidthunit' => '', // The width unit of the item.
           
'itemlengthvalue' => '', // The length value of the item.
           
'itemlengthunit' => '', // The length unit of the item.
           
'ebayitemnumber' => '', // Auction item number.
           
'ebayitemauctiontxnid' => '', // Auction transaction ID number.
           
'ebayitemorderid' => '', // Auction order ID number.
           
'ebayitemcartid' => '' // The unique identifier provided by eBay for this order from the buyer. These parameters must be ordered sequentially beginning with 0 (for example L_EBAYITEMCARTID0, L_EBAYITEMCARTID1). Character length: 255 single-byte characters
           
);
array_push($PaymentOrderItems, $Item);

$Item = array(
           
'name' => 'Widget 456', // Item name. 127 char max.
           
'desc' => 'Widget 456', // Item description. 127 char max.
           
'amt' => '40.00', // Cost of item.
           
'number' => '456', // Item number. 127 char max.
           
'qty' => '1', // Item qty on order. Any positive integer.
           
'taxamt' => '', // Item sales tax
           
'itemurl' => 'http://www.angelleye.com/products/456.php', // URL for the item.
           
'itemweightvalue' => '', // The weight value of the item.
           
'itemweightunit' => '', // The weight unit of the item.
           
'itemheightvalue' => '', // The height value of the item.
           
'itemheightunit' => '', // The height unit of the item.
           
'itemwidthvalue' => '', // The width value of the item.
           
'itemwidthunit' => '', // The width unit of the item.
           
'itemlengthvalue' => '', // The length value of the item.
           
'itemlengthunit' => '', // The length unit of the item.
           
'ebayitemnumber' => '', // Auction item number.
           
'ebayitemauctiontxnid' => '', // Auction transaction ID number.
           
'ebayitemorderid' => '', // Auction order ID number.
           
'ebayitemcartid' => '' // The unique identifier provided by eBay for this order from the buyer. These parameters must be ordered sequentially beginning with 0 (for example L_EBAYITEMCARTID0, L_EBAYITEMCARTID1). Character length: 255 single-byte characters
           
);
array_push($PaymentOrderItems, $Item);

$Payment['order_items'] = $PaymentOrderItems;
array_push($Payments, $Payment);

$UserSelectedOptions = array(
                            
'shippingcalculationmode' => '', // Describes how the options that were presented to the user were determined. values are: API - Callback or API - Flatrate.
                            
'insuranceoptionselected' => '', // The Yes/No option that you chose for insurance.
                            
'shippingoptionisdefault' => '', // Is true if the buyer chose the default shipping option.
                            
'shippingoptionamount' => '', // The shipping amount that was chosen by the buyer.
                            
'shippingoptionname' => '', // Is true if the buyer chose the default shipping option...?? Maybe this is supposed to show the name..??
                            
);

$PayPalRequest = array(
                      
'DECPFields' => $DECPFields,
                      
'Payments' => $Payments
                      
);

$_SESSION['PayPalResult'] = $PayPal -> DoExpressCheckoutPayment($PayPalRequest);

echo
'<pre />';
print_r($_SESSION['PayPalResult']);


Details

Angell EYE PayPal PHP Library

This PHP class library for PayPal makes it easy to integrate PayPal APIs, including the PayPal REST APIs and Classic APIs like the Payments Standard Button Manager, Invoicing, General Merchant APIs, and Permissions.

Server Requirements

  • PHP version 5.3.0 or newer.
  • cURL

Installation

Video Overview

<a href="http://www.youtube.com/watch?feature=player_embedded&v=f9wi8m7_FDc" target="_blank"> <img src="http://img.youtube.com/vi/f9wi8m7_FDc/0.jpg" alt="Install via Composer or Manual Download Overview Video" width="240" height="180" border="10" /></a>

Composer Install

Create a composer.json file with the following section and run composer update.

    "require": {
		"php": ">=5.3.0",
		"ext-curl": "*",
		"angelleye/paypal-php-library": "3.0.*"
	}

Manual Install (without Composer)

  • Download the class library and extract the contents do a directory in your project structure.
  • Upload the files to your web server.

Setup

Open /samples/config/config-sample.php, fill out your details accordingly, and save-as config.php to a location of your choice.

To use the library in your project, include the following into your file(s).

  • /path/to/config.php
  • autoload.php

Usage

  • Open the template file that corresponds to the API call you'd like to make. * Example: If we want to make a call to the RefundTransaction API we open up /templates/RefundTransaction.php
  • You may leave the file here, or save this file to the location on your web server where you'd like this call to be made. * I like to save the files to a separate location and keep the ones included with the library as empty templates. * Note that you can also copy/paste the template code into your own file(s).
  • Each template file prepares the PayPal class object for you and includes PHP arrays for every parameter available to that particular API. Simply fill in the array parameters with your own dynamic (or static) data. This data may come from: * Session Variables * General Variables * Database Recordsets * Static Values * Etc.
  • When you run the file you will get a $PayPalResult array that consists of all the response parameters from PayPal, original request parameters sent to PayPal, and raw request/response info for troubleshooting. * You may refer to the PayPal Developer Documentation for details about what response parameters you can expect to get back from any successful API request. + Example: When working with RefundTransaction, I can see that PayPal will return a REFUNDTRANSACTIONID, FEEREFUNDAMT, etc. As such, I know that those values will be included in $PayPalResult['REFUNDTRANSACTIONID'] and $PayPalResult['FEEREFUNDAMT'] respectively.
  • If errors occur they will be available in $PayPalResult['ERRORS']

You may refer to this overview video of how to use the library, and there are also samples provided in the /samples directory as well as blank templates ready to use under /templates.

If you need additional help you may place an order for premium support.

Fully Functional Demos

The library comes with basic usage samples, but if you feel more comfortable seeing the integration inside a fully functional demo that is built into a basic shopping cart system, take a look at our demo kits available on our website.

You can find our FREE demos inside /demo directory. If you have purchased any demo then you just need to add those inside demo directory and its ready to go.

Tutorials

Supported APIs

REST APIs

Payments Standard Button Manager

Button Manager

Invoicing

Merchant

Permissions

PayPal Manager (PayFlow Gateway)

Financing Banners

  • FinancingBannerEnrollment

Deprecated

  • DoMobileCheckoutPayment
  • GetAccessPermissionsDetails
  • GetAuthDetails
  • SetAccessPermissions
  • SetAuthFlowParam
  • SetMobileCheckout
  • UpdateAccessPermissions
  • Adaptive Accounts
  • Adaptive Payments

Resources


Screenshots  
  • paypal-php-class-library-get-balance-code-sample.jpg
  Files folder image Files  
File Role Description
Files folder imagedemo (2 files, 3 directories)
Files folder imagedocumentation (1 file)
Files folder imagesamples (5 directories)
Files folder imagesrc (1 directory)
Files folder imagetemplates (2 directories)
Plain text file autoload.php Aux. Auxiliary script
Plain text file CHANGELOG.md Data Auxiliary data
Plain text file composer.json Data Auxiliary data
Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 99%
Total:1,761
This week:2
All time:2,227
This week:204Up
User Ratings User Comments (2)
 All time
Utility:83%StarStarStarStarStar
Consistency:66%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:1110