Make the billing information optional through checkout pane configuration.

CommentFileSizeAuthor
#35 collect_billing_information.png47.27 KBbojanz
#33 interdiff_28-33.txt17.95 KBbojanz
#33 2905028-33-optional-billing-information.patch22.87 KBbojanz
#28 interdiff_27-28.txt1.05 KBjsacksick
#28 2905028-28-optional-billing-information.patch17.86 KBjsacksick
#27 interdiff_26-27.txt493 bytesjsacksick
#27 2905028-27-optional-billing-information.patch18.01 KBjsacksick
#26 interdiff_25-26.txt8.95 KBjsacksick
#26 2905028-26-optional-billing-information.patch18.33 KBjsacksick
#25 interdiff_24-25.txt1.42 KBjsacksick
#25 2905028-25-optional-billing-information.patch10.38 KBjsacksick
#24 interdiff_23-24.txt3.72 KBjsacksick
#24 2905028-24-optional-billing-information.patch10.91 KBjsacksick
#23 2905028-23-optional-billing-information.patch7.13 KBbojanz
#20 commerce-2905028-optional_billing_info-20.patch6.35 KBpiggito
#15 commerce-2905028-optional_billing_info-15.patch6.22 KBSAVEL
#12 commerce-2905028-optional_billing_info-12.patch5.22 KBSAVEL
#9 Payment_information_fieldset_empty.png6.02 KBmitrpaka
#8 interdiff-7-8.txt541 bytesczigor
#8 commerce-2905028-optional_billing_info-8.patch4.66 KBczigor
#7 interdiff-6-7.txt580 bytesedaa
#7 2905028-7.patch4.63 KBedaa
#6 needs_billing_false.png9.47 KBedaa
#6 2905028-6.patch3.93 KBedaa
#6 interdiff-2905028-3-6.txt1.32 KBedaa
#3 commerce-2905028-optional_billing_info-3.patch3.43 KBczigor
#2 commerce-2905028-optional_billing_info-2.patch3.52 KBczigor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

czigor created an issue. See original summary.

czigor’s picture

Status: Active » Needs review
FileSize
3.52 KB
czigor’s picture

FileSize
3.43 KB
czigor’s picture

Issue summary: View changes
edaa’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, works well.

edaa’s picture

Show 'Payment information' pane summary on 'Review' step when 'needs_billing' option is disabled.

needs_billing_false

edaa’s picture

FileSize
4.63 KB
580 bytes

Add schema for needs_billing.

czigor’s picture

Just a missing docblock.

mitrpaka’s picture

Thank you for the patch!

If store has only one payment gateway defined, Payment information is shown as empty fieldset once when 'Collect billing information' option is disabled. Any possibility to check and hide fieldset entirely if only one payment gateway defined?

Payment information fielset

bojanz’s picture

Status: Reviewed & tested by the community » Needs review

I don't want to keep the patch in RTBC cause it might make someone believe it's safe to use. This is very experimental and will crash any gateway expecting a billing profile.

gologan’s picture

Does this work with the Commerce Braintree gateway?

We use that for credit cards and PayPal and don't need any address info.

Edit: This doesn't appear to work with the Commerce Braintree payment gateway.

SAVEL’s picture

Here is the patch based on #8 and compatible with latest dev and Commerce 8.x-2.5 Release.

Honza Pobořil’s picture

Patch #12 works for me.

Anybody have an idea how to offer user to fill billing info if he wants?

Dubs’s picture

I might be missing something obvious in configuration, but it doesn't seem like you can make the billing information optional on the order entity? So I have empty billing info which prevents a save without that data if you edit an order. Like I say, perhaps there's some config I've missed somewhere?

SAVEL’s picture

Here is the patch compatible with latest dev and Commerce 8.x-2.10 Release.

SAVEL’s picture

Dubs, you are right!

We still have a problem with editing order in administration interface. We should also remove billing information form from there.

I've never faced the problem as I never tried to edit order via web-interface.

mike82’s picture

Instead of making the billing information optional through checkout pane configuration it could be more usefull to Keep billing information as a separate pane instead of replacing it with the payment information pane.

