Skip to content

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

Notifications You must be signed in to change notification settings

EwertonDaniel/standard-paypal-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages