Auto-capture order payment based on shipping method, with Mechanic.

Mechanic is an automation development platform for Shopify. :)

Auto-capture order payment based on shipping method

by Mechanic Team (team@usemechanic.com)

This task auto-captures payment if the customer has selected a certain shipping method. Useful for expedited order fulfillments.

Runs when an order is created. Configuration includes allowed shipping methods.

15-day free trial – unlimited tasks

Documentation

For expected results, be sure to enable "Manually capture payment for orders" in Shopify, using this guide.

Please note: This task will only capture payment for orders that have the financial status "authorized". You are responsible for ensuring that fulfillment occurs within the order payment's authorization period.

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Events
when an order is created (shopify/orders/create)
Options
allowed shipping methods (required, array)
Script
{% assign order_qualifies = false %}

{% if options.allowed_shipping_methods__required_array contains order.shipping_lines.first.title and order.financial_status == "authorized" %}
  {% assign order_qualifies = true %}
{% endif %}

{% if event.preview or order_qualifies %}
  {
    "action": {
      "type": "shopify",
      "options": [
        "post",
        "/admin/orders/{{ order.id }}/transactions.json",
        { "transaction": { "kind": "capture" } }
      ]
    }
  }
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.