Add checkout settings for payment method behavior

Created on 20 April 2017, over 7 years ago
Updated 28 August 2024, about 1 month ago

Problem/Motivation

We need to be able to configure whether permanent payment methods are always created, never created, or whether the user has a choice.

Proposed resolution

Add a setting on the payment information page which controls storage of payment methods

  • Always create payment methods for customers for later use (forced)
  • Allow customers to save payment method for later use (opt-in)
  • Never save payment methods for later use

Remaining tasks

TBD once final resolution discussed. Will probably require action in contrib modules and a change record.

Example of what we do in Square (currently does not save payment methods because their terms require it to be opt-in)

    // @todo Make payment methods reusable. Currently they represent 24hr nonce.
    // @see https://docs.connect.squareup.com/articles/processing-recurring-payments-ruby
    // Meet specific requirements for reusable, permanent methods.
    $payment_method->setReusable(FALSE);
    // Nonces expire after 24h. We reduce that time by 5s to account for the
    // time it took to do the server request after the JS tokenization.
    $expires = $this->time->getRequestTime() + (3600 * 24) - 5;
    $payment_method->setExpiresTime($expires);
    $payment_method->save();

User interface changes

Adds new option to payment information pane form

API changes

Adds new option to payment gateways on a strategy for handling payment methods

Data model changes

πŸ“Œ Task
Status

Needs review

Version

2.0

Component

Payment

Created by

πŸ‡·πŸ‡ΈSerbia bojanz

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    771 pass, 2 fail
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    769 pass, 4 fail
  • Just jumping in here, patch 60 seems to be working in initial testing.

    Merge request from 74seems to be missing the checkbox at checkout for some reason. @tBKot can you provide a patch and interdiff between #60?

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I am seeing the same thing as @tonytheferg

    patch in #60 seems to work, but the MR does not show the "Save this payment method for later use" checkbox on the checkout form.

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    Here is an interdiff of #60 and MR 149

    It appears that with the MR, in order for the checkbox to appear on the checkout form, the payment gateway needs to have the public method

     public function supportsReusableOption(): bool {
        return TRUE;
      }
    

    When it does, the checkbox appears and the payment method is stored at checkout when checked.

    I think this is a good addition, but gateway contrib modules will need to support this.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    Patch Failed to Apply
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    794 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    Patch Failed to Apply
  • πŸ‡ΊπŸ‡ΈUnited States gcb

    Here's a patch version of the PR as of comment 74, along with patches for commerce_stripe and commerce_authnet to make them compatible.

    I suspect those probably belong in the other modules' issue queues, but until we are sure this is how things are being done I think it makes sense to keep it all in one place.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    795 pass
  • πŸ‡ΊπŸ‡ΈUnited States gcb

    I found that the patch above caused a crash on free orders that didn't have a payment method attached when trying to produce the payment information summary pane. The attached version makes a small check to avoid that crash.

  • πŸ‡³πŸ‡΄Norway zaporylie

    Handling of free orders is actually not mentioned in the issue summary here but sneaked into the patch ;) Because currently we always make payment methods reusable, and here this option is squeezed under always reusable, I am creating ✨ Allow creating payment method on free orders Active and will extract the relevant part of #79 in there.

    Currently not commenting on the reusability feature but will come back to comment on that soon.

  • πŸ‡³πŸ‡΄Norway zaporylie

    Here are some objectives that should be included in this issue's scope:
    - customer must be able to opt-out from reusable payment method (::setReusable(FALSE)). Non-reusable payment methods will only be used to create initial payment.
    - gateway must be able to declare whether the payment method it creates is reusable. We must be able to filter out all unreusable payment methods. whether existing or new, depending on the context. For example, commerce_recurring must be able to enforce checkout with a reusable payment method for the sake of subsequent charges
    - some gateways, depending on configuration, may be reusable but only in the Customer Initiated Transaction (CIT) scenario. This is already possible for Stripe. Such payment methods should not be reusable for Merchant Initiated Transactions (MIT). We must be able to filter them out ✨ Define payment method's reusability context Active

    I don't think we currently have one but this probably calls for a meta issue so we can divide the scope into some smaller chunks and work on them one by one,

Production build 0.71.5 2024