commerce cetelem for drupal 9.5

Created on 13 June 2023, over 1 year ago
Updated 27 July 2023, over 1 year ago

Hello everyone,

I'm currently working on a new module for Drupal 9 that integrates with Cetelem payment service. I have completed the module, but I'm facing a small issue.

The problem occurs after a customer completes the purchase process and makes the payment successfully through Cetelem. Once the payment is processed by Cetelem, the customer is redirected back to the website. However, in some cases, the order is not properly placed and remains in the cart instead.

I'm seeking assistance or suggestions on how to resolve this issue and ensure that orders are properly placed after the payment is successfully processed through Cetelem.

Here is my OnReturn i try to create the order there but doesnt work like i expected.

public function onReturn(OrderInterface $order, Request $request) {
    $payment_storage = $this->entityTypeManager->getStorage('commerce_payment');
    $payment = $payment_storage->create([
      'state' => 'Pendiente',
      'amount' => $order->getTotalPrice(),
      'payment_gateway' => $this->parentEntity->id(),
      'order_id' => $order->id(),
    ]);
      $state_transitions = $order->getState()->getTransitions();
      if (isset($state_transitions['place'])) {
        $order->getState()->applyTransition($state_transitions['place']);
      }

      $payment->setState('Pendiente');
      $order->save();

    $payment->save();

    $url = Url::fromRoute('commerce_checkout.form', ['commerce_order' => $order->id(), 'step' => 'complete']);
    $response = new Response('', 302);
    $response->headers->set('Location', $url->toString());
    return $response;
  }

Here is the GitHub repository

https://github.com/ProdigiaProgramacion/commerce-payment-cetelem

Thank you for your attention and any help you can provide.

Update: I get this error in the log:
Ruta: /checkout/231063/payment/return. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: en Drupal\Core\Routing\AccessAwareRouter->checkAccess() (lรญnea 121 de /home/mitortug/public_html/d9.mitortuga/docroot/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

๐Ÿ’ฌ Support request
Status

Active

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain prodigia Malaga

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024