Public Ticket #4581324

Company Credit addon – orders within credit limit rejected with "insufficient credit" error

Closed
Comments
1 Ticket
Jack started the conversation 1 month ago on August 28, 2026 at 3:00pm

Hello,

We are setting up the Company Credit addon on our B2BKing installation and have run into a bug that blocks customers from paying on credit even when they are well within their approved limit. We would appreciate your help identifying the cause.

Setup
- Customer has an individual credit limit of €5,000 (user meta: b2bking_user_credit_limit).
- The customer group's "Group Credit Limit" field is left empty, per your documentation stating it is "optional, is overwritten by individual user limit."
- Customer group has the credit gateway, iDEAL, and Bancontact enabled as payment methods.
- The customer's payment methods override is set to "Use group rules (Default)."

What we tested
We placed five consecutive test orders on the same customer, all using the credit gateway:

1. Order #1729 – €640.13 – succeeded
2. Order #1730 – €1,213.70 – succeeded (cumulative: €1,853.83)
3. Order #1731 – €1,787.28 – FAILED with "You do not have sufficient credit to pay for this order" (cumulative would have been €3,641.11 — still well under the €5,000 limit)
4. Order #1732 – €1,213.70 – FAILED, same error
5. Order #1733 – €125.84 – FAILED, same error

The cumulative total at checkout never exceeded the €5,000 limit, yet orders 3, 4, and 5 were rejected at checkout.

A second, arguably more serious issue
Despite the checkout error, all five orders were still created, and the full amount was deducted from the customer's credit balance in the Company Credit ledger (confirmed via the ledger PDF export from the customer's CRM Hub page — all five show as "Purchased" with the balance decreasing each time). However, orders 3–5 are stuck in "Pending payment" status rather than "Processing," while orders 1–2 (which did not trigger the error) moved to "Processing" normally.

So the checkout-time validation appears to be blocking the order from completing normally, but the order is still created and credit is still consumed — meaning a rejected order can silently eat into a customer's available credit.

Questions
1. How exactly is "used credit" calculated at checkout — is it a live calculation from order data, or a cached/periodically recalculated value? We noticed a user meta field b2bking_grpro_last_periodic_run, which suggests some form of periodic recalculation, and want to rule out that stale cached data is causing the false rejection.
2. Does leaving the "Group Credit Limit" field empty correctly fall back to the individual user limit, or could an empty value be internally read as 0 and therefore create a conflicting, lower ceiling?
3. Why would checkout validation reject an order that is within the credit limit, while still creating the order and deducting the credit amount from the ledger?
4. When an order paid via Company Credit is cancelled, is the credit reliably restored, including after repeated cancel/reorder cycles? We want to confirm this before relying on it in production.

We are preparing to launch this store shortly and would appreciate a prompt response. Happy to provide additional debug output, screenshots, or the ledger PDF export if useful.

Thank you,

Jack

2,762
KingsPlugins replied 1 month ago on August 29, 2026 at 1:19pm

Hi Jack,

Thank you for purchasing our plugin,

This is very unusual - both the limit not working and the orders still being created despite the error. I don't fully understand yet what's happening there. Perhaps there's some kind of custom checkout in place, or a plugin conflict of some sort.

 

To answer your questions:

1. There's no recalculation or caching - it's a live calculation. The b2bking_grpro_last_periodic_run key you found is for a different feature (group rules).

2. Yes, the individual user credit limit should always take priority, so leaving the group field empty is fine.

4. Yes, credit should be restored when an order is cancelled.

 

Would it be possible to share a backend login to the site or a staging clone site so we can troubleshoot this directly? If you also have any specific steps to reproduce the issue, or can point us to the specific orders with problems, that would help a lot as well.

Kind regards,
Stefan

1 Ticket
Jack replied 1 month ago on September 1, 2026 at 2:15pm

Hi Stefan,

Thanks for your reply and for confirming points 1, 2 and 4 — that helps narrow things down. Regarding point 3 (why the checkout blocks an order that is within the credit limit), we've since done much more controlled testing and have a clean reproduction to share.

