PHP code example of amsgames / laravel-shop-gateway-paypal
1. Go to this page and download the library: Download amsgames/laravel-shop-gateway-paypal 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/ */
amsgames / laravel-shop-gateway-paypal example snippets
/*
|--------------------------------------------------------------------------
| Redirect route after callback
|--------------------------------------------------------------------------
|
| Which route to call after the callback has been processed.
|
*/
'callback_redirect_route' => 'home',
// (1) - Set gateway
Shop::setGateway('paypalExpress');
// (2) - Call checkout / OPTIONAL
// You can call this to keep a standard flow
// Although this step for this gateway is not needed.
Shop::checkout();
// (3) - Create order
$order = Shop::placeOrder();
// (4) - Review order and redirect to payment
if ($order->isPending) {
// PayPal URL to redirect to proceed with payment
$approvalUrl = Shop::gateway()->getApprovalUrl();
// Redirect to url
return redirect($approvalUrl);
}
// (5) - Callback
// You don't have to do anything.
// Laravel Shop will handle the callback and redirect the customer to the configured route.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.