How to enable/disable Billing Information in Commerce depending on the payment method Till now, I have been using only PayPal checkout on my Commerce site, and I have configured the checkout flow so all of the customer's information is collected over on PayPal's site.

However, I am now trying to add Stripe as an alternate payment method.  I need to collect the customer's billing info on my site when using Stripe, so I need to add Billing information to the checkout pane.

Goal


Show Billing information if the customer selects Stripe as the payment method.  If the customer selects PayPal, do not show Billing information.


I looked through the various commerce events and actions available in the Rules module, but I couldn't find anything that is helpful for this case.
There is no way just through Rules to influence the visibility of a checkout pane. Instead, you'll need to use hook_form_alter() and hook_commerce_checkout_pane_info_alter(). Why both?

You have to use the form alter to remove or disable the billing information checkout pane when you detect PayPal has been selected, which means you also need the payment method selection to be first (and, in the most simplest case, on its own page).

You have to use the checkout pane info alter to set your own validate and submit callbacks for the billing information checkout pane. These should also check the payment method and only invoke the default callbacks if the proper payment method was selected. The reason for this step is that the checkout form validates / submits checkout panes based on where they're configured to appear in the checkout form, not based on whether or not they were actually present on the finally rendered form. You can alter a pane out of the checkout form's array, but its default validate callback will still process it as if it had been there.

To determine what payment method was selected, look in $order->data['payment_method'].