Payum / PayumBundle

Payum offers everything you need to work with payments. From simplest use cases to very advanced ones.
https://payum.gitbook.io/payum
MIT License
569 stars 142 forks source link

Request Capture{model: Identity} is not supported #372

Closed samanmohamadi closed 8 years ago

samanmohamadi commented 8 years ago

I'am getting this error when redirecting to capture.

Request Capture{model: Identity} is not supported. Make sure the storage extension for "AppBundle\Entity\Payment" is registered to the gateway. Make sure the storage find method returns an instance by id "290". 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. 

Do I have to add storage extension explicitly as mentioned here ?
According to doc it must add the storage extension automatically, Am I right?

My Payum Config :

payum:
    gateways:
        foo:
            factory: foo
            merchant_id: XXX

    security:
        token_storage:
            AppBundle\Entity\PaymentSecurityToken: { doctrine: orm }
    storages:
        AppBundle\Entity\Payment: { doctrine: orm }
        AppBundle\Entity\PaymentDetails: { doctrine: orm }
makasim commented 8 years ago

Can you try to run payum:gateway-debug cli command and see what is there.

makasim commented 8 years ago

Why did you added Payment and PaymentDetails, Are you sure you need both?

samanmohamadi commented 8 years ago

]$ php bin/console payum:gateway:debug

Order of actions, apis, extensions matters
Found 1 gateways
zarinpal (Payum\Core\Gateway):
    Actions:
    Payum\Core\Bridge\PlainPhp\Action\GetHttpRequestAction
    Payum\Core\Action\CapturePaymentAction
    Payum\Core\Action\AuthorizePaymentAction
    Payum\Core\Action\PayoutPayoutAction
    Payum\Core\Action\ExecuteSameRequestWithModelDetailsAction
    Payum\Core\Bridge\Twig\Action\RenderTemplateAction
    Payum\Core\Action\GetCurrencyAction
    AppBundle\Payum\Zarinpal\Action\CaptureAction
    AppBundle\Payum\Zarinpal\Action\AuthorizeAction
    AppBundle\Payum\Zarinpal\Action\RefundAction
    AppBundle\Payum\Zarinpal\Action\CancelAction
    AppBundle\Payum\Zarinpal\Action\NotifyAction
    AppBundle\Payum\Zarinpal\Action\StatusAction
    AppBundle\Payum\Zarinpal\Action\ConvertPaymentAction

    Extensions:
    Payum\Core\Extension\EndlessCycleDetectorExtension

    Apis:
    Payum\Core\Bridge\Httplug\HttplugClient
    AppBundle\Payum\Zarinpal\Api
samanmohamadi commented 8 years ago

PaymentDetails was for testing. I didn't use it anywhere in the code.

makasim commented 8 years ago

for some reason the storage extension was not registered.

makasim commented 8 years ago

You are using the old version, could you try to upgrade to the latest one. I am completely sure the bug was fixed there.

samanmohamadi commented 8 years ago

I'm using the latest version (v 2.1.0). ]$ composer show | grep payum

payum/core                           1.3.6              Payum offers everything you need to work with payments. From simplest use cases to very a...
payum/iso4217                        1.0.0              ISO 4217 PHP Library
payum/payum-bundle                   2.1.0              Rich payment solutions for symfony2. Paypal, payex, authorize.net, be2bill, omnipay, recu...
tomaszkowalczyk94 commented 8 years ago

I have the same problem.

makasim commented 8 years ago

I've run a few tests in the sandbox on the latest version of payum/core payum/payum-bundle. Everything works just fine. So the problem could be related to a custom gateway use. Could you post your factory: foo foo factory here?

makasim commented 8 years ago

and the way you register it to payum?

samanmohamadi commented 8 years ago
namespace AppBundle\Payum\Zarinpal;

use AppBundle\Payum\Zarinpal\Action\AuthorizeAction;
use AppBundle\Payum\Zarinpal\Action\CancelAction;
use AppBundle\Payum\Zarinpal\Action\CaptureAction;
use AppBundle\Payum\Zarinpal\Action\ConvertPaymentAction;
use AppBundle\Payum\Zarinpal\Action\NotifyAction;
use AppBundle\Payum\Zarinpal\Action\RefundAction;
use AppBundle\Payum\Zarinpal\Action\StatusAction;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;

class ZarinpalGatewayFactory extends GatewayFactory
{
    /**
     * {@inheritDoc}
     */
    protected function populateConfig(ArrayObject $config)
    {
        $config->defaults([
            'payum.factory_name' => 'zarinpal',
            'payum.factory_title' => 'zarinpal',
            'payum.action.capture' => new CaptureAction(),
            'payum.action.authorize' => new AuthorizeAction(),
            'payum.action.refund' => new RefundAction(),
            'payum.action.cancel' => new CancelAction(),
            'payum.action.notify' => new NotifyAction(),
            'payum.action.status' => new StatusAction(),
            'payum.action.convert_payment' => new ConvertPaymentAction(),
        ]);

        if (false == $config['payum.api']) {
            $config->defaults($config['payum.default_options']);
            $config['payum.required_options'] = array('merchant_id');

            $config['payum.api'] = function (ArrayObject $config) {
                $config->validateNotEmpty($config['payum.required_options']);

                return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']);
            };
        }
    }
}
services:
    payum.zarinpal_gateway_factory:
        class: AppBundle\Payum\Zarinpal\ZarinpalGatewayFactory
        tags:
            - { name: payum.gateway_factory, factory: zarinpal }
makasim commented 8 years ago

you are not using the core factory from the bundle but create your own, hence it knows nothing about storages and so on. So please use a builder:

services:
    payum.zarinpal_gateway_factory:
        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [AppBundle\Payum\Zarinpal\ZarinpalGatewayFactory]
        tags:
            - { name: payum.gateway_factory_builder, factory: zarinpal }
yurguis commented 5 years ago

I know this is old but just wanted to let you know I had the same problem and found the solution in this last post. Maybe it would be a good idea to add this to the documentation as I couldn't figured it out by reading it.

you are not using the core factory from the bundle but create your own, hence it knows nothing about storages and so on. So please use a builder:

services:
    payum.zarinpal_gateway_factory:
        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [AppBundle\Payum\Zarinpal\ZarinpalGatewayFactory]
        tags:
            - { name: payum.gateway_factory_builder, factory: zarinpal }

I know this is old but just wanted to let you know I had the same problem and found the solution in this last post. Maybe it would be a good idea to add this to the documentation as I couldn't figured it out by reading it.