Troubleshooting Klarna and Webhook Integration Issues with 8.x-1.2 Module

Created on 2 December 2024, 17 days ago

Problem/Motivation

I recently installed the commerce_stripe-8.x-1.2 module update, which introduces support for Klarna and webhook functionality. However, these features are not functioning as expected.

The goal is to determine whether additional steps are required to enable Klarna and to resolve webhook signature validation issues.

Steps to reproduce

  1. Configure Klarna in the Stripe dashboard (both test and production).
  2. Enable the Klarna payment method in Stripe.
  3. Set up a webhook endpoint in the Stripe dashboard with the URL and events listed in the module documentation.
  4. Enter the "Webhook signing secret" in the module settings on Drupal.
  5. Attempt a test transaction using the staging site.

Proposed resolution

  • Verify if additional configuration is required on Drupal for Klarna integration.
  • Confirm the correct configuration of webhook signing secrets and resolve the "No signatures found matching the expected signature for payload" error.

Remaining tasks

  • Document any additional Klarna setup steps if required.
  • Ensure the webhook functionality works seamlessly for all supported events.

User interface changes

No expected UI changes. The Klarna payment option should become available in the checkout process.

API changes

No API changes expected beyond the standard module behavior.

Data model changes

No data model changes expected.

Observations

  • Klarna: The payment method does not appear during checkout.
  • Webhook: Stripe reports an HTTP 500 error for the payment_intent.succeeded event, stating "No signatures found matching the expected signature for payload."

Questions

  1. Does the Klarna setup require additional steps on Drupal or Stripe?
  2. Is there any known mismatch in webhook signing logic for this module version?
  3. Are there additional checks or logs I can enable to better diagnose these issues?

Thank you for your support!

💬 Support request
Status

Active

Version

1.2

Component

Miscellaneous

Created by

🇮🇹Italy AleDDR

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

  • Issue created by @AleDDR
  • 🇺🇸United States TomTech

    Hi @aleddr,

    There are a variety of reasons why the Klarna payment method is not showing up.

    Reviewing Stripe's Klarna documentation may be helpful. See: https://docs.stripe.com/payments/klarna

    Some possibilities:

    • The customer address is not in a supported country. Check the current list at the link referenced above.
    • The currency is not supported. Check the current list at the link referenced above.
    • The amount of the order is below the Klarna minimum. This can change, so hesitant to specify a number in this thread, but if you are doing a $1 test transaction, you won't get it as a payment option. I would suggest $100 for a test amount.
    • The Payment Gateway is configured for "Setup Future Usage" with a value of "On-session" or "Off-session". These values allow you to "re-use" the payment method. Since Klarna is essentially a micro-loan, approved on a case by case basis, you normally would need to set the value to "Single use". Stripe and Klarna, though, do have the intention of allowing recurring payments, based on the link above, offering a "Private Preview Sign Up" option. For now, only "Single use" has been tested supported, though the other values may be supported with Klarna in the future.

    IRT the webhook signing secret, ensure that you also are in "Test Mode" in stripe when creating the webhook. You don't want to send webhooks from prod to your test environment. Also, I'm presuming you are using the URL provided when you configured your payment gateway, but the pattern you mentioned does not look right. It should be https://[your site domain]/payment/notify/[your payment gateway machine name], e.g. https://www.example.com/payment/notify/my_stripe_gateway

  • 🇩🇪Germany Anybody Porta Westfalica

    Thank you so much @tomtech! We had similar issues and your comment gave the right anwser!
    I opened an issue to improve the UX: 🐛 Payment Element: Better use effect of the "Payment method usage" setting Active

  • 🇩🇪Germany Anybody Porta Westfalica

    Maybe the debug steps should be added to the README.md?

  • 🇺🇸United States TomTech

    @anybody,

    Glad these comments were helpful for you!

    We are working on additional documentation...it gets challenging, though, because stripe is churning a lot, and what is true today may not be true tomorrow.

    Case in point...when I was making the comment #4 above, I pulled up the link I referenced, and noticed the new "Private Preview" for recurring payments with Klarna. Previously, that value was "No".

  • 🇺🇸United States TomTech
  • 🇮🇹Italy AleDDR

    Hi @TomTech,
    I really appreciate your contribution and your availability, and I thank you very much.

    I still need to ask for support to better understand and resolve the issue.

    In the meantime, I confirm that I am testing in a Drupal development environment, on Stripe in Test Mode, and the sensitive data shared is anonymized but consistent.
    I have performed checks and tests based on your suggestions, and here are the results.

    Webhook events result in a 500 Internal Server Error

    Regarding "Webhook events result in a 500 Internal Server Error", which impacts all transactions, I have made progress by reconfiguring:

    • the WebHook on Stripe
    • the "Default Checkout flows" on Drupal, adding "Stripe review" in the Review stage, while leaving "Setup future usage" set to "None".

    I no longer get the error
    No signatures found matching the expected signature for payload...
    , but now I have this error: "Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::processWebHook(): Argument #1 ($webhook_event_id) must be of type int, null given, called in /var/opt/www/[your site domain]/releases/58/web/modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/StripePaymentElement.php on line 586.
    I have already read another issue ( #3420717 🐛 Webhook httpstatus 500 Fixed ), but I didn't quite understand what needs to be done to resolve it...
    I tried introducing "skip_return_failure": true, where should I insert it?
    Has the fix for #3420717 already been applied to commerce_stripe-8.x-1.2, or is it necessary to apply a workaround?
    - Here is the request sent by Stripe to the Webhook ( requestBodyAnonymized.tx t)

    Payment method: Klarna

    I reviewed the scenarios in Klarna's documentation without finding any issues (customer address, currency, order amount, ...)
    I believe the problem lies with the configuration of the "Setup Future Usage" option set to "Single use", because I can't find where or how to configure this option. In short, on the requires_payment_method request, the "Setup Future Usage" option remains set to "On-session", and that's why I don't see Klarna.
    Let me give you some information about the current configurations:

    Can you help me further with this?
    Thank you in advance!

  • 🇮🇹Italy AleDDR

    I found the solution, very simple.
    I'm really sorry, but I didn't realize that the latest version had not been installed due to an incompatibility with another module. I isolated the incompatibility and installed the latest version, everything works perfectly!

Production build 0.71.5 2024