Payment Pattern
How to model payment states and transitions — EXECUTE_PRICING, BILL_ID_GENERATION, PAY, and EXPIRE_PAYMENT.
States and events
EXECUTE_PRICINGandBILL_ID_GENERATIONare always paired inbreakingActions(plural) withargs: nullPAY: system-triggered (systemAuthorised: true), fires when payment gateway confirms paymentEXPIRE_PAYMENT: system-triggered (systemAuthorised: true), fires when payment deadline lapses →PAYMENT_EXPIRED(terminal)- Payment can happen at submission (
APPLYendStateOne) or after a processing step
PAYMENT_PENDING endState structure
{
"stateName": "Payment Pending",
"stateNames": null,
"stateCode": "PAYMENT_PENDING",
"breakingAction": null,
"breakingActions": [
{ "actionType": "EXECUTE_PRICING", "args": null },
{ "actionType": "BILL_ID_GENERATION", "args": null }
],
"nonBreakingActions": [{ "actionType": "NOTIFICATION", "args": { "...payment pending notification..." } }],
"nextEvent": null,
"position": null
}EXPIRE_PAYMENT transition
{
"startState": "PAYMENT_PENDING",
"event": "EXPIRE_PAYMENT",
"endStateOne": {
"stateName": "Payment Expired", "stateNames": null, "stateCode": "PAYMENT_EXPIRED",
"breakingAction": null, "breakingActions": null,
"nonBreakingActions": [{ "actionType": "NOTIFICATION", "args": { "...expiry notification..." } }],
"nextEvent": null, "position": null
},
"endStateTwo": null, "endStateCondition": null,
"authorisation": { "authorisedRoles": null, "authorisedUsers": null, "systemAuthorised": true },
"position": null, "eventNames": null, "eventConfigs": null
}PAY transition
{
"startState": "PAYMENT_PENDING",
"event": "PAY",
"endStateOne": {
"stateName": "Paid", "stateNames": null, "stateCode": "PAID",
"breakingAction": null, "breakingActions": null,
"nonBreakingActions": [{ "actionType": "NOTIFICATION", "args": { "...payment confirmed notification..." } }],
"nextEvent": "ASSIGN_OFFICE",
"position": null
},
"endStateTwo": null, "endStateCondition": null,
"authorisation": { "authorisedRoles": null, "authorisedUsers": null, "systemAuthorised": true },
"position": null, "eventNames": null, "eventConfigs": null
}