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