Skip to content

Commerce Foundations: the B2B ecommerce platform for manufacturers and distributors. See what it includes

Craft CMS plugins

Net Terms

Net Terms is a Craft Commerce payment gateway that bills orders on net terms, tracks each buyer's balance, and applies recorded payments to invoices or orders.

Paying on account

What a buyer sees at checkout, what a charge does, and how refunds change the account’s balance.

At checkout#

The Net Terms gateway is listed with the store’s other payment methods, under the name it has in Commerce -> Settings -> Gateways, when all of these are true:

  • The order’s customer is an active buyer on an account in the order’s store, and on the storefront is signed in. In the control panel, staff charge the customer’s accounts, not their own. A site module can charge a different user; see company accounts.
  • The account’s credit limit isn’t 0. A customer on more than one account doesn’t see the accounts with a 0 limit.
  • The order isn’t already complete. A completed order’s balance is paid another way.
  • The gateway’s own conditions in Commerce -> Settings -> Gateways match the order.

Otherwise the gateway isn’t listed, and the customer pays another way.

The gateway’s payment form shows the buyer’s available credit, unless the buyer’s credit is unlimited. A customer who buys on more than one account chooses one from a list sorted by title, with each account’s available credit beside it. The form selects the first account with enough credit. When the order is more than the available credit on every account the customer can choose, or those accounts are suspended, the form says there isn’t enough available credit and shows no pay button. If the checkout template doesn’t pass the order to the payment form, the form uses the current cart. Net Terms doesn’t split an order with another payment method.

What a charge does#

The gateway checks available credit again as it charges, and declines the order when the credit doesn’t cover it. If two checkouts on the same account are paid at the same moment and there isn’t room for both, the gateway declines one of them.

What happens to the order depends on the gateway’s payment type:

  • Invoice billing: the gateway purchases the order total, so Commerce marks the order paid. Net Terms adds the charge to the account’s ledger, and the charge goes on the account’s next invoice.
  • Order billing: the gateway authorizes the order total. The order stays unpaid until you record payments against the order. See billing by order.

Changes to a paid order#

In invoice billing, when the total of a completed order charged to an account changes, a queue job settles the change on the order and the ledger. The order stays paid.

  • The total rises. The job adds a Net Terms purchase to the order and a charge to the ledger. It charges only the order’s balance due, so a payment taken in the meantime covers the rest. The charge goes on the account’s next invoice.
  • The total falls. The job refunds only what the order is overpaid, and doesn’t refund again what you refunded before the edit. It refunds the newest Net Terms purchase first, each up to what it can still refund, and adds an Order changed entry to the ledger for each refund. If the order’s charge is already on an invoice, the entry comes off that invoice line when the line’s balance covers it. Otherwise it goes on the next invoice.

A refund you give without editing the order takes the amount off the buyer’s balance.

If the job runs twice for one edit, the second run changes neither the order nor the ledger.

A raise over available credit#

For an active buyer on an Active account, a raise has to fit the buyer’s available credit. When it doesn’t, clicking Update order in Commerce’s order editor shows “There are errors on the order” with the reason, and doesn’t save the order. Lower the order total, or make room on the account first: raise the credit limit or the buyer’s sublimit.

On a suspended account, or for a deactivated buyer, Net Terms doesn’t check available credit and adds the raise to the buyer’s balance, even past the limit. The account pages then show how far over the limit the account or buyer is; see over the limit.

The raise can still fail when the queue job runs, for example when another order uses the buyer’s credit first, or a module saves the order without validation. The job then fails with the same reason. The saved order keeps a balance due, and the job changes neither the order’s transactions nor the ledger. Make room on the account, then retry the job in Utilities -> Queue Manager.

Refunds#

In invoice billing, refund a Net Terms order from the order’s page in the control panel, as with any other Commerce payment. Partial refunds work. The refund takes the amount off the buyer’s balance.

If the order’s charge is already on an invoice, the refund comes off that invoice line when the line’s balance covers it. Otherwise Net Terms takes it off the buyer’s next invoice.

In order billing, the charge is an authorization, which Commerce can’t refund. Edit the order instead, and the buyer’s balance follows its new total. To refund a recorded payment, see changes after checkout.

Deleting an order#

In either billing mode, an order on an invoice that isn’t voided can’t be deleted, because the customer already has that invoice. The orders index says why, with its delete button disabled. Commerce’s order page doesn’t show a message, and the order stays. A module that deletes the order in PHP gets false back. To delete the order, void the invoice first.

A trashed order stops counting toward the buyer’s balance, their available credit and the next invoice, and the account’s Ledger tab doesn’t list its entries. Restoring the order counts it again. A queue job settling an edit to the order’s total still runs while the order is in the trash, so the ledger matches the order when you restore it. Deleting the order permanently deletes its ledger entries.

For order billing, see changes after checkout.

We can take it from here.

We take on the Craft and Craft Commerce sites you built, so you can get back to building. Introduce a client who signs a management contract and you get a $3K partnership fee.

How the Dev Partnership Program works
Book a call with Stephen