PHP code example of thecodingcompany / laravel-paypal-light

1. Go to this page and download the library: Download thecodingcompany/laravel-paypal-light library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thecodingcompany / laravel-paypal-light example snippets




use CodingCompany\PayPal\PayPalPayment as PayPalPayment;
use CodingCompany\PayPal\PayPalTransaction as PayPalTransaction;

$p = new PayPalPayment(array(
    'client_id'         => 'AddMFxCjj3QgJZT4kYgrgegbfdbgthre9Qj24o_P8Ldag7yeu2A',
    'client_secret'     => 'EFNXQgBjL9PQO0ZeuC5_4567547y6htet5ert34435_tct4nFU7g'
));

$p->set_endpoint("https://api.paypal.com");

$transaction = new PayPalTransaction();
$transaction->amount = array(
    "total" => "1.00",
    "currency" => "USD"
);
$transaction->description = "PayPal transaction";
$p->set_transaction($transaction);

$p->set_return_url("http://localhost:8000/paypal/callback");
$p->set_cancel_url("http://localhost:8000/paypal/cancel");

$response = $p->authorize_payment();



use CodingCompany\PayPal\PayPalPayment as PayPalPayment;
use CodingCompany\PayPal\PayPalTransaction as PayPalTransaction;

$p = new PayPalPayment(array(
    'client_id'         => 'AddMFxCjj3QgJZT4kYgrgegbfdbgthre9Qj24o_P8Ldag7yeu2A',
    'client_secret'     => 'EFNXQgBjL9PQO0ZeuC5_4567547y6htet5ert34435_tct4nFU7g'
));

$p->set_endpoint("https://api.paypal.com");

$response = $p->execute_payment(array(
    "paymentId" => "PAY-554",
    "token" => "EC-45645",
    "PayerID" => "455454"
));