Payments
Hardcount charges a customer’s saved card through your own Stripe account, right after an invoice is issued. When a charge fails, it tries again on a schedule and emails the customer. Credit the customer holds pays an invoice before the card is charged. A customer can also pay on an invoice’s hosted page, which is how a top-up, the invoice that sells credit, is usually paid (Sell prepaid credit). This page explains that flow, the payment statuses, and the webhooks your app gets.
Hardcount uses Stripe to save, charge and refund cards, and, if you choose, to work out tax. It does not use Stripe Billing or Stripe Invoices: the invoice is Hardcount’s. To connect Stripe, see Connect Stripe and take card payments.
When a customer first sets up a card or pays an invoice, Hardcount creates a customer for them at Stripe and keeps it up to date. When you change the customer’s email, Hardcount sets it at Stripe. When you save a billing profile, Hardcount also sets the Stripe customer’s name, address, phone, tax status and tax ID, and removes any other tax ID there. A change to the display name does not reach Stripe.
The flow
Section titled “The flow”- The customer saves a card. They enter it on a Stripe page, never on yours or Hardcount’s. That page opens from a setup link you send, or from Pay on the hosted invoice page. A card saved through a setup link becomes their default. Those Stripe pages offer cards only. A payment method of another type that reaches Hardcount another way is listed with its type and never charged, so it never becomes the default.
- An invoice is issued. Hardcount first uses any credit the customer holds (Credits). If credit covers it all, the invoice is paid and nothing is charged.
- Hardcount charges the default card for what is left, naming that exact card. The charge is a Stripe PaymentIntent: Stripe’s record of one attempt to take money.
- The charge succeeds or fails. Success marks the invoice
paid. A failure starts payment retries, called dunning. - Dunning retries the charge on a schedule and, once email is set up, emails the customer. A card the customer adds meanwhile is charged. When the retries run out, your dunning policy decides what happens.
With no card saved, step 3 cannot run. Dunning starts at once. Once email
is set up, the customer gets an email at once: a link to add a card when
Stripe is connected and PAYMENT_ and PAYMENT_
are set, or the invoice itself when Stripe is not connected. With Stripe
connected and either address unset, no email goes out at once. Each dunning
retry then sends a reminder. Once they add a card, the next billing run
charges it.
An amount below Stripe’s minimum charge, such as $0.50 in USD, is not charged and starts no retries. The invoice stays open (what to do).
Payment statuses
Section titled “Payment statuses”An invoice’s payment_ says where its card payment stands. It sits
beside the invoice’s own status.
payment_ |
What it means |
|---|---|
pending |
Not charged yet: the invoice is waiting for a card, a retry, or its first charge. |
processing |
Stripe accepted the charge but has not finished it, as with some bank debits. |
succeeded |
The money arrived. The invoice is paid. |
failed |
Stripe declined the charge. Dunning retries it. |
unknown |
A charge is at Stripe and Hardcount has no answer yet. Every charge is unknown for a second or so. It stays unknown when the answer is unclear. See When the answer is unclear. |
Retries: dunning
Section titled “Retries: dunning”Dunning is the process of collecting an unpaid invoice. The account’s dunning policy sets it up, one policy for each mode, used for every customer:
- When to retry: the days to wait before each retry, in
retry_. The first wait counts from the failed charge, and each later one from the retry before it. Every new account starts withdays retry_days [3, 4, 7]: retries on day 3, 7 and 14 after the failed charge. - What to do when the retries run out: two separate choices. For the subscription: cancel it, or do nothing. For the invoice: write it off, or leave it open. A new account’s policy does nothing to either: the subscription keeps billing and the invoice stays open.
Each retry first uses any credit the customer got since the last try.
Some declines are never retried on the same card:
- A card refused for good, such as a lost or stolen card. Retries keep their schedule but charge only once the customer has another default card.
- A bank that wants the customer to confirm the payment (3-D Secure). The emails ask the customer to pay on the hosted invoice page, where they can confirm.
You see each run on the Payment retries page, and set the policy on
its Policy tab, or with PUT /.
When the answer is unclear
Section titled “When the answer is unclear”Each charge first creates its PaymentIntent at Stripe, which moves no
money, and puts it on the invoice with the payment status unknown. Only
then does Hardcount ask Stripe to take the money. So an invoice is unknown
for the second or so its charge takes. Then it is succeeded, failed or
processing.
A charge can end without a clear answer: a timeout, a Stripe server error
or a dropped connection. Hardcount never guesses. If Stripe was already
asked to take the money, the payment status stays unknown. The invoice
already names the payment, so Hardcount can look it up.
- Nothing charges the invoice again until Stripe’s answer is known, so the customer is never charged twice. A charge hold makes sure only one charge runs at a time. It is a 5-minute claim on the invoice. After an unclear answer, the hold stays until its 5 minutes end, or until the payment’s result is recorded, whichever comes first.
- The reconciler finds the answer. It is a check that asks Stripe what
happened to payments Hardcount did not hear back about. It runs with
every billing run: hourly, or every 5 minutes when
APP_ENVislocalor not set. It reads the payment by its ID once the charge hold has ended, usually within about an hour. A Stripe webhook can also settle the payment sooner. - A payment that Stripe was never asked to take is canceled there, so it can never go through. The invoice is then charged again as usual, and the customer gets no payment-failed email.
- An unclear answer to the first step charged nothing. Stripe had not been asked to take the money yet. The invoice keeps its payment status, and the reconciler frees it for the next charge without asking Stripe, on the first billing run at least 15 minutes after the charge began.
While a payment is processing or unknown, Hardcount refuses to void the
invoice, to record a payment on it or to issue a credit note on it, and the
hosted invoice page offers no Pay. So the customer cannot pay twice, and
money cannot arrive on an invoice that no longer asks for it. That includes
the moment a charge is running. It also refuses to write off a processing
payment. An unknown one can be written off once no charge holds the
invoice, 5 minutes after the charge began.
More: Card payment failure handling, every case in detail.
Webhooks
Section titled “Webhooks”| Event | When |
|---|---|
payment. |
A card charge succeeded. invoice. comes with it. |
payment. |
Stripe declined a charge. |
dunning. |
Dunning began on an unpaid invoice. |
dunning. |
Every retry failed, and the policy’s final action was applied, even when that action is to do nothing. |
dunning. |
Dunning ended, for example because the customer paid. |
payment., payment. |
A customer disputed a card payment with their bank, and when Stripe closed the dispute. |
payment. |
A refund was made in Stripe outside Hardcount. |
payment., payment., payment., payment. |
Money arrived that does not fit the invoice. Check it in Stripe. |
More: every event, with an example message: Webhook events.
Next: set it up: Connect Stripe and take card payments.
Stuck, or found a bug? Ask in Discussions · Open an issue