1. Go to this page and download the library: Download 8ctopus/paypal-rest-api 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/ */
8ctopus / paypal-rest-api example snippets
use HttpSoft\Message\RequestFactory;
use HttpSoft\Message\StreamFactory;
use Nimbly\Shuttle\Shuttle;
use Oct8pus\PayPal\Orders;
use Oct8pus\PayPal\Orders\Intent;
use Oct8pus\PayPal\OAuth;
use Oct8pus\PayPal\HttpHandler;
tion token
$auth = new OAuth($sandbox, $handler, 'rest.id', 'rest.pass');
$orders = new Orders($sandbox, $handler, $auth);
// create order
$response = $orders->create(Intent::Capture, 'USD', 10.0);
// you must redirect the user to approve the payment before you can capture
$redirectUrl = "https://www.sandbox.paypal.com/checkoutnow?token={$response['id']}";
...
// once the user has approved the payment, capture it
$response = $orders->capture($args['id']);
if ($response['status'] === 'COMPLETED') {
echo 'payment processed!';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.