githubEdit

Get started

Payum Bundle

Install

The preferred way to install the library is using composerarrow-up-right. Run composer require to add dependencies to composer.json:

php composer.phar require "payum/payum-bundle" "payum/offline" "php-http/guzzle7-adapter"
circle-info

Note: Where payum/offline is a payum gateway, you can for example change it to payum/paypal-express-checkout-nvp or payum/stripe. Look at supported gateways to find out what you can use.

circle-info

Note: Use payum/payum if you want to install all gateways at once.

When using Symfony Flex, the bundle should automatically be added to the bundle config.

If that did not happen, or if you are not using Symfony Flex, then enable the bundle in the config

<?php
// config/bundles.php

return [
    Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
];

Now let's import Payum's routes:

# config/routes.yml

payum_all:
    resource: "@PayumBundle/Resources/config/routing/all.xml"

Configure

First we need two entities: Token and Payment. The token entity is used to protect your payments, while the payment entity stores all your payment information.

Note: In this chapter we show how to use Doctrine ORMarrow-up-right entities. There are other supported storages.

Next, you have to add mapping information, and configure payum's storages:

Note: You can add other gateways to the gateways key too.

Create payment and redirect the user

Now we can create a payment:

Payment is done

After setting up the payment, the user will be redirected to doneAction(). You can read more about it in its dedicated chapter. doneAction() is always called, no matter if the payment was successful or not. Here we may check the payment status, update the model, dispatch events and so on.


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