Testing
Test scenarios
Make the mock airline and payment provider fail on purpose, so you can test every path of the booking flow.
In test mode the suppliers and the payment provider are mocks. A scenario tells them how to behave for one order, so you can rehearse every failure your integration must handle before real money is involved.
Using a scenario#
Add scenario to the order you create with a test key:
{
"idempotencyKey": "test-price-up-0001",
"scenario": "price_up",
"offer": { "…": "…" },
"passengers": [ "…" ],
"contact": { "…": "…" }
}Without scenario, test orders behave as happy. Scenarios are accepted in test mode only.
Scenarios#
| scenario | What happens | Ends as |
|---|---|---|
happy | Everything works. | issued |
flaky_supplier | Holding seats times out twice (SUPPLIER_TIMEOUT), then succeeds. Shows automatic retries in the timeline. | issued |
price_up | The price re-check returns a higher price; the order waits for your price decision. | issued if accepted, cancelled if declined, expired if unanswered |
sold_out | Seats are gone at the price re-check (SOLD_OUT). | failed |
payment_declined | The provider reports a decline (PAYMENT_DECLINED). Another payment attempt can still succeed before the hold expires. | issued after a successful retry, otherwise expired |
payment_timeout | Nobody pays; the hold expires (PAYMENT_TIMEOUT). Seats and payment hold are released. | expired |
issue_fail | The airline refuses to issue (ISSUE_REJECTED). The payment hold is released and the booking cancelled. | failed |
issue_unknown | Issuing times out (ISSUE_STATUS_UNKNOWN); the result is found by checking the supplier, never by issuing twice. | issued |
notify_fail | The e-mail provider is down. The order is still issued; the timeline records order.attention_needed. | issued |
The table is generated from the engine’s list of scenarios, so it always matches what the API accepts.
What to verify#
| Scenario | Your integration should |
|---|---|
happy |
Show the ticket when the order is issued. |
flaky_supplier |
Do nothing special: retries are automatic. The timeline shows book_seats with 3 attempts and 2 failures. |
price_up |
Notice awaiting_price_confirmation, show live.newPriceMinor, send the traveller’s decision. |
sold_out |
Offer another flight. |
payment_declined |
Let the traveller try again before holdExpiresAt. |
payment_timeout |
Tell the traveller the booking expired; offer to search again. |
issue_fail |
Explain the airline refused; the money was not taken. |
issue_unknown |
Keep waiting: 1fly resolves it by checking the supplier. |
notify_fail |
Nothing: the order is issued; the ticket is in My trips. |
Generating traffic#
POST /v1/dev/simulate (test mode, orders:write) creates realistic orders and plays both the traveller and the payment provider for them, with shorter waiting windows (45 seconds). Use it to fill your dashboard, analytics and request logs:
curl -X POST http://localhost:4000/v1/dev/simulate \
-H "Authorization: Bearer $ONEFLY_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"scenario": "mixed", "count": 25}'scenario is one of the values above or mixed (mostly successes with a realistic tail of every failure); count is 1–50. The response lists the created order ids. Simulated orders count towards your monthly quota.