l9cgv
l9cgv

Reputation: 178

Symfony Payum Bundle: Storage Extension for "Proxies\__CG__\App\Entity\Payment" is registered to the gateway

for many hours I am searching for a solution for following bug:

I want to perform a payment with a gateway (stripe and paypal + offline for testing) but everytime I want to open the capture link I get following exception:

Request Capture{model: Identity} is not supported. Make sure the storage extension for "Proxies_CG_\App\Entity\Payment" is registered to the gateway. Make sure the storage find method returns an instance by id "1". Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker.

I have following configuration:

Relevant snippets:

payum.yaml

payum:
    storages:
        App\Entity\Payment: { doctrine: orm }

    security:
        token_storage:
            App\Entity\PaymentToken: { doctrine: orm }

    gateways: [...]

Entity\Payment

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Payment as BasePayment;

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

Entity\PaymentToken

<?php

namespace App\Entity;

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

/**
 * @ORM\Table
 * @ORM\Entity
 */
class PaymentToken extends Token
{

}

doctrine.yaml (config/packages)

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        #server_version: '5.7'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
        dql:
            numeric_functions:
                Rand: App\DQL\RandFunction

Snippet to create the payment

$storage = $this->payum->getStorage('App\Entity\Payment');

$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('EUR');
$payment->setDescription('[...]');
$payment->setClientId($user->getId());
$payment->setClientEmail($user->getEmail());

$storage->update($payment);

$captureToken = $this->payum->getTokenFactory()->createCaptureToken(
    'offline',
    $payment,
    'index'
);

and by Opening the capture URL ($capureToken->getTargetURL()) I get the exception from above. I tried different solutions from other stackoverflow-posts like clearing the cache, warmup with no-dev and other methods but nothing worked. I followed the (in some cases horrible) documentation of payum and the bundle many times with exact the same snippets but without any results.

I just hope that someone here can help me, otherwise I'm kinda screwed up.

Thank you!

Upvotes: 1

Views: 353

Answers (1)

l9cgv
l9cgv

Reputation: 178

okay it seems like there was a problem with a relation to the payment entity. I had another entity which had an many-to-one relation with the payment entity. By removing it and acting the payment entity without any relations it worked just fine...

Upvotes: 0

Related Questions