Skip to content

Instantly share code, notes, and snippets.

@joemocha
Created September 13, 2019 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemocha/45f4fd12ab25884015a21e15eab5a56f to your computer and use it in GitHub Desktop.
Save joemocha/45f4fd12ab25884015a21e15eab5a56f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const orderStateMachine = Machine({
id: 'state',
initial: 'CREATED',
states: {
CREATED: {
on: {
AUTHORIZE: 'AUTHORIZED',
PAYMENT_FAIL: 'PAYMENT_FAILED',
},
},
AUTHORIZED: {
on: {
FULFILL: 'FULFILLED',
CANCEL: 'CANCELLED',
},
},
FULFILLED: {
on: {
PICK_UP: 'PICKED_UP',
FULL_REFUND: 'FULLY_REFUNDED',
NOT_PICKED_UP: 'NOT_PICKED_UP',
},
},
PICKED_UP: {
on: {
TIP: 'COMPLETED',
CANCEL: 'CANCELLED',
PARTIAL_REFUND: 'PARTIAL_REFUNDED',
},
},
COMPLETED: {
on: {
FULL_REFUND: 'FULLY_REFUNDED',
PARTIAL_REFUND: 'PARTIAL_REFUNDED',
},
},
CANCELLED: {
on: {
FULL_REFUND: 'FULLY_REFUNDED',
PARTIAL_REFUND: 'PARTIAL_REFUNDED',
},
},
FULLY_REFUNDED: {
type: 'final',
},
PAYMENT_FAILED: {
type: 'final',
},
PARTIAL_REFUNDED: {
on: {
TIP: 'COMPLETED',
FULL_REFUND: 'FULLY_REFUNDED',
},
},
NOT_PICKED_UP: {
type: 'final',
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment