-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
re-implement payum payment interface #2164
Conversation
Ok, I think there are more things to discuss, @dpfaffenbauer. Two ways: Way ICoreShop creates a valid
However, there is another issue if we're going to keep it that way. I'm using your unzer gateway to show you the problem:
My suggestion:
Way IIFinish this PR (re-implementing the payum interface) and remove the try/catch block where you're creating a dedicated payum model WDYT? |
@solverat here is what you can do with how CoreShop currently is designed:
So as was before. Then, in the Bundle, you create a final class ConvertCoreShopPaymentAction implements ActionInterface
{
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var CoreShopPaymentInterface $payment */
$payment = $request->getSource();
}
public function supports($request)
{
return
$request instanceof Convert &&
$request->getSource() instanceof CoreShopPaymentInterface &&
$request->getTo() == 'array';
}
} and add it as service: CoreShop\Payum\UnzerBundle\Action\ConvertCoreShopPaymentAction:
tags:
- { name: payum.action, alias: unzer_convert_action, factory: unzer, gateway: unzer, prepend: true } In there, you have complete Control over the CoreShop Order and can access anything and prepare data for the Payment Provider. |
Hey @dpfaffenbauer: "So as it was before": Almost. In CS2, the Payum Gateway also was able to manage the request source, because it was a real Payum Payment Interface. Within your proposal, the CoreShop bundle always needs to copy the content of the Gatway's https://github.com/search?l=PHP&q=%22class+ConvertPaymentAction%22&type=Code So I'm far away from accepting this as a solution. But I can't do more than suggest an alternative solution (personally, I would go with "Way II"). |
@solverat It's too late for that now, CoreShop 3.0 is out and thats the way it is now. |
BTW: One of our devs (@Zodiarc) has found a much cleaner solution (And keep the extension as it is): // ConvertPaymentExtension
$paymentEntity = $this->paymentRepository->createQueryBuilder('p')
->where('p.number = :orderNumber')
->setParameter('orderNumber', $payment->getNumber())
->getQuery()
->getSingleResult();
if (!$paymentEntity instanceof \Coreshop\Component\Core\Model\Payment) {
return;
}
$order = $paymentEntity->getOrder();
// ... append data to $request |
This PR re-implements the
\Payum\Core\Model\PaymentInterface
. Otherwise, the Payum Actions won't work anymore. Example:https://github.com/karser/PayumSaferpay/blob/master/Action/ConvertPaymentAction.php#L57