Problem/Motivation
Stripe's payment element offers various features that are only customisable by creating a CustomerSession.
These features focus on displaying saved cards in the payment element, or gathering permission to save the card. While these features aren't relevant if using Drupal Commerce's normal mechanism for showing saved payment methods in the PaymentInformation pane, they nonetheless can be made to work fine in a Drupal Commerce checkout and actually offer a superior UX for saved payment methods compared with the PaymentInformation pane (they have bigger UX budgets!).
Let's provide optional support for these features in the StripePaymentElement gateway and StripeReview checkout pane.
Proposed resolution
1. Create a CustomerSessionAttributes event to allow developers to specify the attributes they want.
2. Create a createCustomerSession method on the StripePaymentGateway plugin. This dispatches an event to gather attributes, creates a customer if necessary, and creates a customer session if necessary.
3. Call the createCustomerSession() method from the StripeReview pane.
Remaining tasks
User interface changes
None, unless developers choose to specify payment element features.
API changes
A new createCustomerSession() method on StripePaymentElementInterface.
Data model changes
None.