Configure builder. You are free to use other builder's methods.
In Laravel 4, add the following to bootstrap/start.php or other place where you can use App::resolving method.
App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
// this method registers filesystem storages, consider to change them to something more
// sophisticated, like eloquent storage
->addDefaultStorages()
->addGateway('paypal_ec', [
'factory' => 'paypal_express_checkout',
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
])
;
});
In Laravel 5, create new service provider or add to the default app/Providers/AppServiceProvider.php register method:
...
public function register()
{
$this->app->resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
// this method registers filesystem storages, consider to change them to something more
// sophisticated, like eloquent storage
->addDefaultStorages()
->addGateway('paypal_ec', [
'factory' => 'paypal_express_checkout',
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
]);
});
}
...
Prepare payment
Lets create a controller where we prepare the payment details.
<?php
// app/controllers/PaypalController.php
namespace App\Http\Controllers; // the path of the controller
use Payum\LaravelPackage\Controller\PayumController;
class PaypalController extends PayumController
{
public function prepareExpressCheckout()
{
$storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
$details = $storage->create();
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = 1.23;
$storage->update($details);
$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('paypal_ec', $details, 'payment_done');
return \Redirect::to($captureToken->getTargetUrl());
}
}
Supporting Payum
Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:
Here's you may want to modify a payment_done route. It is a controller where the payer will be redirected after the payment is done, whenever it is success failed or pending. Read a about how the payment done controller may look like.