PHP Classes

How to Use a PHP Paypal Payment API to Process Order Payments using the Standard Paypal PHP SDK: Compose orders and process payments using Paypal

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 65 All time: 10,397 This week: 524Up
Version License PHP version Categories
standard-paypal-php- 1.0.0MIT/X Consortium ...5PHP 5, E-Commerce, Web services
Description 

Author

This package can compose orders and process payments using Paypal.

It provides a class library that can define an order with products, prices, and other details.

The package can process the order using the Paypal Standard API to charge a customer for the products being ordered.

Picture of Ewerton Daniel
  Performance   Level  

 

Documentation

Generic badge Generic badge Twitter

PayPal Standard PHP SDK

_This library provides developers with a simple set of bindings to help you integrate PayPal Standard to a website and start receiving payments._

? Requirements

php >= 8.1

guzzlehttp/guzzle >= 7.0.1

echosistema/simple-http-request" >= 1.0.1

? Coming soon package to PHP versions < 8.1.

? Installation

First time using PayPal? Create your PayPal account in PayPal, if you don?t have one already.

Download Composer if not already installed

On your project directory run on the command line "composer require ewertondaniel/paypal-standard-php-sdk" for PHP 8.1;

That's it! PayPal Standard PHP SDK has been successfully installed!

??? Examples

? Getting authorization


use EwertonDaniel\PayPal\Auth;

        $authentication = new Auth($client_id, $client_secret, $is_production);
        $authentication->getScopes();
        $authentication->getAccessToken();
        $authentication->getTokenType();
        $authentication->getAppId();
        $authentication->getExpiresIn();
        $authentication->getNonce();

? Create an Order


use EwertonDaniel\PayPal\Order;

        $order = new Order($authentication);
        
        //Set Purchase Unit
        $order->setPaypalRequestId()
            ->setIntent('CAPTURE')
            ->purchaseUnit()
            ->setCurrencyCode('BRL')
            ->addItemWithBasicData('Blacksaber Mandalore', 1, 29900) // string $name, int $quantity, int $value
            ->setReferenceId()
            ->setDescription('I can write up to one hundred and twenty seven characters as a description...');
            
        // Set Payment Source    
        $order->pushPurchaseUnit()
            ->paymentSource()
            ->paypal()
            ->experienceContext()
            ->setPaymentMethodPreference('IMMEDIATE_PAYMENT_REQUIRED')
            ->setBrandName('Bounty Hunters Guild (BHG)') // Company name
            ->setLocale('pt-BR')
            ->setLandingPage('LOGIN')
            ->setShippingPreference('NO_SHIPPING')
            ->setUserAction('PAY_NOW')
            ->setReturnUrl('https://example.com/returnUrl')
            ->setNotificationUrl('https://example.com/notifyUrl')
            ->setCancelUrl('https://example.com/cancelUrl');
            
        $response = $order->create();

? Order Details


use EwertonDaniel\PayPal\Order;
        $order_id = $_POST['token'];
        $detail = $order->setOrderId($order_id)->detail();

? Documentation

? Visit the PayPal for further information regarding:

PayPal REST APIs Documentation


  Files folder image Files (46)  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:65
This week:0
All time:10,397
This week:524Up