Payum
Source🩷 Sponsor
  • Payum docs
  • Get started
  • Instant payment notification
  • ISO4217 or Currency Details
  • The Architecture
  • Your order integration
  • Supported Gateways
  • Storages
  • Debugging
  • Logging
  • Event Dispatcher
  • Configure gateways in backend
  • Working with sensitive information
  • Encrypt gateway configs stored in database
  • Mask credit card number
  • Develop a custom Payum gateway
  • Troubleshooting
  • Frameworks and e-commerce integration.
  • Payum vs Omnipay
  • How to contribute from sub repository
  • Examples
    • Paypal: Create Gateway
    • Paypal: Redirects
    • Handle redirect
    • Get Status
    • Stripe Js: Create gateway
    • Capture Payment
    • Get Http Reponse
    • Capture Credit Card
    • Authorise script
    • Capture Script
    • Done Script
    • index
    • Notify script
    • Payout Script
    • Refund script
  • Authorize-NET
    • AIM
      • Authorize.Net AIM: Get started
  • Be2Bill
    • Be2Bill Direct
    • Be2Bill Offsite
  • jms-payment-bridge
    • Get Started
  • Klarna
    • Checkout
      • Klarna Checkout: Get Started
    • Invoice
      • Klarna Invoice: Get Started
  • Laravel
    • Get Started
    • Blade Templating
    • Eloquent Storage
    • Payment done controller
    • Store gateway config in database
    • Examples
  • Offline
    • Get Started
  • Payex
    • Get Started
  • Paypal
    • Express Checkout
      • Get Started
      • Authorize order
      • Authorize token custom query parameters
      • Cancel recurring payment
      • Confirm order step
      • Recurring Payments Basics
    • IPN
      • Get Started
    • Masspay
      • Get Started
    • Pro Checkout
      • Get Started
    • Pro Hosted
      • Get Started
    • REST
      • Get Started
      • Credit Card Purchase
  • Silex
    • Get Started
    • Payment Done Controller
  • Sofort
    • Get Started
    • Disable Notifications
  • Stripe
    • Checkout
    • Direct
    • Stripe.js
    • Raw Capture
    • Store card and use later
    • Subscription Billing
  • Symfony
    • Get started
    • Authorize Payment
    • Configure payment in backend
    • Console commands
    • Container tags
    • Custom Action
    • Custom API usage
    • Creating custom view for payment page
    • Custom purchase examples
    • Debugging
    • Encrypt gateway configs stored in database
    • ISO4217 or Currency Details
    • Purchase done action
    • Refund Payment
    • Sandbox
    • Storages
    • Configuration Reference
    • Custom Purchase Examples
      • Authorize.NET AIM
      • Be2Bill onsite
      • Be2Bill Credit Card
      • Klarna Checkout
      • Klarna Invoice
      • Payex
      • Paypal Express Checkout
      • Paypal Pro Checkout
      • Paypal via Omnipay
      • Stripe checkout
      • Stripe.js
      • Stripe via Omnipay
Powered by GitBook
On this page
  • Doctrine ORM
  • Custom.
  • Filesystem.
  • Supporting Payum
Edit on GitHub
  1. Symfony

Storages

Doctrine ORM

Add token and payment details classes:

<?php
namespace Acme\PaymentBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Token;

/**
 * @ORM\Table
 * @ORM\Entity
 */
class PaymentToken extends Token
{
}
<?php
namespace Acme\PaymentBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\ArrayObject;

/**
 * @ORM\Table
 * @ORM\Entity
 */
class PaymentDetails extends ArrayObject
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     *
     * @var integer $id
     */
    protected $id;
}

next, you have to add mapping of the basic entities you are extended, and configure payum's storages:

# app/config/config.yml

payum:
    security:
        token_storage:
            Acme\PaymentBundle\Entity\PaymentToken: { doctrine: orm }

    storages:
        Acme\PaymentBundle\Entity\PaymentDetails: { doctrine: orm }

Doctrine MongoODM.

Token use custom mongo type called ObjectType, so you have to add it to the kernel boot method:

<?php
// app\AppKernel.php

use Doctrine\ODM\MongoDB\Types\Type;

class AppKernel extends Kernel
{
    public function boot()
    {
        Type::addType('object', 'Payum\Core\Bridge\Doctrine\Types\ObjectType');

        parent::boot();
    }

Now, add token and payment details classes:

<?php
namespace Acme\PaymentBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as Mongo;
use Payum\Core\Model\Token;

/**
 * @Mongo\Document
 */
class PaymentToken extends Token
{
}
<?php
namespace Acme\PaymentBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as Mongo;
use Payum\Core\Model\ArrayObject;

/**
 * @Mongo\Document
 */
class PaymentDetails extends ArrayObject
{
    /**
     * @Mongo\Id
     *
     * @var integer $id
     */
    protected $id;
}

next, you have to add mapping of the basic entities you are extended, and configure payum's storages:

# app/config/config.yml

doctrine_mongodb:
    document_managers:
        default:
            auto_mapping: true

            mappings:
                payum:
                    is_bundle: false
                    type: xml
                    dir: %kernel.root_dir%/../vendor/payum/core/Payum/Core/Bridge/Doctrine/Resources/mapping

                    # set this dir instead if you use `payum/payum` library
                    #dir: %kernel.root_dir%/../vendor/payum/payum/src/Payum/Core/Bridge/Doctrine/Resources/mapping

                    prefix: Payum\Core\Model

payum:
    security:
        token_storage:
            Acme\PaymentBundle\Entity\PaymentToken: { doctrine: mongodb }

    storages:
        Acme\PaymentBundle\Entity\PaymentDetails: { doctrine: mongodb }

Note: You should use commented path if you install payum/payum package.

Custom.

We have several built in storages which cover all your needs. Sometimes you need completely custom storage. To have a custom storage you have to implement StorageInterface from core:

<?php
namespace Acme\PaymentBundle\Payum\Storage;

use Payum\Core\Storage\StorageInterface;

class CustomStorage implements StorageInterface
{
  // implement interface methods.
}

Register it as a service:

# app/config/config.yml

services:
    acme.payment.payum.storage.custom:
        class: Acme\PaymentBundle\Payum\Storage\CustomStorage

When you are done you can use it like this:

# app/config/config.yml

payum:
    storages:
        Acme\PaymentBundle\Model\Foo:
            custom: acme.payment.payum.storage.custom

Filesystem.

Attention: Use filesystem storage only for testing and never in production.

Add token and payment details classes:

<?php
namespace Acme\PaymentBundle\Model;

use Payum\Core\Model\Token;

class PaymentToken extends Token
{
}
<?php
namespace Acme\PaymentBundle\Model;

use Payum\Core\Model\ArrayObject;

class PaymentDetails extends ArrayObject
{
    protected $id;
}

next, you have to configure payum's storages:

# app/config/config.yml

payum:
    security:
        token_storage:
            Acme\PaymentBundle\Model\PaymentToken:
                filesystem:
                    storage_dir: %kernel.root_dir%/Resources/payments
                    id_property: hash
                    
    storages:
        Acme\PaymentBundle\Model\PaymentDetails:
            filesystem:
                storage_dir: %kernel.root_dir%/Resources/payments
                id_property: id

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:

PreviousSandboxNextConfiguration Reference

Last updated 1 year ago

Become a sponsor