Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with repeat of payments #19

Open
filipfonal opened this issue Feb 20, 2019 · 2 comments
Open

Problem with repeat of payments #19

filipfonal opened this issue Feb 20, 2019 · 2 comments

Comments

@filipfonal
Copy link

I have a problem with payments. If I've been redirect to PayU and left this page (for example closing browser tab) and then try repeat payment in user panel I get error 500 with this message:

ERROR_ORDER_NOT_UNIQUE - Order with given extOrderId already exists

Has anyone had this problem or knows how to fix it?

@filipfonal filipfonal changed the title Problem with repetition of payments Problem with repeat of payments Feb 20, 2019
@wobokas
Copy link

wobokas commented May 21, 2019

I have exactly the same problem

@mikemix
Copy link

mikemix commented Oct 7, 2019

@bitbager ?

In the ConvertPaymentAction class, line 43:

$details['extOrderId'] = uniqid((string) $payment->getNumber(), true);

Should be unique instead, not deterministic as above:

$details['extOrderId'] = uniqid(md5(mt_rand(0, 1000000)), true);

Because PayU's order != Sylius payment id

To everybody, to fix this you have to decorate this service and remove this unnecessary extOrderId key:

<?php

declare(strict_types=1);

namespace App\Payment\PayU;

use BitBag\SyliusPayUPlugin\Action\ConvertPaymentAction;
use Payum\Core\Action\ActionInterface;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Convert;

final class ConvertPaymentActionDecorator implements ActionInterface, GatewayAwareInterface
{
    use GatewayAwareTrait;

    private $action;

    public function __construct(ConvertPaymentAction $action)
    {
        $this->action = $action;
    }

    /**
     * @param Convert $request
     */
    public function execute($request): void
    {
        $this->action->execute($request);

        $details = $request->getResult();

        unset($details['extOrderId']);

        $request->setResult($details);
    }

    public function supports($request): bool
    {
        return $this->action->supports($request);
    }
}

and register this as a service to decorate the original action:

App\Payment\PayU\ConvertPaymentActionDecorator:
    decorates: bitbag.payu_plugin.action.convert_payment
    arguments: ['@App\Payment\PayU\ConvertPaymentActionDecorator.inner']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants