Improve PaymentIntent metadata and event handling in Payment Request Button gateway

Created on 25 September 2025, 20 days ago
Updated 28 September 2025, 17 days ago

Problem/Motivation

When creating a PaymentIntent via the Stripe Payment Request Button gateway, the module provides limited/default metadata and does not give third-party modules a reliable opportunity to inject or override metadata before the PaymentIntent is created.
This leads to inconsistencies compared to the standard commerce_stripe gateway, and makes it hard for sites to send rich, business-critical metadata to Stripe.

Steps to reproduce

Proposed resolution

  1. Dispatch a specific event prior to PaymentIntent::create(), allowing consumers to add/override intent attributes (especially metadata), mirroring the pattern used by commerce_stripe:
    • Event: Drupal\commerce_stripe_payment_request_button\Event\PaymentRequestButtonEvents::PAYMENT_INTENT
    • Payload: a PaymentIntentEvent-like object with getIntentAttributes()/addIntentAttributes()
  2. Keep a single place to build rich metadata: the existing custom event subscriber.
  3. Make sure each flow dispatches the corresponding event before PaymentIntent::create().
  4. For renewals, either reuse the same event path or set metadata at the subscription level as a fallback.

Benefits

  1. Restores parity with the standard commerce_stripe gateway’s extensibility.
  2. Enables sites to uniformly enrich metadata across all Stripe payment methods, including Payment Request Button (Apple Pay/Google Pay).
  3. Keeps a sane baseline (order_id, order_items,...) even if no subscriber is present.
🐛 Bug report
Status

Active

Version

3.8

Component

Code

Created by

🇯🇴Jordan mohammad-fayoumi Amman

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024