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.
}
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: