# Send Your Own Customer Notifications

This page is for platforms that send their customers' payment plan receipts and notices themselves, using the webhooks and objects described in [Webhooks](/developer-guide/webhook) and [Payment Plans](/developer-guide/payment-plans). Each section names the event to listen to and the field that fills each line of the message.

Every request on this page outside the `/platform` routes authenticates with your account's secret key in the `cc-api-key` header, or with a platform key in `cc-api-key` plus the account's id in the `Chaching-Account` header (see [Platforms](/developer-guide/platforms#authenticate)).

## Before You Start

Each webhook names the merchant account it belongs to in `account.id`, and that account's company in `account.company.id`. Use them to pick the merchant's name, address and branding from your own records: the events do not carry them.

Deduplicate on the event `id`. A retried delivery carries the same `id`; `created` is in seconds and two events can share it, so never use `created` to order events or to detect a duplicate. Deliveries can arrive in any order.

The objects below are the same in webhooks and in REST responses: `GET /payment-plans/{id}/installments`, `GET /payment-plans/{id}/payments` and `GET /invoices/{id}` return the keys the events carry.

## Turning Off ChaChing's Emails

`GET /email-settings` and `PATCH /email-settings` read and set `customer_emails_enabled` and `owner_email_copies_enabled`. Both are `true` by default, except on an account a platform creates with `POST /platform/accounts`, where both start `false`.

With `customer_emails_enabled: false`, ChaChing sends no payment plan receipt, no failed-payment notice and no overdue notice for the account, and no owner copy. Invoice emails, payment-link emails and customer portal sign-in links that the merchant or the customer requests are still sent.

The account that turns them off takes over the card-network obligations: a receipt for every installment charge carrying `Payment N of M`, the seller's name and city and state, the card brand and last four digits, and a link that stays available at least 120 days; and a written notice after a declined stored-card charge that leaves the customer at least 7 calendar days to pay another way.

Turn them off only once your own receipts and notices are live.

## Installment and Payment Receipts

On a platform account
Hosted checkout and invoice pages do not work for a platform account (see [Platforms](/developer-guide/platforms#what-does-not-apply-to-a-platform-account)): leave out the `hosted_invoice_url` lines of the tables below and link to your own payment page.

Send a receipt for every installment and every payment ChaChing collects by card. Fill it from the Installment object (`payment_plan.installment_paid`) or the Payment object (`payment_plan.payment_succeeded`):

Fields both events carry:

| Receipt line | Field |
|  --- | --- |
| Merchant name and location | Your records for `account.id` |
| Description | `payment_plan_summary.description` |
| Credit card surcharge | `surcharge_amount`, printed when above `0` |
| Card brand and last four digits | `card.brand`, `card.last4`; print `Card on file` when `card` is `null` and `external` is `false`; `card.brand` is the gateway's card network label, not guaranteed lowercase |
| Transaction type | The word `Purchase` |
| Remaining balance and payments remaining | `payment_plan_summary.remaining_balance`, `payment_plan_summary.installments_remaining` |
| Invoice link | `hosted_invoice_url` |
| Payment recorded (external) | An `external: true` payment: `card` and `payment_method` are `null` and no card was charged. |


From the Installment object:

| Receipt line | Field |
|  --- | --- |
| `Payment N of M` | `sequence` and `payment_plan_summary.installment_count`; `sequence` `0` is the down payment |
| Amount and currency | `amount_paid` and `payment_plan_summary.currency` |
| Total charged | `amount_charged` |
| Date | `paid_at` |


From `payment_plan.payment_succeeded`:

| Receipt line | Field |
|  --- | --- |
| `Payment N of M` | `allocations[].sequence` and `payment_plan_summary.installment_count` |
| Amount and currency | `amount` and `payment_plan_summary.currency` |
| Total charged | `amount_charged` |
| Date | `created` |


`amount_charged` can exceed `amount` plus `surcharge_amount`; the difference is not itemized.

Send one receipt for each `payment_plan.payment_succeeded`: its `allocations` list every installment, principal and refunded amount the payment paid, each with its own `hosted_invoice_url`. Send one receipt for each `payment_plan.installment_paid` whose installment `id` is not listed in the `allocations` of a `payment_plan.payment_succeeded` of the same plan. For a payment recorded with `POST /payment-plans/{id}/payments`, ChaChing sends its `payment_plan.installment_paid` events before its `payment_plan.payment_succeeded`; for every other payment (an automatic charge, a down payment, a terminal deposit, an invoice payment, a charge of a new card) the two can be sent in either order.

Deliveries can arrive out of order after retries, so an `installment_paid` can reach you before the `payment_succeeded` that lists it. Choose one rule for the whole integration:

- **One receipt per payment.** Send the receipt on `payment_plan.payment_succeeded`, and do not send a separate receipt for an `installment_paid` whose installment is listed in that payment's `allocations`. Before you treat an `installment_paid` as standalone, check whether a `payment_succeeded` of the same plan that lists it has already arrived, and otherwise wait for one. Wait up to 70 minutes plus the retry window (about 2 hours in total), or until `payment_plan.payment_succeeded` arrives. Send the standalone receipt when none arrives.
- **One receipt per installment.** Send one receipt for each `payment_plan.installment_paid` and ignore `payment_plan.payment_succeeded` for receipts.


The card networks set what a receipt for an installment must carry. The receipt ChaChing sends meets these obligations, and a receipt you send in its place has to meet them too, as set out in the Visa Core Rules and Visa Product and Service Rules (Table 5-33 and Table 5-34 on receipt content, and the electronic receipt rules of section 5.9.1.2) and in Visa Business News AI09536:

- the installment sequence number, such as `Payment 2 of 4`;
- the merchant name and location;
- the description of the purchase;
- the amount with its currency;
- the total charged, including the credit card surcharge;
- the date;
- the card brand and the last four digits of the card;
- the transaction type;
- a direct link to the invoice.


## Failed Installment Notice

`payment_plan.installment_failed` is sent for each declined automatic attempt, retries included. Each declined attempt also sends `payment_plan.payment_failed` with the Payment object (`status` `declined`, `failure_code`, `failure_message`), which carries no installment number, pay link or retry date: fill the notice from `payment_plan.installment_failed` and send one notice per attempt. A `payment_plan.payment_failed` whose `status` is `not_attempted` reports an attempt your processor was never reached for, or a terminal sale that collected nothing for the plan without a decline: it is not a decline, and ChaChing sends the customer no failed-payment notice for it. Fill the notice from the Installment object:

| Notice line | Field |
|  --- | --- |
| Installment number | `sequence` and `payment_plan_summary.installment_count` |
| Amount | `amount` |
| Description | `payment_plan_summary.description` |
| Decline reason | `failure_message` and `failure_code` |
| Next automatic retry | `next_payment_attempt` |
| Pay link | `hosted_invoice_url` |
| Card | `card` |
| First decline | `first_failed_at` |


Card network rules give the customer at least 7 calendar days from the first declined attempt on an installment to pay it with another payment method. `first_failed_at` is that first declined attempt, in Unix seconds; it does not change on later retries.

`first_failed_at` is the time ChaChing recorded the first confirmed decline. It is `null` for an installment whose only declines predate this field.

`failure_code` and `failure_message` are `null` when the most recent attempt was not declined.

## Late-Payment and Failed-Payment Outcome Notices

`payment_plan.past_due` and `payment_plan.defaulted` carry the Payment Plan object, which has no payment link. Read the plan's installments with `GET /payment-plans/{id}/installments` and link the installment whose `status` is `failed` to your own payment page.

## Plan Paid in Full

`payment_plan.completed` carries the Payment Plan object with `status` `paid_off`. For a payment recorded with `POST /payment-plans/{id}/payments` it is sent after that payment's `payment_plan.installment_paid` and `payment_plan.payment_succeeded`; for any other payment it and the payment's `payment_plan.payment_succeeded` can be sent in either order, and a plan completed by forgiving its last refunded amount sends it with no payment event. Use it to send the paid-in-full notice, and the receipt events above for the last payment's receipt.

## When ChaChing Sends These Events

ChaChing sends `payment_plan.installment_paid` and `payment_plan.payment_succeeded` once the credit card surcharge of the charge is known, so `surcharge_amount` and `amount_charged` are final when the event arrives. When the surcharge cannot be read within an hour, ChaChing sends the event with `surcharge_amount` `0` and `surcharge_status` `unavailable`; the exact amount charged is then the one shown for that transaction in your Dejavoo (iPOSpays) account. Amounts are in cents of US dollars, the only currency.

For a payment recorded with `POST /payment-plans/{id}/payments` that reaches the unbilled part of the plan, ChaChing sends `payment_plan.payment_succeeded` after it rebuilds the plan's remaining schedule, so `remaining_balance`, `installments_remaining` and `payment_plan_summary` match the response of that request.

ChaChing produces each event once; a delivery can arrive more than once. Deduplicate on `id`.

See [Webhooks](/developer-guide/webhook) for the envelope, the retry policy and the signature, and [Payment Plans](/developer-guide/payment-plans) for the plan lifecycle and the surcharge rules.