Cross-Provider Workflow

Shopify Order Cancellation to Stripe Refund to SendGrid Notice

Version 1.0.0

Cancel a Shopify order, refund the Stripe payment, then email the customer with SendGrid.

1 workflow 3 source APIs 3 providers
View Spec View on GitHub ArazzoWorkflowsCross-Provider

Providers Orchestrated

shopify stripe sendgrid

Workflows

cancel-refund-and-notify
Cancel a Shopify order, refund the Stripe payment, and email the customer.
Cancels a Shopify order, refunds the original Stripe payment intent, then emails the customer a cancellation-and-refund notice via SendGrid.
3 steps inputs: customerEmail, orderId, paymentIntentId outputs: emailStatus, refundId
1
cancel-order
$sourceDescriptions.shopifyApi.cancelOrder
Cancel the Shopify order.
2
refund-payment
$sourceDescriptions.stripeApi.PostRefunds
Refund the original Stripe payment intent.
3
email-notice
$sourceDescriptions.sendgridApi.SendMail
Email the customer a cancellation-and-refund notice via SendGrid.

Source API Descriptions

Arazzo Workflow Specification

shop-cancel-order-refund-email-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Shopify Order Cancellation to Stripe Refund to SendGrid Notice
  summary: Cancel a Shopify order, refund the Stripe payment, then email the customer with SendGrid.
  description: >-
    A cancellation workflow that cancels a Shopify order, refunds the associated
    Stripe payment, and emails the customer a cancellation-and-refund notice
    through SendGrid. Demonstrates coordinating a commerce platform's
    cancellation flow, a payment provider's refund, and an email provider.
  version: 1.0.0
sourceDescriptions:
  - name: shopifyApi
    url: https://raw.githubusercontent.com/api-evangelist/shopify/refs/heads/main/openapi/shopify-admin-rest-api-openapi.yml
    type: openapi
  - name: stripeApi
    url: https://raw.githubusercontent.com/api-evangelist/stripe/refs/heads/main/openapi/stripe-refunds-api-openapi.yml
    type: openapi
  - name: sendgridApi
    url: https://raw.githubusercontent.com/api-evangelist/sendgrid/refs/heads/main/openapi/tsg_mail_v3.yaml
    type: openapi
workflows:
  - workflowId: cancel-refund-and-notify
    summary: Cancel a Shopify order, refund the Stripe payment, and email the customer.
    description: >-
      Cancels a Shopify order, refunds the original Stripe payment intent, then
      emails the customer a cancellation-and-refund notice via SendGrid.
    inputs:
      type: object
      properties:
        orderId:
          type: string
        paymentIntentId:
          type: string
        customerEmail:
          type: string
    steps:
      - stepId: cancel-order
        description: Cancel the Shopify order.
        operationId: $sourceDescriptions.shopifyApi.cancelOrder
        parameters:
          - name: order_id
            in: path
            value: $inputs.orderId
        requestBody:
          contentType: application/json
          payload:
            reason: customer
            email: false
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          cancelledAt: $response.body#/order/cancelled_at
      - stepId: refund-payment
        description: Refund the original Stripe payment intent.
        operationId: $sourceDescriptions.stripeApi.PostRefunds
        requestBody:
          contentType: application/x-www-form-urlencoded
          payload:
            payment_intent: $inputs.paymentIntentId
        successCriteria:
          - condition: $statusCode == 200
          - condition: $response.body#/status == "succeeded"
        outputs:
          refundId: $response.body#/id
          refundStatus: $response.body#/status
      - stepId: email-notice
        description: Email the customer a cancellation-and-refund notice via SendGrid.
        operationId: $sourceDescriptions.sendgridApi.SendMail
        requestBody:
          contentType: application/json
          payload:
            personalizations:
              - to:
                  - email: $inputs.customerEmail
                subject: Your order was cancelled and refunded
            from:
              email: [email protected]
            content:
              - type: text/plain
                value: Your order has been cancelled and your refund is on the way.
        successCriteria:
          - condition: $statusCode == 202
        outputs:
          emailStatus: $statusCode
    outputs:
      refundId: $steps.refund-payment.outputs.refundId
      emailStatus: $steps.email-notice.outputs.emailStatus