My Drupal commerce site supports multiple payment gateways. One of the payment types should be paying by invoice. That means if you select invoice payment type during checkout process you don't have to enter any "real" payment info (credit card data or something), but at end site should send you invoice (pdf document) with instructions how to pay your order.

I've installed Invoice module: https://www.drupal.org/project/commerce_invoice

And if I understood well I should use actions and rules to send email after checkout is complete. Is that true?

But what puzzles me most is that this module doesn't provide invoice payment gateway. So I don't know how to achieve that when user is selecting payment method "Pay by invoice" method appears? Should I use some dummy (test) payment gateway or? What payment gateway should be used for invoice payment?

An update:

What Rules event should I use to detect that checkout process is finished, so I can send invoice.

Also, what action should I select to send email that contains invoice (with link to PDF document or PDF document attached)?

1 Answer 1


Yes - just create a new (custom, standard) payment method named Invoice, and user's then can select that.

On the payment method edit form you can add more details, and even could limit the availability of the method.

Rules are not actively supported as in D7: https://www.drupal.org/node/1535554 But I do not see a need using rules with your use-case.

You need to configure your invoice type to send emails, there should be a checkbox: Email the customer a confirmation when an invoice is generated - see https://www.drupal.org/project/commerce_invoice/issues/3089861

The invoice is attached by default and you can remove the attachment with hook_mail_alter, it's using the id invoice_confirmation. See https://git.drupalcode.org/project/commerce_invoice/-/blob/8.x-2.x/src/Mail/InvoiceConfirmationMail.php (UPDATE: The invoice types seem to create invoices for all payment methods and is not (yet) configurable to limit them)

See also the commerce-invoice-confirmation.html.twig to change the email.

Not attaching the PDF makes the emails smaller, and maybe passes more SPAM filters .. But users need to take action and press a link .. I would discuss that with the customer or maybe try both and gain experience with them. (Like what method is really paid more, and which one is faster)

UPDATE: If you only want to send the invoice for one payment method you need to alter the commerce receipt email (id: order_receipt) and attach the invoice there. You'll find the order entity in the body's theme render array (first entry using #theme commerce_order_receipt)

  • I thought that I must use rules to create/send invoice. There is a checkbox for sending, but no option to select with what payment method invoice should be sent? I need it only if "Invoice" payment method is chosen by user. Also is checking this checkbox triggering generation and sending - they are not separate things?
    – MilanG
    Commented Aug 6, 2020 at 8:56
  • Didn't install the module and only looked at code ;) If the invoice type is not configurable per payment method, this would be a good feature request! A workaround could be turning the invoice type's email off and alter the commerce receipt email. See my updated answer.
    – rémy
    Commented Aug 6, 2020 at 20:35
  • It's a shame that module (specially D8 version) is very poorly documented. There is only a list of features but it's not explainend at all how to use them. :(
    – MilanG
    Commented Aug 7, 2020 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.