{
  "uiConfig": {
    "edges": [],
    "nodes": [
      {
        "id": "StartAuthorize",
        "position": {
          "x": 50,
          "y": 50
        }
      },
      {
        "id": "checkTransactionType",
        "position": {
          "x": 1400,
          "y": 50
        }
      },
      {
        "id": "authorizeCit",
        "position": {
          "x": 1850,
          "y": 50
        }
      },
      {
        "id": "checkCitResult",
        "position": {
          "x": 2300,
          "y": 50
        }
      },
      {
        "id": "authorizeMit",
        "position": {
          "x": 1850,
          "y": 310
        }
      },
      {
        "id": "checkMitResult",
        "position": {
          "x": 2300,
          "y": 310
        }
      },
      {
        "id": "finalNotification",
        "position": {
          "x": 2750,
          "y": 50
        }
      },
      {
        "id": "checkPaymentMethod",
        "position": {
          "x": 1850,
          "y": 570
        }
      },
      {
        "id": "checkCreateInstrumentSupport",
        "position": {
          "x": 500,
          "y": 50
        }
      },
      {
        "id": "createOrGetInstrument",
        "position": {
          "x": 950,
          "y": 50
        }
      },
      {
        "id": "checkInstrumentResult",
        "position": {
          "x": 1400,
          "y": 310
        }
      },
      {
        "id": "autoAddedNotifyCompleted",
        "position": {
          "x": 1850,
          "y": 830
        }
      },
      {
        "id": "triggerLookup",
        "position": {
          "x": 50,
          "y": 310
        }
      },
      {
        "id": "lookup",
        "position": {
          "x": 500,
          "y": 310
        }
      },
      {
        "id": "triggerCapture",
        "position": {
          "x": 50,
          "y": 570
        }
      },
      {
        "id": "capture",
        "position": {
          "x": 500,
          "y": 570
        }
      },
      {
        "id": "checkCaptureResult",
        "position": {
          "x": 950,
          "y": 310
        }
      },
      {
        "id": "checkCaptureUpdatedResult",
        "position": {
          "x": 950,
          "y": 570
        }
      },
      {
        "id": "autoAddedNotifyUpdated",
        "position": {
          "x": 2750,
          "y": 310
        }
      },
      {
        "id": "triggerCancel",
        "position": {
          "x": 50,
          "y": 830
        }
      },
      {
        "id": "cancel",
        "position": {
          "x": 500,
          "y": 830
        }
      },
      {
        "id": "checkCancelResult",
        "position": {
          "x": 950,
          "y": 830
        }
      },
      {
        "id": "checkCancelUpdatedResult",
        "position": {
          "x": 950,
          "y": 1090
        }
      },
      {
        "id": "triggerRefund",
        "position": {
          "x": 50,
          "y": 1090
        }
      },
      {
        "id": "refund",
        "position": {
          "x": 500,
          "y": 1090
        }
      },
      {
        "id": "checkRefundResult",
        "position": {
          "x": 950,
          "y": 1350
        }
      },
      {
        "id": "checkRefundUpdatedResult",
        "position": {
          "x": 950,
          "y": 1610
        }
      },
      {
        "id": "checkAuthorizePausedReason",
        "position": {
          "x": 2300,
          "y": 570
        }
      },
      {
        "id": "checkAuthorizeUpdatedResult",
        "position": {
          "x": 2300,
          "y": 830
        }
      }
    ],
    "overrideAutoLayout": false,
    "visibleActionStatusesByStepCode": {
      "authorizeCit": [
        "success",
        "declined"
      ],
      "authorizeMit": [
        "success",
        "declined"
      ]
    }
  },
  "steps": [
    {
      "name": "Start Authorize",
      "code": "StartAuthorize",
      "type": "trigger",
      "params": {
        "type": "clientAPI",
        "params": {
          "path": "/authorize",
          "method": "POST"
        },
        "requestMapping": [
          {
            "from": "meta",
            "to": "fraudScore.meta"
          },
          {
            "from": "meta",
            "to": "notify.meta"
          }
        ],
        "responseMapping": [
          {
            "from": "output.name",
            "to": "name"
          },
          {
            "from": "output.executedAt",
            "to": "executedAt"
          },
          {
            "from": "output.actionId",
            "to": "actionId"
          },
          {
            "from": "output.workspaceId",
            "to": "workspaceId"
          },
          {
            "from": "output.links",
            "to": "links"
          }
        ],
        "nextActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "authorizeRequested"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "checkCreateInstrumentSupport"
            }
          }
        ]
      }
    },
    {
      "name": "Transaction type",
      "code": "checkTransactionType",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "MIT rule: Subscription or UnscheduledCardOnFile",
            "condition": {
              "field": "paymentProcessingType",
              "operator": "IS ONE OF",
              "value": [
                "Subscription",
                "UnscheduledCardOnFile"
              ]
            },
            "actions": [
              {
                "type": "addNextStep",
                "params": {
                  "code": "authorizeMit",
                  "mapping": [
                    {
                      "from": "output.success",
                      "to": "success"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "CIT rule: Regular, CardOnFile or MOTO",
            "condition": {
              "field": "paymentProcessingType",
              "operator": "IS ONE OF",
              "value": [
                "Regular",
                "CardOnFile",
                "MOTO"
              ]
            },
            "actions": [
              {
                "type": "addNextStep",
                "params": {
                  "code": "authorizeCit",
                  "mapping": [
                    {
                      "from": "output.success",
                      "to": "success"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "authorizeCit",
              "mapping": [
                {
                  "from": "output.success",
                  "to": "success"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "CIT Authorize",
      "code": "authorizeCit",
      "type": "action",
      "params": {
        "type": "authorize",
        "settings": {
          "threeDSMode": "Default",
          "captureMode": "Instant",
          "instrumentCreationDisabled": true
        },
        "nextActions": {
          "onPaused": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkAuthorizePausedReason"
              }
            }
          ],
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkCitResult"
              }
            }
          ],
          "onUpdated": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkAuthorizeUpdatedResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check CIT result",
      "code": "checkCitResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "finalNotification",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "Declined",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": false
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "finalNotification",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "authorizeFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "finalNotification",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "MIT Authorize",
      "code": "authorizeMit",
      "type": "action",
      "params": {
        "type": "authorize",
        "settings": {
          "threeDSMode": "Skip",
          "captureMode": "Instant",
          "instrumentCreationDisabled": true
        },
        "nextActions": {
          "onPaused": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkAuthorizePausedReason"
              }
            }
          ],
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkMitResult"
              }
            }
          ],
          "onUpdated": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkAuthorizeUpdatedResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check MIT result",
      "code": "checkMitResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "finalNotification",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "Declined",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": false
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "finalNotification",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "authorizeFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "finalNotification",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Send notification",
      "code": "finalNotification",
      "type": "action",
      "params": {
        "type": "notify",
        "settings": {
          "eventType": "executionActionCompleted"
        },
        "nextActions": {}
      }
    },
    {
      "name": "Payment method routing",
      "code": "checkPaymentMethod",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "Card, Apple Pay or Google Pay",
            "condition": {
              "field": "paymentMethodCode",
              "operator": "IS ONE OF",
              "value": [
                "card",
                "applePay",
                "googlePay"
              ]
            },
            "actions": [
              {
                "type": "addNextStep",
                "params": {
                  "code": "checkTransactionType"
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "authorizeFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "finalNotification",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Should Create Instrument",
      "code": "checkCreateInstrumentSupport",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Payment method Supports Instrument",
            "condition": {
              "field": "paymentMethod.supportsInstrument",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addNextStep",
                "params": {
                  "code": "createOrGetInstrument",
                  "mapping": [
                    {
                      "from": "output.authorize.scope",
                      "to": "scope"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentId",
                      "to": "id"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentMethodCode",
                      "to": "paymentMethod"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].storeInstrument",
                      "to": "storeInstrument"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.futureUsage",
                      "to": "futureUsage"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.merchantReference",
                      "to": "merchantReference"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.default",
                      "to": "default"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.displayName",
                      "to": "displayName"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.network",
                      "to": "data.network"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.eci",
                      "to": "data.eci"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.paymentToken",
                      "to": "data.paymentToken"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.encryptedData",
                      "to": "data.encryptedData"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.encryptedDataType",
                      "to": "data.encryptedDataType"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.vaultProviderConfigId",
                      "to": "data.vaultProviderConfigId"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.billingAddress",
                      "to": "data.billingAddress"
                    },
                    {
                      "from": "output.authorize.paymentComposition[0].paymentInstrumentData.qrCode",
                      "to": "data.qrCode"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "checkPaymentMethod"
            }
          }
        ]
      }
    },
    {
      "name": "Create or Get Instrument",
      "code": "createOrGetInstrument",
      "type": "action",
      "params": {
        "type": "createInstrument",
        "nextActions": {
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkInstrumentResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check Instrument Result",
      "code": "checkInstrumentResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addNextStep",
                "params": {
                  "code": "checkPaymentMethod",
                  "mapping": [
                    {
                      "from": "output.id",
                      "to": "paymentComposition[0].paymentInstrumentId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "authorizeFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyCompleted",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Send Action Completed Notification",
      "code": "autoAddedNotifyCompleted",
      "type": "action",
      "params": {
        "type": "notify",
        "settings": {
          "eventType": "executionActionCompleted"
        },
        "nextActions": {}
      }
    },
    {
      "name": "Start Lookup",
      "code": "triggerLookup",
      "type": "trigger",
      "params": {
        "type": "clientAPI",
        "params": {
          "path": "/lookup",
          "method": "POST"
        },
        "nextActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "lookup"
            }
          }
        ]
      }
    },
    {
      "name": "Lookup",
      "code": "lookup",
      "type": "action",
      "params": {
        "type": "lookup",
        "nextActions": {}
      }
    },
    {
      "name": "Start Capture",
      "code": "triggerCapture",
      "type": "trigger",
      "params": {
        "type": "clientAPI",
        "params": {
          "path": "/capture",
          "method": "POST"
        },
        "responseMapping": [
          {
            "from": "output.name",
            "to": "name"
          },
          {
            "from": "output.executedAt",
            "to": "executedAt"
          },
          {
            "from": "output.actionId",
            "to": "actionId"
          },
          {
            "from": "output.workspaceId",
            "to": "workspaceId"
          },
          {
            "from": "output.links",
            "to": "links"
          }
        ],
        "nextActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "capture"
            }
          }
        ]
      }
    },
    {
      "name": "Capture Payment",
      "code": "capture",
      "type": "action",
      "params": {
        "type": "capture",
        "nextActions": {
          "onScheduled": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "captureScheduled"
              }
            }
          ],
          "onUnscheduled": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "captureUnscheduled"
              }
            }
          ],
          "onRequested": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "captureRequested"
              }
            }
          ],
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkCaptureResult"
              }
            }
          ],
          "onUpdated": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkCaptureUpdatedResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check Capture Result",
      "code": "checkCaptureResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "captureSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyCompleted",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "captureFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyCompleted",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Check Capture Updated Result",
      "code": "checkCaptureUpdatedResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Previously Failed, but now Successful",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": true
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": false
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "captureSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "If Previously Successful, but now Failed",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": false
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": true
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "captureFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyUpdated",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Send Action Updated Notification",
      "code": "autoAddedNotifyUpdated",
      "type": "action",
      "params": {
        "type": "notify",
        "settings": {
          "eventType": "executionActionUpdated"
        },
        "nextActions": {}
      }
    },
    {
      "name": "Start Cancel",
      "code": "triggerCancel",
      "type": "trigger",
      "params": {
        "type": "clientAPI",
        "params": {
          "path": "/cancel",
          "method": "POST"
        },
        "responseMapping": [
          {
            "from": "output.name",
            "to": "name"
          },
          {
            "from": "output.executedAt",
            "to": "executedAt"
          },
          {
            "from": "output.actionId",
            "to": "actionId"
          },
          {
            "from": "output.workspaceId",
            "to": "workspaceId"
          },
          {
            "from": "output.links",
            "to": "links"
          }
        ],
        "nextActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "cancel"
            }
          }
        ]
      }
    },
    {
      "name": "Cancel Payment",
      "code": "cancel",
      "type": "action",
      "params": {
        "type": "cancel",
        "nextActions": {
          "onScheduled": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "cancelScheduled"
              }
            }
          ],
          "onUnscheduled": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "cancelUnscheduled"
              }
            }
          ],
          "onRequested": [
            {
              "type": "addWorkflowExecutionStatus",
              "params": {
                "status": "cancelRequested"
              }
            }
          ],
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkCancelResult"
              }
            }
          ],
          "onUpdated": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkCancelUpdatedResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check Cancel Result",
      "code": "checkCancelResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "cancelSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyCompleted",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "cancelFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyCompleted",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Check Cancel Updated Result",
      "code": "checkCancelUpdatedResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Previously Failed, but now Successful",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": true
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": false
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "cancelSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "If Previously Successful, but now Failed",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": false
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": true
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "cancelFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyUpdated",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Start Refund",
      "code": "triggerRefund",
      "type": "trigger",
      "params": {
        "type": "clientAPI",
        "params": {
          "path": "/refund",
          "method": "POST"
        },
        "responseMapping": [
          {
            "from": "output.name",
            "to": "name"
          },
          {
            "from": "output.executedAt",
            "to": "executedAt"
          },
          {
            "from": "output.actionId",
            "to": "actionId"
          },
          {
            "from": "output.workspaceId",
            "to": "workspaceId"
          },
          {
            "from": "output.links",
            "to": "links"
          }
        ],
        "nextActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "refundRequested"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "refund"
            }
          }
        ]
      }
    },
    {
      "name": "Refund Payment",
      "code": "refund",
      "type": "action",
      "params": {
        "type": "refund",
        "nextActions": {
          "onCompleted": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkRefundResult"
              }
            }
          ],
          "onUpdated": [
            {
              "type": "addNextStep",
              "params": {
                "code": "checkRefundUpdatedResult"
              }
            }
          ]
        }
      }
    },
    {
      "name": "Check Refund Result",
      "code": "checkRefundResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Success",
            "condition": {
              "field": "success",
              "operator": "=",
              "value": true
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "refundSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyCompleted",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addWorkflowExecutionStatus",
            "params": {
              "status": "refundFailed"
            }
          },
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyCompleted",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Check Refund Updated Result",
      "code": "checkRefundUpdatedResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Previously Failed, but now Successful",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": true
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": false
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "refundSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "If Previously Successful, but now Failed",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": false
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": true
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "refundFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyUpdated",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "name": "Update SDK status in case 3DS challenge happens",
      "code": "checkAuthorizePausedReason",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "3DS challenge required",
            "condition": {
              "field": "output.reason",
              "operator": "=",
              "value": "actionRequired"
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizePending"
                }
              }
            ]
          }
        ]
      }
    },
    {
      "name": "Check Authorize Updated Result",
      "code": "checkAuthorizeUpdatedResult",
      "type": "condition",
      "params": {
        "rules": [
          {
            "name": "If Previously Failed, but now Successful",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": true
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": false
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeSuccessful"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          },
          {
            "name": "If Previously Successful, but now Failed",
            "condition": {
              "left": {
                "field": "success",
                "operator": "=",
                "value": false
              },
              "operator": "AND",
              "right": {
                "field": "output.previous.results[0].success",
                "operator": "=",
                "value": true
              }
            },
            "actions": [
              {
                "type": "addWorkflowExecutionStatus",
                "params": {
                  "status": "authorizeFailed"
                }
              },
              {
                "type": "addNextStep",
                "params": {
                  "code": "autoAddedNotifyUpdated",
                  "mapping": [
                    {
                      "from": "output.actionId",
                      "to": "actionId"
                    }
                  ]
                }
              }
            ]
          }
        ],
        "defaultActions": [
          {
            "type": "addNextStep",
            "params": {
              "code": "autoAddedNotifyUpdated",
              "mapping": [
                {
                  "from": "output.actionId",
                  "to": "actionId"
                }
              ]
            }
          }
        ]
      }
    }
  ]
}
