Allow a store to always collect a billing address before payment method selection

Created on 11 September 2020, about 4 years ago
Updated 28 August 2024, 3 months ago

Problem/Motivation

Some payment methods are only available to customers in specific countries; for example, in the past we’ve had multi-national stores where they used one gateway for France and another for Germany. Or, certain options (like GoCardless & ByJuno ) may only be available to customers [with a billing address] in a specific country (i.e. UK / Switzerland).

In order to support them, we need to be able to use the billing address inline condition on payment gateways to determine payment method availability. This is complicated by the fact that an order will not necessarily have a billing address until the payment information pane is at least partially submitted.

Steps to reproduce

These two issues both describe the scenarios to reproduce.

Proposed resolution

Settings

Add a setting to the payment information checkout pane that moves billing address collection above the payment method radios. In the settings summary, it should read:

”Billing address collection determined by payment gateway.” or ”Billing address is always collected.”

The checkbox default to unchecked to preserve current functionality and should be labeled, “Collect a billing address for all payment methods.” with a description that reads, “The billing address fields will be moved above the payment method radio options.”

Checkout

We need some way to detect that a billing address has been supplied (in 1.x we used onchange on all of the embedded customer profile fields and triggered a refresh when all required fields had a value). Once the billing address is entered, we need to refresh the list of available payment methods - this means saving the profile, assigning it to the order, and re-building the pane form to reflect new options.

We need to ensure the form accommodates the three types of address entry: new address entry, reuse of a shipping address, and selection of an address from the addressbook. It isn’t clear to me at what point we’ll need to actually write information to the database based on those two alternate address sources, but at this point … presumably the shipping address would have been saved, if applicable, due to the “Recalculate shipping” button … but it also appears that the addressbook widget uses its own logic to determine a default address vs. writing a default address reference to the database for the order.

Remaining tasks

User interface changes

Admin

Payment information checkout pane will now have the following options

  • Collect billing information
    The option will collect billing profile before filtering and presenting payment gateway options
  • Require billing information
    Hide payment gateways until an address is entered
  • Auto Rebuild
    Auto rebuild payment options when a new address is entered

Customer

API changes

Noen identified

Data model changes

None identified

Feature request
Status

Needs work

Version

3.0

Component

Payment

Created by

🇬🇧United Kingdom dwkitchen London

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • 🇺🇸United States DamienMcKenna NH, USA

    Cross-posting from 🐛 The billing address condition should not be shown for payment gateways Active .

    There are tangible business reasons why this is necessary.

    In Commerce 1 on Drupal 7 it is possible to limit one payment method so it can only be used in one country, and other payment methods so they can be used in all countries except for that one. We've done that for years on a non-profit org's site and it works reliably.

    Per #42 it sounds like the work needs to be split into several pieces. Were the necessary issues created? I don't see any open issues regarding this use case besides #2950877, which hasn't been touched in almost three years. What are the next steps here?

  • 🇦🇹Austria agoradesign

    In most of our e-commerce projects, we are providing a custom billing information pane and putting the payment method selection in a dedicated payment step. This way it is easy to restrict a payment gateway to a single country, for example

  • 🇮🇱Israel jsacksick

    If this is ever implemented, this should go into 3.x.

Production build 0.71.5 2024