Dubs’s picture

@mike82 - that sounds like a good idea. A lot of sites would not require billing information at all.

bobemoe’s picture

Just updated drupal/commerce (2.11.0 => 2.12.0) and the patch no longer applies.

Status: Needs review » Needs work

The last submitted patch, 20: commerce-2905028-optional_billing_info-20.patch, failed testing. View results

bojanz’s picture

Title: Make billing information optional on checkout » Add a per-gateway setting to skip collecting billing information

Time to revisit this.

We need to make this a payment gateway annotation + setting. Existing gateways might crash without a billing profile, so they need to opt-in.

bojanz’s picture

Status: Needs work » Needs review
FileSize
7.13 KB

Here's a rough sketch made after discussing with jsacksick.

Needs an update hook for making the billing_profile field optional.
Needs a functional test somewhere (PaymentCheckoutTest, I guess).

jsacksick’s picture

jsacksick’s picture

jsacksick’s picture

jsacksick’s picture

jsacksick’s picture

Honza Pobořil’s picture

I want to have it optional for user. Could I add it to patch?

Checkbox Collect billing information change to radios:

Collect billing information

  • Require billing information
  • Optional for user
  • Do not collect
bojanz’s picture

@Bobík
No, that would need to stay custom to your site.

Honza Pobořil’s picture

In buildPaneForm at PaymentInformation.php:

    if ($this->order->isPaid() || $this->order->getTotalPrice()->isZero()) {
      // No payment is needed if the order is free or has already been paid.
      // In that case, collect just the billing information.
      $pane_form['#title'] = $this->t('Billing information');
      $pane_form = $this->buildBillingProfileForm($pane_form, $form_state);
      return $pane_form;
    }

So it seems there is edge case for free orders - even with current patch it will not be able to disable biling profile form.

bojanz’s picture

Yes, this only covers non-free orders currently.
Free orders have a separate code path, and settings for it are being explored in #2871483: Add checkout settings for payment method behavior. Not sure we should touch it here.

bojanz’s picture

Here are some cleanups.

Simplified the payment gateway setting logic.
Added a warning description after brainstorming with Ryan.

Fixed the following problems:
1) The payment gateway label should be shown in the Review page even if there's no billing information. The test should confirm.
2) PaymentMethodEditForm should create the billing profile if missing, cause it's possible that the merchant enabled billing info collection after it was previously disabled.
3) testManualWithoutBilling should confirm that the payment instructions are still shown, cause that confirms a payment was created as well.

Opened #3050301: Clean up the payment method plugin forms for related cleanups, to avoid bloating this patch.
Opened #3050303: Forward port the 1.x button to explicitly add a profile on the order edit form for the admin UI problem mentioned in #14 / #16.

  • bojanz committed db945d9 on 8.x-2.x authored by jsacksick
    Issue #2905028 by jsacksick, czigor, edwardaa, bojanz, SAVEL, piggito,...
bojanz’s picture

Status: Needs review » Fixed
FileSize
47.27 KB

Added explanation docblocks to the Onsite and OffsiteRedirect example gateways.
Tweaked the docblocks for OrderInterface::getBillingProfile and PaymentMethodInterface::getBillingProfile.

Committed! Change record created. Screenshot attached.

Since the setting is per-gateway, you can easily duplicate your gateway and have two versions, one that collects billing information and one that doesn't. You can then use conditions to restrict each one to specific order types, stores, customer roles, etc. That would give you per-order-type, per-store, per-customer-group settings as well!

Note that only the Manual gateway shows this checkbox right now. Each gateway will need to be updated by adding the requires_billing_information = FALSE annotation key, and updating code to check for a NULL billing profile.

Braintree issue: #3050427: Allow not collecting billing information.
Stripe issue: #3050428: Allow not collecting billing information.

bojanz’s picture

Also note that #9 (the empty fieldset) was fixed in #3049355: Checkout panes are rendered even if they are empty.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

init90’s picture

Awesome work, thanks! Just encountered with such case.