Skip to content

Instantly share code, notes, and snippets.

@paulfioravanti
Last active May 6, 2020 00:33
Show Gist options
  • Save paulfioravanti/1839b52ed14127566df4ccee480ef80e to your computer and use it in GitHub Desktop.
Save paulfioravanti/1839b52ed14127566df4ccee480ef80e to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: "Payliance",
initial: "Programmed",
context: {
retries: 0,
},
states: {
// We done scheduled da transancion
Programmed: {
on: {
PROCESS: "Pending",
EXPIRE: "Expired",
// REJECT: "Rejected",
// NOT_PROCESSABLE: "NotProcessable",
},
},
// Wrong bank data
// NotProcessable: { type: "final" },
// We tried to double charge the same transaction
// Rejected: { type: "final" },
// Time for le charge done expired
Expired: { type: "final" },
// Twas processed by payment processor
Pending: {
on: {
// NOT_FOUND: "InternalError",
INVALIDATED: "Invalid",
PENDING: "Pending",
SENT_TO_BANK: "SentToBank",
// RETURNED: "Returned",
// SETTLED: "Settled",
// LATE_RETURN: "LateReturn",
VOIDED: "Voided",
},
},
InternalError: {
type: "final"
},
Invalid: {
type: "final"
},
SentToBank: {
on: {
NOT_FOUND: "InternalError",
// INVALIDATED: "Invalid",
// PENDING: "Pending",
SENT_TO_BANK: "SentToBank",
RETURNED: "Returned",
SETTLED: "Settled",
// LATE_RETURN: "LateReturn",
VOIDED: "Voided",
},
},
// LateReturn: {
// type: "final"
// },
//
Settled: {
on: {
DISPUTE: "LateReturn",
CLEAR: "Posted",
},
},
// We should not have charged this transaction
Voided: { type: "final" },
// Peeps disputed the transaction after settled
LateReturn: { type: "final" },
// Cleared maybe?
Posted: { type: "final" },
// They dispuated cuz they DQ's
Returned: { type: "final" },
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment