Documentation

Shopify Refund Order Line Items and Shipping Fee v2

Refund the full order or specific items, together with shipping fee or a part of it based on line items that are refunded

🚧

In order for this action to work 3 meta object definitions have to be created for the Shopify store.

Inputs

NameTypeDescription
Shopify TokenCredentialsShopify API token
Shopify DomainStringShopify domain
Order IDStringShopify order ID
Line ItemsOptional ListShopify line items to be refunded.
Default: All line items
Refund ReasonStringRefund reason that will be added to the order notes
Only Calculate RefundOptional BooleanWhether to only calculate the refund and not actually perform it.
Default: false
Restock TypeOptional StringRestock type for the line items.
Default: no_restock
Possible values: no_restock, cancel, return
Shipping Refund TypeOptional StringType of refund for the shipping fee.
Default: Depending on the line items
Possible values: full, partial, none
Partial Shipping Refund CriteriaOptional StringCriteria on which to calculate the partial shipping fee refund.
Default: quantity
Possible values: quantity, weight
Update Order NoteOptional BooleanWhether to update the order note with the refund reason.
Default: true
Max Refund AmountOptional NumberMax refund amount for one transaction
Check for Previous RefundsOptional BooleanWhether to check for previous refunds for the order customer. Default: true
Check Universal LimitsOptional BooleanWhether to check for domain wide number of refunds during last hour, 12 hours and 24 hours.
Default: true
Check Universal Amount LimitsOptional BooleanWhether to check amount refunded in the last 24 hours.
Linked to: Check Universal Limits.
Default: false
Check for Fraud LimitsOptional BooleanWhether to check for shipping/billing addresses and card details limits. Default: false
Send Notifications to DG Slack channelOptional BooleanWhether to send notifications to the DG Slack channel if the universal limits were exceeded.
Default: false
Fraud Records LimitOptional NumberLimit for refunds created for address/card number/card name. Linked to: Check for Fraud Limits.
Default: 1
Fraud Addresses LimitOptional NumberLimit for refunds created from different addresses for a specific zip code.
Linked to: Check for Fraud Limits.
Default: 5
Hour LimitOptional NumberHour limit for refunds created.
Linked to: Check Universal Limits.
Default: 10
Twelve Hour LimitOptional NumberTwelve hour limit for refunds created.
Linked to: Check Universal Limits.
Default: 30
Twenty Four Hour LimitOptional NumberTwenty four hour limit for refunds created.
Linked to: Check Universal Limits.
Default: 50
Twenty Four Hour Amount LimitOptional NumberTwenty four hour amount limit for refunds created.
Linked to: Check Universal Amount Limits.
Default: 2000

πŸ‘

Restock Type

How this refund line item affects inventory levels.

no_restock: Refunding these items won't affect inventory.

cancel: The items have not yet been fulfilled. The canceled quantity will be added back to the available count. The number of fulfillable units for this line item will decrease.

return: The items were already delivered but will be returned to the merchant. The returned quantity will be added back to the available count. The number of fulfillable units for this line item will remain unchanged.

πŸ‘

Shipping Refund Type

How the shipping fee refund will be calculated.

full: The shipping fee will be refunded fully.
partial: The shipping fee refund will be calculate based on the quantity or weight of the line items that are being refunded.

none: The shipping fee will not be refunded.

πŸ‘

Partial Shipping Refund Criteria

How the partial shipping fee refund will be calculated.

quantity: The percentage of refundable items quantity divided by the total quantity.

weight: The percentage of refundable items weight divided by the total weight.

πŸ‘

Check for Previous Refunds

Default value: true

When this option is enabled, the action will perform the following logic:

  1. Retrieve the last (max 100) orders for the customer.
  2. Check if any of these orders have a meta field created by DG.
  3. If a meta field with the refund key is found, the order creation process will be stopped.

πŸ‘

Check Universal Limits

Default value: true

When this option is enabled, the action will perform the following logic:

  1. Query meta objects of type $app:refund_replacement_order.
  2. Check the number of filtered meta objects by time against the following limits:
    1. Hour Limit: 10
    2. Twelve Hour Limit: 30
    3. Twenty-Four Hour Limit: 50
  3. If any of these limits are exceeded, the refund process will be stopped.

Additionally, if Check Universal Amount Limits is enabled, the action will check the total amount of money refunded within the twenty-four hour limit against the Twenty Four Hour Amount Limit (default value: 2000). If this amount is exceeded, the refund process will be stopped.

πŸ‘

Check for Fraud Limits

Default value: false

When this option is enabled, the action will perform the following logic:

  1. Search for meta objects of type $app:refund_replacement_address using the shipping address zip code and the billing address zip code. If records are found, the system will check against the following limits:
    1. Fraud Records Limit: 1
    2. Fraud Addresses Limit: 5

