Setup

Installation

Install with composer:

composer require jms/payment-core-bundle

And register the bundle in your AppKernel.php:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
    );
}

Configuration

The configuration is as simple as setting an encryption key which will be used for encrypting data. You can generate a random key with the following command:

bin/console jms_payment_core:generate-key

And then use it in your configuration:

# app/config/config.yml
jms_payment_core:
    encryption:
        secret: output_of_above_command

Warning

If you change the secret or the crypto provider, all encrypted data will become unreadable.

Create database tables

This bundle requires a few database tables, which you can create as follows.

If you’re not using database migrations:

bin/console doctrine:schema:update

Or, if you’re using migrations:

bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate

Note

It’s assumed you have entity auto mapping enabled, which is usually the case. If you don’t, you need to either enable it:

# app/config/config.yml
doctrine:
    orm:
        auto_mapping: true

Or explicitly register the configuration from this bundle:

# app/config/config.yml
doctrine:
    orm:
        mappings:
            JMSPaymentCoreBundle: ~

Configure a payment backend

In addition to setting up this bundle, you will also need to install a plugin for each payment backend you intend to support. Plugins are simply bundles you add to your application, as you would with any other Symfony bundle.

Tip

See Available payment backends for the list of existing plugins.

Using the Paypal plugin as an example, you would install it with composer:

composer require jms/payment-paypal-bundle

Register it in your AppKernel.php:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
        new JMS\Payment\PaypalBundle\JMSPaymentPaypalBundle(),
    );
}

And configure it:

# app/config/config.yml

jms_payment_paypal:
    username: your api username
    password: your api password
    signature: your api signature

Note

Other plugins will require different configuration. Take a look at their documentation for complete instructions.

Next steps

If you have no prior experience with this bundle or payment processing in general, you should follow the Accepting payments guide. Otherwise, proceed to the Payment form chapter.