In order to understand how to set up test cases in the system and enforce their behavior, you will need to think about an account lifecycle as a series of events that occur; starting with the moment they’re onboarded. Events can range from human activity — such as making a payment, to automatic activity — such as a due date passing by.

Our testing framework involves:

  1. Enqueuing all of the events from your test case
  2. Running through the events in order
  3. Querying the outcome to make sure it is what you expect.

<aside> 💡 Normally, Canopy’s system processes events as soon as they happen. This creates challenges in simulating historical activity for an account.

For example, normally, if you are trying to set up the system with backdated payments after each month, as soon as you backdate the account by five months, the system will immediately assume you’ve been late for five straight payments and generate late fees.

To test without this risk, we use migration mode. Migration mode asks the system to wait until you’ve loaded in all of your historical activity before it starts to process it.


  1. Set the product in migration mode

PUT /products/{product_id}/migration_mode

  "migration_mode": true
  1. Onboard a borrower as normal

POST /customers

POST /accounts

-- using the configs from above, with one difference.
For the account payload, **backdate** the `effective_at` for the account to the historical date of your simulation
  1. Simulate repayment activity

POST /accounts/{account_id}/line_items/payments/payment_record

  "line_item_id": "<some ID for the payment>",
  "original_amount_cents": 3000, -- payment amount in cents
  "line_item_status": "VALID",
  "effective_at": "2020-07-20T09:11:28+00:00", -- date you expect the payment to occur