Problem/Motivation
StripeEvents::PAYMENT_METHOD_CREATE was added to 1.x in #3191993: Add event to allow customising payment method and customer creation to allow modifying the customer before that is created at Stripe. We used this to match or create a Drupal user account as the payment method owner, working around the problem described in #3564625: Re-usable payment method is not usable if created anonymously.
This event was poorly named, and was removed in #3508499: Clean up Events. The suggested use of the generic payment method entity create event is not sufficient, because it does not contain the payment details submitted from the form.
Steps to reproduce
Upgrade a 1.x instance to 2.x. An event subscriber responding to StripeEvents::PAYMENT_METHOD_CREATE will no longer be called, because the event is never dispatched.
Proposed resolution
Restore a better-named event and dispatch it from an appropriate place, either in Stripe::createPaymentMethod() as before, or in Stripe::doCreatePaymentMethod(). The event needs to be supplied with a $payment_details array containing the data submitted from the form.
Issue fork commerce_stripe-3566023
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
johnpitcairn commentedThis was removed in #3508499: Clean up Events, with the claim that it is not triggered before remote payment method creation. It is however triggered before remote customer creation, as per the original issue which added it. We rely on this to create (or match) and associate a drupal user.
Comment #4
johnpitcairn commentedRemote customer creation at Stripe occurs in
Stripe::doCreatePaymentMethod().To influence this, we need the name and email address captured from the form in
$payment_details. That is not available in the generic payment method entity creation event.Comment #5
johnpitcairn commentedComment #6
johnpitcairn commentedComment #7
johnpitcairn commented#3564625: Re-usable payment method is not usable if created anonymously touches the same code, and could potentially remove the need for early account creation. Postponing while that is being actively worked on.