The Fraud Addresses Limit is used to check how many distinct address lines are tied to the same zip code. If either of these limits is exceeded, therefund process will be stopped.

  1. Search for meta objects of type $app:refund_replacement_card_details using the card type, the last 4 digits of the card, and the cardholder's name. If records are found, the system will check against the Fraud Records Limit (default value: 1). If this limit is exceeded, the refund process will be stopped.

πŸ‘

Send Notifications to DG Slack channel

Default value: false

When this option is enabled, the action will perform the following logic:

If the universal limits are exceeded, a notification will be sent to the #shopify_r_r_alarms DG Slack channel.

πŸ“˜

Hour Limit, Twelve Hour Limit, Twenty Four Hour Limit, Twenty Four Hour Amount Limit, Fraud Records Limit, Fraud Addresses Limit

These are optional inputs, each of which has a default value. They will be considered only if the inputs that they are linked with are truthful.
Hour Limit: 10
Twelve Hour Limit: 30
Twenty Four Hour Limit: 50
Fraud Records Limit: 1
Fraud Addresses Limit: 5


Outputs

NameTypeDescription
Refund SuccessfulBooleanWhether the refund was created/calculated successfully
Calculate Refund OnlyBooleanWhether to only calculate the refund and not actually process the refund
Blocked by Safety ChecksBooleanWhether the refund was blocked by safety/fraud checks
Refund Metafields CreatedBooleanWhether the refund metafields were created
Refund Metaobject CreatedBooleanWhether the refund metaobject was created
Fraud Prevention Meta Objects CreatedBooleanWhether the fraud prevention addresses/card details meta objects were created
Refund Meta Object UpdatedBooleanWhether the refund meta object was updated after the order was created
Refund DetailsObjectRefund details object returned by Shopify
Refund StringStringRefund amount and currency

πŸ‘

Refund

A refund processes only if all the safety checks are passed and the initial refund meta object is created.


Refund Meta Object Schema

mutation {
  metaobjectDefinitionCreate(
    definition: {
      type: "$app:refund_replacement_order"
      access: { admin: MERCHANT_READ, storefront: NONE }
      fieldDefinitions: [
        { key: "order_id", name: "Order ID", type: "number_integer" }
        { key: "status", name: "Status", type: "single_line_text_field" }
        { key: "completed", name: "Operation Completed?", type: "boolean" }
        { key: "start_date", name: "Date and Time Refund/Replacement Initiated", type: "date_time" }
        { key: "reason", name: "Reason for refund/replacement", type: "single_line_text_field" }
        { key: "amount", name: "Amount refunded/replaced", type: "number_integer" }
        { key: "customer_id", name: "Shopify Customer ID", type: "number_integer" }
        { key: "customer_email", name: "Customer Email", type: "single_line_text_field" }
        { key: "shipping_address_zip", name: "Shipping Address ZIP Code", type: "single_line_text_field" }
        { key: "billing_address_zip", name: "Billing Address ZIP Code", type: "single_line_text_field" }
        { key: "ip_address", name: "Order IP Address", type: "single_line_text_field" }
        { key: "operation_type", name: "Operation Type: Refund or Replacement", type: "single_line_text_field" }
        { key: "type", name: "Type: Full or Partial", type: "single_line_text_field" }
        { key: "shipping_address", name: "Shipping Address", type: "json" }
        { key: "billing_address", name: "Billing Address", type: "json" }
        { key: "line_items", name: "Line Items", type: "json" }
      ]
    }
  ) {
    metaobjectDefinition {
      id
      type
      fieldDefinitions {
        key
        name
        type {
          name
        }
      }
    }
  }
}

Addresses Meta Object Schema

mutation {
  metaobjectDefinitionCreate(
    definition: {
      type: "$app:refund_replacement_address"
      access: { admin: MERCHANT_READ, storefront: NONE }
      fieldDefinitions: [
        { key: "address_list", name: "List of Addresses", type: "json" }
      ]
    }
  ) {
    metaobjectDefinition {
      id
      type
      fieldDefinitions {
        key
        name
        type {
          name
        }
      }
    }
  }
}

Card Details Meta Object Schema

mutation {
  metaobjectDefinitionCreate(
    definition: {
      type: "$app:refund_replacement_card_details"
      access: { admin: MERCHANT_READ, storefront: NONE }
      fieldDefinitions: [
        { key: "count", name: "Number of Operations", type: "json" }
      ]
    }
  ) {
    metaobjectDefinition {
      id
      type
      fieldDefinitions {
        key
        name
        type {
          name
        }
      }
    }
  }
}