This library provides developers with a simple set of bindings to help you integrate PayPal Standard to a website and start receiving payments.
php >= 8.1
guzzlehttp/guzzle >= 7.0.1
echosistema/simple-http-request" >= 1.0.1
📢 Coming soon package to PHP versions < 8.1
.
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!
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();
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();
use EwertonDaniel\PayPal\Order;
$order_id = $_POST['token'];
$detail = $order->setOrderId($order_id)->detail();