Gift Cards - Flow Diagram

%%{init: { "theme": "base", "themeVariables": { "fontSize": "18px", "background": "transparent", "actorBkg": "#038851", "actorTextColor": "#ffffff", "actorBorder": "#026139", "actorLineColor": "#94a3b8", "signalColor": "#64748b", "signalTextColor": "#059669", "noteBkgColor": "#e6f4ee", "noteTextColor": "#02502f", "noteBorderColor": "#038851", "activationBkgColor": "#c6ebdc", "activationBorderColor": "#026139", "sequenceNumberColor": "#ffffff" }, "sequence": { "useMaxWidth": true, "actorMargin": 70, "width": 150, "height": 60, "boxMargin": 12, "noteMargin": 14, "messageMargin": 50, "diagramMarginX": 20, "diagramMarginY": 20, "actorFontSize": 18, "actorFontWeight": 700, "noteFontSize": 15, "noteFontFamily": "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", "messageFontSize": 16, "messageFontWeight": 700, "noteAlign": "left", "mirrorActors": false } }}%%

sequenceDiagram
    autonumber
    actor Customer
    participant Channel Platform
    participant Deliverect
    participant Gift Card Provider

    Note over Deliverect,Gift Card Provider: 1. Provider registration
    Deliverect->>Gift Card Provider: POST registerProfileURL with account and apiKey
    Gift Card Provider-->>Deliverect: 200 OK with webhook URLs
    Note right of Deliverect: Merchant links provider profile to channelLinkId

    Note over Channel Platform,Deliverect: 2. Discover linked profiles
    Channel Platform->>Deliverect: GET providerProfileLinks
    Deliverect-->>Channel Platform: 200 OK with giftCardProviderProfileLinks

    Note over Customer,Gift Card Provider: 3. Check gift card balance
    Customer->>Channel Platform: Enters gift card and applies it
    Channel Platform->>Deliverect: POST getGiftCardBalance
    Deliverect->>Gift Card Provider: POST getGiftCardBalanceURL
    Gift Card Provider-->>Deliverect: 200 OK with giftCardNumber and amount
    Deliverect-->>Channel Platform: 200 OK with giftCardNumber and amount

    Note over Customer,Gift Card Provider: 4. Apply gift card to basket
    Channel Platform->>Deliverect: POST applyGiftCard
    Deliverect-->>Channel Platform: 200 OK with order payment data

    Note over Customer,Gift Card Provider: 5. Checkout and redeem
    Customer->>Channel Platform: Places the order
    Channel Platform->>Deliverect: POST order with gift card payment
    Deliverect-->>Channel Platform: 200 OK order accepted
    Deliverect->>Gift Card Provider: POST redeemGiftCardURL
    Gift Card Provider-->>Deliverect: 200 OK

    Note over Channel Platform,Gift Card Provider: 6. Cancel reverses redemption optional
    Channel Platform->>Deliverect: Cancel order with gift card payment
    Deliverect->>Gift Card Provider: POST revertRedeemGiftCardURL
    Gift Card Provider-->>Deliverect: 200 OK