Does not capture fees from StripePaymentElement gateway

Created on 4 May 2024, 6 months ago
Updated 8 May 2024, 6 months ago

Problem/Motivation

This module looks very promising for a project I'm in the middle of building. Thanks!

However, it doesn't work if you configure the (recommended) "Payment element" gateway with Stripe. That payment gateway plugin does not dispatch the StripeEvents::TRANSACTION_DATA event, only StripeEvents::PAYMENT_INTENT_CREATE.

Steps to reproduce

  1. Install Commerce core, commerce_stripe, commerce_payment_fee and commerce_payment_fee_stripe
  2. Configure a payment gateway for your store with "Payment element".
  3. Complete a test checkout
  4. See if there are any fees recorded in your payment

Proposed resolution

Subscribe to both events, and record fees from either one.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dww

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

Merge Requests

Comments & Activities

  • Issue created by @dww
  • Status changed to Needs review 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    In very mild local testing, the change in the MR seems to work. This is the first time I'm looking closely at payment gateways at all, much less the gory details of Stripe. Would love some reviews / pointers on if this is legit. πŸ˜‚

  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    The code looks fine at first glance. However, when does a PaymentIntentEvent fire? Do we need to check the status of the event to make sure we're only recording the fee when the payment has actually succeeded? In the Commerce Stripe code, I see that the TransactionDataEvent is only dispatched when the status of the PaymentIntent is REQUIRES_CAPTURE and SUCCEEDED, and when count($intent->charges->data) !== 0.

    https://git.drupalcode.org/project/commerce_stripe/-/blob/8.x-1.x/src/Pl...

    Do we need a similar check to make sure we're not importing the fee when the charge was declined?

Production build 0.71.5 2024