openapi: 3.1.0
info:
  title: Gift Card Requested Webhook
  version: 1.0.0
  description: |
    If you are using a third party gift card provider, this webhook is triggered when a
    return with a store credit outcome is processed. This webhook is also triggered if
    you have configured Loop to automatically create a gift card when a new exchange
    item is out of stock.

    | Request Header   | Description               |
    | ---------------- | ------------------------- |
    | X-Loop-Signature | Hashed Webhook Secret Key |

    The X-Loop-Signature is a base64, HMAC hash of body payload using the Webhook Secret provided by Loop.

    Note: Before attempting to create your hash of the POST request body, make sure
    slashes have been escaped & newlines have been removed from the JSON.
webhooks:
  GiftCardRequested:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GiftCardRequested'
      responses:
        '200':
          description: Return a 200 status to indicate that the data was received successfully
components:
  schemas:
    GiftCardRequested:
      properties:
        topic:
          type: string
          description: Webhook type
          examples:
            - "giftcard"
        trigger:
          type: string
          description: Event that triggered the webhook
          examples:
            - "giftcard.requested"
        id:
          type:
            - integer
            - "null"
          description: Loop gift card ID, `null` in the case of auto out-of-stock gift cards
          examples:
            - 12345
        total_credit_issued:
          type: string
          description: Total credit issued
          examples:
            - "23.50"
        gift_card_subtotal:
          type: string
          description: Gift card value minus taxes and bonus
          examples:
            - "25.00"
        gift_card_tax:
          type: string
          description: Gift card tax applied, "0.00" if no taxes applied
          examples:
            - "0.50"
        gift_card_bonus_credit:
          type: string
          description: Gift card bonus credit applied, "0.00" if no bonus applied
          examples:
            - "1.00"
        currency:
          type: string
          description: Currency of the gift card values
          examples:
            - "USD"
        return_id:
          type: integer
          description: Loop return ID
          examples:
            - 23456
        email:
          type: string
          format: email
          description: Customer email address
          examples:
            - "eliza@example.com"
        first_name:
          type: string
          description: Customer first name
          examples:
            - "Eliza"
        last_name:
          type: string
          description: Customer last name
          examples:
            - "Strawberry"
        external_order_id:
          type: integer
          description: External order ID
          examples:
            - 1234567890
        external_order_name:
          type: string
          description: External order name
          examples:
            - "#2234"
        external_order_number:
          type:
            - integer
            - "null"
          description: External order number
          examples:
            - 1234
        presentment:
          type: object
          description: Gift card credit values reported in the customer-facing (presentment) currency.
          properties:
            total_credit_issued:
              type: string
              description: Total credit issued in the presentment currency
              examples:
                - "23.50"
            gift_card_subtotal:
              type: string
              description: Gift card value minus taxes and bonus, in the presentment currency
              examples:
                - "25.00"
            gift_card_tax:
              type: string
              description: Gift card tax applied in the presentment currency, "0.00" if none
              examples:
                - "0.50"
            gift_card_bonus_credit:
              type: string
              description: Gift card bonus credit applied in the presentment currency, "0.00" if none
              examples:
                - "1.00"
            currency:
              type: string
              description: Presentment currency of the gift card values
              examples:
                - "CAD"
