Skip to main content
GET
/
v2
/
orders
/
{id}

Get Order

Retrieve information about an order, including payment status, customer details, and line items. Orders are created when a payment link is successfully paid.

Authentication

Authorization: Bearer glm_test_YOUR_API_KEY

Path Parameters

ParameterTypeRequiredDescription
idstringYesOrder ID (e.g., ord_abc123xyz)

Request

GET /v2/orders/{id}

Response

{
  "id": "ord_abc123xyz",
  "order_number": "ORD-2025-001234",
  "status": "completed",
  "payment_status": "captured",
  "merchant_id": "mch_xyz789",
  "merchant_site_id": "site_abc123",
  "test_mode": false,
  "customer": {
    "email": "jane@example.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "phone": "+1-555-123-4567",
    "shipping_address": {
      "address_line_1": "123 Main St",
      "address_line_2": "Apt 4B",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US"
    },
    "billing_address": {
      "address_line_1": "123 Main St",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US"
    }
  },
  "line_items": [
    {
      "id": "li_123",
      "product_id": 12345,
      "merchant_product_id": "PROD-001",
      "name": "Digital Thermometer",
      "quantity": 1,
      "price_cents": 2995,
      "is_hsa_eligible": true,
      "eligibility_type": "auto_substantiation"
    }
  ],
  "amounts": {
    "subtotal_cents": 2995,
    "hsa_fsa_amount_cents": 2995,
    "regular_amount_cents": 0,
    "shipping_cents": 995,
    "tax_cents": 245,
    "discount_cents": 0,
    "total_cents": 4235
  },
  "payment": {
    "payment_id": "pay_xyz789",
    "payment_method": "hsa_fsa_card",
    "last4": "1111",
    "brand": "visa",
    "captured_at": "2025-10-18T15:30:00Z"
  },
  "metadata": {
    "order_number": "ORDER-12345",
    "platform": "SHOPIFY"
  },
  "created_at": "2025-10-18T15:00:00Z",
  "completed_at": "2025-10-18T15:30:00Z",
  "status_history": [
    {
      "status": "pending",
      "timestamp": "2025-10-18T15:00:00Z",
      "reason": "Order created"
    },
    {
      "status": "processing",
      "timestamp": "2025-10-18T15:01:00Z",
      "reason": "Payment processing"
    },
    {
      "status": "completed",
      "timestamp": "2025-10-18T15:30:00Z",
      "reason": "Payment captured"
    }
  ]
}

Response Fields

See Order Object for complete field descriptions.

Examples

Basic Retrieval

curl https://api.withgale.com/v2/orders/ord_abc123xyz \
  -H "Authorization: Bearer glm_test_YOUR_API_KEY"

Check Order Status

const getOrderStatus = async (orderId) => {
  const response = await fetch(
    `https://api.withgale.com/v2/orders/${orderId}`,
    {
      headers: {
        'Authorization': `Bearer ${process.env.GALE_API_KEY}`
      }
    }
  );

  const order = await response.json();

  return {
    orderNumber: order.order_number,
    status: order.status,
    paymentStatus: order.payment_status,
    total: order.amounts.total_cents / 100,
    completedAt: order.completed_at
  };
};

Fulfillment Check

const canFulfillOrder = async (orderId) => {
  const order = await getOrder(orderId);

  // Only fulfill completed orders with captured payment
  const canFulfill =
    order.status === 'completed' &&
    order.payment_status === 'captured';

  return {
    canFulfill,
    order,
    reason: !canFulfill
      ? `Order ${order.status}, payment ${order.payment_status}`
      : null
  };
};

Extract Shipping Information

const getShippingInfo = async (orderId) => {
  const order = await getOrder(orderId);

  return {
    customerName: `${order.customer.first_name} ${order.customer.last_name}`,
    email: order.customer.email,
    phone: order.customer.phone,
    address: order.customer.shipping_address,
    items: order.line_items.map(item => ({
      name: item.name,
      quantity: item.quantity,
      sku: item.merchant_product_id
    }))
  };
};

Order Status

StatusDescription
pendingOrder created, awaiting payment
processingPayment being processed
completedPayment successful, order complete
failedPayment failed
cancelledOrder cancelled

