Note: Where payum/xxx is a payum package, for example it could be payum/paypal-express-checkout-nvp. Look at supported gateways to find out what you can use.
Note: Use payum/payum if you want to install all gateways at once.
Now you have all codes prepared and ready to be used.
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:
...publicfunctionregister(){$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.phpnamespaceApp\Http\Controllers; // the path of the controllerusePayum\LaravelPackage\Controller\PayumController;classPaypalControllerextendsPayumController{publicfunctionprepareExpressCheckout() { $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()); }}
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 dedicated chapter about how the payment done controller may look like.
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: