Skip to content

Instantly share code, notes, and snippets.

@Uter1007
Created January 17, 2021 19:09
Show Gist options
  • Save Uter1007/2d0b75a34099e5a79b1f5f91e968bf76 to your computer and use it in GitHub Desktop.
Save Uter1007/2d0b75a34099e5a79b1f5f91e968bf76 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
key: 'order',
initial: 'created',
context: {},
states: {
created: {
on: {
INIT_BY_ADMIN: 'pending.admin',
INIT_BY_BTCPAY: 'pending.btcpay',
INIT_BY_PAYPAL: 'pending.paypal',
INIT_BY_DEPOSIT: 'pending.deposit',
INIT_BY_PAYFORWARD: 'pending.payforward',
ERROR: 'failed.error'
},
},
pending: {
on: {
EXPIRED: 'expired',
PAID: 'paid.completed',
OVERPAID: 'paid.overpaid',
RESOLVE_MANUALLY: 'paid.completed',
UNDERPAID: 'partialpaid.underpaid',
ERROR: 'failed.error'
},
states: {
btcpay: {},
paypal: {},
admin: {},
payforward: {},
deposit: {},
}
},
paid: {
states: {
completed: {},
overpaid: {}
},
on: {
FINISH: 'approved',
ERROR: 'failed.error'
}
},
partialpaid: {
states: {
underpaid: {}
},
on: {
RESOLVE_MANUALLY: 'paid.completed',
ERROR: 'failed.error'
}
},
expired: {
type: 'final',
on: {
RESOLVE_MANUALLY: 'paid.completed',
ERROR: 'failed.error'
}
},
failed: {
states: {
canceled: {},
error: {},
},
on: {
RESOLVE_MANUALLY: 'paid.completed'
}
},
approved: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment