Get started
Here we describe basic steps required by all supported gateways. We are going to setup models, storages, a security layer and so on. All that stuff will be used later.
Install
The preferred way to install the library is using composer. Run composer require to add dependencies to composer.json:
php composer.phar require payum/offline php-http/guzzle7-adapterBefore we configure payum, let's look at the flow diagram. This flow is same for all gateways so once you familiar with it any other gateways could be added easily.
As you can see we have to create some php files: config.php, prepare.php, capture.php and done.php. At the end you will have the complete solution and it would be much easier to add other gateways. Let's start from the config.php and continue with rest after:
config.php
Here we can put our gateways, storages. Also we can configure security components. The config.php has to be included to all left files.
Note: There are other storages available. Such as Doctrine ORM\MongoODM.
Note: Consider using something other than FilesystemStorage in production.
prepare.php
At this stage we have to create an order. Add some information into it. Create a capture token and delegate the job to capture.php script. Here's an offline gateway example:
Note: There are examples for all supported gateways.
capture.php
When the preparation is done a user is redirect to capture.php. Here's an example of this file. You can just copy\past the code. It has to work for all gateways without any modification from your side.
Note: Find out more about capture script in the dedicated chapter.
done.php
After the capture did its job you will be redirected to done.php. The capture.php script always redirects you to done.php no matter the payment was a success or not. In done.php we may check the payment status, update the model, dispatch events and so on.
Note: Find out more about done script in the dedicated chapter.
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:
Last updated