Payment Status

StatusDescription
pendingPayment not yet attempted
authorizedPayment authorized (not captured)
capturedPayment captured successfully
failedPayment failed
refundedPayment refunded (full or partial)
disputedPayment disputed/chargebacked

Use Cases

Order Fulfillment Workflow

// Complete fulfillment workflow
const fulfillOrder = async (orderId) => {
  const order = await getOrder(orderId);

  // Validate order is ready
  if (order.status !== 'completed') {
    throw new Error('Order not completed');
  }

  if (order.payment_status !== 'captured') {
    throw new Error('Payment not captured');
  }

  // Create shipment
  const shipment = await createShipment({
    orderId: order.id,
    address: order.customer.shipping_address,
    items: order.line_items
  });

  // Update order metadata
  await updateOrderMetadata(order.id, {
    fulfillment_status: 'shipped',
    tracking_number: shipment.tracking_number,
    shipped_at: new Date().toISOString()
  });

  // Notify customer
  await sendEmail({
    to: order.customer.email,
    subject: `Order ${order.order_number} Shipped`,
    body: `Your order has shipped! Tracking: ${shipment.tracking_number}`
  });

  return shipment;
};

Customer Service Portal

// Display order in customer portal
const renderOrderDetails = async (orderId) => {
  const order = await getOrder(orderId);

  return {
    orderNumber: order.order_number,
    status: order.status,
    placedAt: order.created_at,
    items: order.line_items.map(item => ({
      name: item.name,
      quantity: item.quantity,
      price: `$${item.price_cents / 100}`,
      hsaEligible: item.is_hsa_eligible
    })),
    totals: {
      subtotal: `$${order.amounts.subtotal_cents / 100}`,
      shipping: `$${order.amounts.shipping_cents / 100}`,
      tax: `$${order.amounts.tax_cents / 100}`,
      total: `$${order.amounts.total_cents / 100}`
    },
    payment: {
      method: order.payment.payment_method,
      last4: order.payment.last4,
      brand: order.payment.brand
    }
  };
};

HSA/FSA Amount Tracking

// Calculate total HSA/FSA sales
const getHSARevenue = async (orderIds) => {
  let totalHSA = 0;
  let totalRegular = 0;

  for (const orderId of orderIds) {
    const order = await getOrder(orderId);

    if (order.status === 'completed') {
      totalHSA += order.amounts.hsa_fsa_amount_cents;
      totalRegular += order.amounts.regular_amount_cents;
    }
  }

  return {
    hsaAmount: totalHSA / 100,
    regularAmount: totalRegular / 100,
    totalAmount: (totalHSA + totalRegular) / 100,
    hsaPercentage: (totalHSA / (totalHSA + totalRegular)) * 100
  };
};

Refund Eligibility Check

const canRefundOrder = async (orderId) => {
  const order = await getOrder(orderId);

  // Can only refund captured payments
  if (order.payment_status !== 'captured') {
    return {
      eligible: false,
      reason: 'Payment not captured'
    };
  }

  // Check if already refunded
  if (order.payment_status === 'refunded') {
    return {
      eligible: false,
      reason: 'Already refunded'
    };
  }

  // Check order age (example: 90 day refund window)
  const orderAge = Date.now() - new Date(order.created_at).getTime();
  const maxAge = 90 * 24 * 60 * 60 * 1000; // 90 days

  if (orderAge > maxAge) {
    return {
      eligible: false,
      reason: 'Order too old for refund'
    };
  }

  return {
    eligible: true,
    maxRefundAmount: order.amounts.total_cents
  };
};

Errors

Status CodeError CodeDescription
401unauthorizedInvalid or missing API key
404not_foundOrder not found
429rate_limit_exceededToo many requests
Example error:
{
  "error": {
    "code": "not_found",
    "message": "Order not found",
    "param": "id"
  }
}

Best Practices

Check Payment Status

Verify payment_status === 'captured' before fulfilling

Use Webhooks

Don’t poll this endpoint. Use webhooks for order updates.

Validate Before Actions

Always check order status before refunds or fulfillment

Store Order IDs

Link orders to your internal system via metadata