Webhook httpstatus 500

Created on 11 February 2024, 4 months ago
Updated 15 March 2024, 3 months ago

Problem/Motivation

HTTP status code 500 (Internal Server Error)

Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::processWebHook(): Argument #1 ($webhook_event_id) must be of type int, null given, called in /code/modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/StripePaymentElement.php on line 586

Steps to reproduce

Webhook calls from Stripe fail and the event webhook ids look like "evt_3OhdyYDtDendB14I0XISNhnF"

Webhook calls fail for the following events
payment_intent.succeeded
payment_intent.created
charge.succeeded
charge.refund.updated
charge.refunded
charge.succeeded
payment_intent.succeeded
charge.refund.updated
charge.refund.updated
charge.refunded
charge.refunded
charge.refunded
payment_intent.created
charge.refund.updated

Proposed resolution

Modify $webhook_event_id type integer to allow type string

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Component

Payment Element

Created by

πŸ‡¨πŸ‡¦Canada mightysooz

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

Merge Requests

Comments & Activities

  • Issue created by @mightysooz
  • Assigned to TomTech
  • Status changed to Closed: works as designed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TomTech

    Hi! Thanks for the report.

    The webhook_event_id in the module code is the primary key of the commerce_stripe_webhook_event table. This is an integer.

    The property you are referring to is stored in that table as the "stripe_event_id", and is stored in that table as a string.

    Sounds like you might be overriding processWebhook() or onNotify()?

    If you override processWebHook(), this id will already provided for you as the first argument, which you can use to update the record.

    If you are overriding onNotify(), I would suggest to override processWebhook() instead, so that you can take advantage of this being provided to you. (Also, when the queued webhook event processing lands, it will be invoking processWebhook(), so it is more ideal to override.)

  • πŸ‡¨πŸ‡¦Canada mightysooz

    I am using the module out of the box, not modifying anything. I am not sure then why in this case the following webhook events would fail. For now I have disabled those events from Stripe's accounts that failed.

    payment_intent.succeeded
    payment_intent.created
    charge.succeeded
    charge.refund.updated
    charge.refunded
    charge.succeeded
    payment_intent.succeeded
    charge.refund.updated
    charge.refund.updated
    charge.refunded
    charge.refunded
    charge.refunded
    payment_intent.created
    charge.refund.updated

  • Status changed to Active 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TomTech
  • Status changed to Needs review 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TomTech

    @mightysooz , thanks for the additional info.

    I've created an MR to address this issue. There appears to be an issue with the phpunit tests. (Unrelated to this MR, but it is preventing the merge currently.)

    In the meantime, there are two ways to work around this:
    1. If you are comfortable with patching, apply the plain diff of this MR as a patch.
    2. You can enable the sub-module "commerce stripe webhook events", which provides additional functionality, and doesn't have this issue.

  • Status changed to Fixed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States TomTech
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024