Cleanest reproduction so far
- Fresh test account, credit limit set to €5,000, zero prior usage (confirmed €0 outstanding, €5,000 available in both the backend and the checkout page itself).
- First order ever placed on this account: 8x Indevolt PowerFlex 2000 AC, cart subtotal €3,719.76.
- With standard shipping, order total €4,579.56 — checkout immediately blocks with "You do not have sufficient credit to pay for this order," despite the payment option on the same page showing "Available credit: €5,000.00."
- We repeated the exact same order using local pickup instead of shipping (no shipping cost applied at all) — same error. This rules out our custom shipping calculation as the cause.
- This is not a cumulative-usage issue either: it happens on the very first order of a completely fresh account, well within the limit.

A pattern we've noticed: every order that has triggered this error so far has fallen within a tiered/staffel pricing bracket (5–9 units, in this case), where a per-unit discount is applied to the cart. Our working hypothesis is that the credit validation may be running against a cart or order total calculated before the tiered discount is applied, comparing the limit against a higher (pre-discount) amount than the total the customer actually sees and is charged.

We'd also flag again the operational issue we mentioned before: even when the checkout blocks with this error, the order is still created and the corresponding amount is still deducted in the Company Credit ledger. So a customer seeing this error is not simply "nothing happened" — credit is consumed and an order exists in a pending state regardless.

On backend access
We'd prefer not to share a login to our live backend, as the site is now live with real customer and financial data. If it would help, we're happy to:
- Record a short screen capture of the exact reproduction steps above
- As a last resort, create a temporary, limited admin account that we can revoke once this is resolved

Given we've now launched, resolving this is fairly urgent for us — we can't safely offer Company Credit to customers until this is sorted. Let us know which of the above would help most, or if there's specific data (order/cart exports, plugin version numbers, etc.) that would speed up your investigation.

Also, we can't be the first or only one with this problem, right? Given how it is a pretty big feature in the plug in.

Thanks,


Jack

1 Ticket
Jack replied 1 month ago on September 2, 2026 at 7:42am

Hi Stefan,

Good news — we've updated to the version you sent (1.6.25) and tested with the exact case that was failing before.

- Checkout completed without any error.
- Available credit correctly updated to €420.44 after the order.
- After cancelling the order, available credit correctly returned to €5,000.00.

This matches your explanation of the timing issue exactly, and everything looks correct now. Thanks for tracking this down and for the quick turnaround — much appreciated, especially since we'd just gone live.

We'll keep an eye on it over the next few days as real orders come through, but as far as we're concerned this can be marked resolved. Let us know if you need anything further from us.

Thanks again,


Jack

2,762
KingsPlugins replied 1 month ago on September 4, 2026 at 3:07pm

Hi Jack,

Great to hear that, thank you for confirming!

If you see any further issues over the next few days or anything else we can help with, please reach out anytime.

Kind regards,
Stefan

1 Ticket
Jack replied 2 weeks ago on September 24, 2026 at 9:43am

Hi team,

I have got another issue which is not really the same as below, but has to do with the credit function. 

Our credit gateway correctly records entries in the Transaction History for full orders (customer only uses credit payment in checkout). Is there a function or hook to programmatically trigger that same recording for a partial amount, bypassing the standard gateway selection at checkout?

I've built in a function with a snippet where if a customer has a credit limit of 10.000, and he wants to order worth of 30.000, his credit maximum of 10.000 will be deducted from the total, leaving the 20.000 to pay via bank deposit at that moment.

It appears that, as a result, the credit function fails to recognize that a payment of 10.000 was made on credit and does not record this anywhere.


Hopefully you can help with this issue.

Jack

2,762
KingsPlugins replied 1 week ago on September 27, 2026 at 5:55pm

Hi Jack,

Thanks for the extra details. There is no built-in public function that accepts a partial credit amount. The standard recording function only runs when Company Credit is the order’s payment gateway,

I put together an example of how the partial amount could be recorded here:
https://pastecode.io/s/tb9actqg

This is only an example and should be adapted to your code. The general approach is to save the updated consumed balance in the b2bking_user_credit_consumed_balance user meta and append the transaction to b2bking_user_credit_history.

 

If you send us the code you are currently using, we can take a closer look and advise,

 

Kind regards,
Stefan

Sign In