Error in Omnipay/Stripe

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
DNK
Posts: 21
Joined: 27 Feb 2025, 10:50

Error in Omnipay/Stripe

Post by DNK » 31 Mar 2025, 14:13

I got error in your extension:
Image

Code: Select all

{
  "error": {
    "message": "This PaymentIntent is configured to accept payment methods enabled in your Dashboard. Because some of these payment methods might redirect your customer off of your page, you must provide a `return_url`. If you don't want to accept redirect-based payment methods, set `automatic_payment_methods[enabled]` to `true` and `automatic_payment_methods[allow_redirects]` to `never` when creating Setup Intents and Payment Intents.",
    "payment_intent": {
      "id": "pi_XXXXXXXX",
      "object": "payment_intent",
      "amount": 100,
      "amount_capturable": 0,
      "amount_details": {
        "tip": {
        }
      },
      "amount_received": 0,
      "application": null,
      "application_fee_amount": null,
      "automatic_payment_methods": {
        "allow_redirects": "always",
        "enabled": true
      },
      "canceled_at": null,
      "cancellation_reason": null,
      "capture_method": "automatic",
      "client_secret": "pi_3R**********************_******_*********************DlD2",
      "confirmation_method": "manual",
      "created": 1743016046,
      "currency": "eur",
      "customer": "cus_S11LPwqx9vnxI6",
      "description": "Order 60",
      "invoice": null,
      "last_payment_error": null,
      "latest_charge": null,
      "livemode": true,
      "metadata": {
      },
      "next_action": null,
      "on_behalf_of": null,
      "payment_method": "pm_XXXXXX",
      "payment_method_configuration_details": {
        "id": "pmc_XXXXXXXX",
        "parent": null
      },
      "payment_method_options": {
        "card": {
          "installments": null,
          "mandate_options": null,
          "network": null,
          "request_three_d_secure": "automatic"
        },
        "link": {
          "persistent_token": null
        }
      },
      "payment_method_types": [
        "card",
        "link"
      ],
      "processing": null,
      "receipt_email": null,
      "review": null,
      "setup_future_usage": "off_session",
      "shipping": null,
      "source": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "requires_confirmation",
      "transfer_data": null,
      "transfer_group": "ORDER-60"
    },
    "request_log_url": "https://dashboard.stripe.com/logs/req_XXXXXXX?t=1743016091",
    "type": "invalid_request_error"
  }
}
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS

User avatar
DNK
Posts: 21
Joined: 27 Feb 2025, 10:50

Re: Error in Omnipay/Stripe

Post by DNK » 01 Apr 2025, 16:12

As an addendum. When entering the card number and after clicking the "Pay now" button, I am redirected to the bank page, where I have to confirm the payment. After I have confirmed, I am redirected back to my Aimeos store, but with an error
Image

However, when I pay with another card, I am not redirected anywhere.
Therefore, I want to report a critical error in your application! And I urgently ask for help!

The error is related to the fact that you have not set up payments with redirection!

For testing this scenario use these test cards - https://docs.stripe.com/testing#3d-secu ... enge-flows
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS

User avatar
DNK
Posts: 21
Joined: 27 Feb 2025, 10:50

Re: Error in Omnipay/Stripe

Post by DNK » 02 Apr 2025, 06:38

I received a response from Stripe about this error.
Hi there,
Upon reviewing the logs, I noticed that the Payment Intent was initially created with confirm: true in the request req_knv3MUhtnrKWA7 [0]. This automatically confirmed the Payment Intent and moved its status to requires_action. In such cases, the next step would be to use stripe.handleNextAction [1] to manage any additional actions required, such as 3D Secure authentication.

Could you share why you attempted to confirm the Payment Intent again in req_QLRNHIiGAiss3d [2]. When reconfirming a Payment Intent, it's necessary to submit both a new payment method and a return URL. This could explain why you're receiving an error about the missing return_url.

To resolve this issue, you have two options:

If you intended to create and confirm the Payment Intent in one step, simply use stripe.handleNextAction [1] after the initial creation with confirm: true.
If you need to confirm the Payment Intent separately, ensure you're providing both a new payment method and a return URL in the confirmation request.
Their response suggests that your omnipay/stripe plugin is not configured correctly. Please advise where I need to adjust the code!
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Error in Omnipay/Stripe

