Package Data | |
---|---|
Maintainer Username: | haveacigaro |
Maintainer Contact: | alan@alanmonger.co.uk (Alan Monger) |
Package Create Date: | 2015-06-17 |
Package Last Update: | 2016-08-23 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-26 15:10:35 |
Package Statistics | |
---|---|
Total Downloads: | 710 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This repo contains a set of commands which allow you to use Laravels command bus to take payments through paypal express (with more to come).
Initially you're going to have to find your api details, which you can find under your profile page on paypal.
You'll need to add these to your .env file
PAYPAL_USERNAME=username
PAYPAL_PASSWORD=password
PAYPAL_SIGNATURE=signature
#PAYPAL_TEST_MODE=true # Be sure to use this if accessing a sandbox!
You'll then need to add the gateway service provider to your app.php. This binds the provider to the GatewayInterface.
'providers' => [
...
PaymentCommands\Paypal\Providers\GatewayServiceProvider::class
],
After this has been added, you're good to go! Just fire the command bus in your controller for handling the payment. This will return the redirect url, which you can then redirect to.
public function index()
{
$cancelUrl = url('/cancel');
$returnUrl = url('/capture');
$currency = 'GBP';
$items = [
[
'price' => 200,
'description' => 'A bike',
'quantity' => 1
]
];
$redirectUrl = $this->dispatch(new MakePayment($items, $currency, $cancelUrl, $returnUrl));
return redirect($redirectUrl);
}
After the payment has been completed, you redirect the user back to your website.
public function capture()
{
$this->dispatch(new CapturePayment(Input::get('token'), Input::get('payerID')));
}
Each stage of the command bus fires an event which you can hook into.
You can read about how to implement this by looking at the Event Documentation