Post by aimeos » 02 Apr 2025, 09:09

Guess, the problem is related to the "createtoken: yes" option in your Stripe configuration in the Setup > Services panel of the admin backend. Can you check if the problem vanishes if you change it to "no"?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
DNK
Posts: 21
Joined: 27 Feb 2025, 10:50

Re: Error in Omnipay/Stripe

Post by DNK » 02 Apr 2025, 09:25

No, it didn't solve the problem.

I found a solution. When confirming a payment, your plugin makes a request without specifying the return_url. This is a mandatory parameter.

It needs to be added after this line in this file
https://github.com/aimeoscom/ai-payment ... e.php#L238

As soon as I forked your plugin and added the line there

Code: Select all

$response = $this->getProvider()->confirm( [
'paymentIntentReference' => $this->getOrderData( $order, 'Reference' ),
'return_url' => config('app.url') . '/shop/confirm/stripe',
] )->send();
Then the payment was immediately successful!

By the way, https://github.com/thephpleague/omnipay-stripe says that return_url is required:
Image
Aimeos 2024.10.3 + Laravel 11, PHP 8.2, MySql8.0, Nginx, Ubuntu 22.04.5 LTS

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Error in Omnipay/Stripe

Post by aimeos » 04 Apr 2025, 16:07

Great! Can you make a pull request so we can merge your fix into the ai-payments extension?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Error in Omnipay/Stripe

Post by aimeos » 08 Apr 2025, 10:30

The return URL has been added to the Stripe payment service provider now.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

donnnnar
Posts: 6
Joined: 02 Apr 2025, 11:20

Re: Error in Omnipay/Stripe

Post by donnnnar » 16 Apr 2025, 06:57

Hi,

We're encountering another issue with the return_url parameter. On the Checkout-Confirm page (action=confirm&code=stripe&controller=Checkout), the return_url is empty, which leads to an error. According to DNK, the return_url must be set for Stripe.

Steps to reproduce:

- Place an order and proceed to the checkout payment page
- Enter credit card information
- Complete the payment successfully via Stripe
- After redirection, land on the confirmation page
- The confirmation page calls our custom checkout confirm decorator
- The custom decorator executes $this->client()->init(); on the first line
- That line triggers Stripe->updateSync(), where the config value for the payment success URL is empty
- It seems there should be a default value for the payment success URL, or it should never be empty to begin with.

Relevant code:
File: vendor/aimeos/ai-payments/src/MShop/Service/Provider/Payment/Stripe.php (starting at line 237)

Code: Select all

// @todo: $default variable must be set 
$response = $this->getProvider()->confirm( [
    'paymentIntentReference' => $this->getOrderData( $order, 'Reference' ),
    'return_url' => $this->getConfigValue( ['payment.url-success'], $default )
] )->send();
Best regards,
Steve


Edit:
I changed the example

Code: Select all

    'return_url' => $this->getConfigValue( 'payment.url-success', $default )
to

Code: Select all

    'return_url' => $this->getConfigValue( ['payment.url-success'], $default )
Last edited by donnnnar on 16 Apr 2025, 08:48, edited 1 time in total.

User avatar
aimeos
Administrator
Posts: 8616
Joined: 01 Jan 1970, 00:00

Re: Error in Omnipay/Stripe

Post by aimeos » 16 Apr 2025, 07:26

donnnnar wrote: 16 Apr 2025, 06:57 File: vendor/aimeos/ai-payments/src/MShop/Service/Provider/Payment/Stripe.php (starting at line 237)

Code: Select all

// @todo: $default variable must be set 
$response = $this->getProvider()->confirm( [
    'paymentIntentReference' => $this->getOrderData( $order, 'Reference' ),
    'return_url' => $this->getConfigValue( 'payment.url-success', $default )
] )->send();
Does it work if you replace "payment.url-success" by "payment.url-self"?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

donnnnar
Posts: 6
Joined: 02 Apr 2025, 11:20

Re: Error in Omnipay/Stripe

Post by donnnnar » 16 Apr 2025, 07:57

No,

Code: Select all

$this->getConfigValue( ['payment.url-self'] )
also returns null.

Post Reply