Skip to content

pos-refund-shortfall ​

Method: POST
Path: /pos/shipping/shipments/{order_number}/refund-shortfall

Tags: Shipments

Summary ​

Refund shortfall

Description ​

Refunds items of an order's unscheduled shipment that won't be shipped: the shortfall moves to a shipment of its own and is refunded by the original payment or by bank transfer, never beyond what the order's payments have left. Fails with a 409, changing nothing, while refunds are briefly unavailable or the order's payment is held for an admin's review. A refund of a cash or other offline payment in the original mode is manual: done at once when the store marks that payment method paid, else pending until an admin marks it paid or forfeits it.

Pos SDK Usage ​

SDK Method: pos.refundShortfall()

Example:

typescript
const { data, error } = await pos.refundShortfall(
  { order_number: "ORD-2024-001234" },
  {
    items: [
      {
        product_id: "01H9XYZ12345ABCDE",
        variant_id: null,
        quantity: 2,
        free_quantity: 0
      }
    ],
    payment_method: "original-payment-mode"
  }
);

if (error) {
  console.error("Failed to process refund:", error.message);
} else {
  console.log("Refund processed:", data.message);
  console.log("Success:", data.success);
}

// Refund to bank transfer
const { data: bankData, error: bankError } = await pos.refundShortfall(
  { order_number: "ORD-2024-001234" },
  {
    items: [{ product_id: "01H9XYZ12345ABCDE", variant_id: null, quantity: 1 }],
    payment_method: "bank-transfer",
    bank_account_id: "BANK_ACC_123"
  }
);

TypeScript Definition ​

typescript
"pos-refund-shortfall": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description Order Number */
                order_number: string;
            };
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": {
                    items: {
                        product_id: string;
                        /** @description The unique identifier of the product variant. Use `null` if the product has no variants. */
                        variant_id: string | null;
                        quantity: number;
                        /** @default 0 */
                        free_quantity?: number;
                    }[];
                    /** @constant */
                    payment_method: "original-payment-mode";
                    /** @description The customer’s verified outbound bank account. Needed when the order has a paid bank-transfer payment: its refund then goes by bank transfer even though the original mode was requested. */
                    bank_account_id?: string;
                } | {
                    items: {
                        product_id: string;
                        /** @description The unique identifier of the product variant. Use `null` if the product has no variants. */
                        variant_id: string | null;
                        quantity: number;
                        /** @default 0 */
                        free_quantity?: number;
                    }[];
                    /** @constant */
                    payment_method: "bank-transfer";
                    /** @description The customer’s verified outbound bank account to refund to. */
                    bank_account_id: string;
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                    };
                };
            };
            400: components["responses"]["AdminBadRequest"];
            401: components["responses"]["AdminUnauthorized"];
            403: components["responses"]["Forbidden"];
            404: components["responses"]["NotFound"];
            /** @description The shortfall can't be refunded at the moment. Nothing is changed. */
            409: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /**
                         * @example A shortfall refund waits for the payment ledger update to finish; try again shortly
                         * @example The order's payment is held for an admin to resolve; it cannot be refunded until then.
                         */
                        message: string;
                        /** @default false */
                        success: boolean;
                    };
                };
            };
            500: components["responses"]["AdminInternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["responses"]["AdminBadRequest"]AdminBadRequest
components["responses"]["AdminUnauthorized"]AdminUnauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["NotFound"]NotFound
components["responses"]["AdminInternalServerError"]AdminInternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

Parameters ​

  • order_number (path): Order Number

Request Body ​

Content Types: application/json

Responses ​

200 ​

OK

400 ​

401 ​

403 ​

Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.

404 ​

Requested resource not found

409 ​

The shortfall can't be refunded at the moment. Nothing is changed.

500 ​

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "operationId": "pos-refund-shortfall",
  "summary": "Refund shortfall",
  "description": "Refunds items of an order's unscheduled shipment that won't be shipped: the shortfall moves to a shipment of its own and is refunded by the original payment or by bank transfer, never beyond what the order's payments have left. Fails with a 409, changing nothing, while refunds are briefly unavailable or the order's payment is held for an admin's review. A refund of a cash or other offline payment in the original mode is `manual`: done at once when the store marks that payment method paid, else `pending` until an admin marks it paid or forfeits it.",
  "parameters": [
    {
      "name": "order_number",
      "in": "path",
      "description": "Order Number",
      "required": true,
      "schema": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9_-]{1,128}$"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "title": "RefundShortfallToOriginalPaymentMode",
              "type": "object",
              "properties": {
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "product_id",
                      "variant_id",
                      "quantity"
                    ],
                    "properties": {
                      "product_id": {
                        "type": "string"
                      },
                      "variant_id": {
                        "description": "The unique identifier of the product variant. Use `null` if the product has no variants.",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "quantity": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "free_quantity": {
                        "type": "integer",
                        "default": 0,
                        "minimum": 0
                      }
                    },
                    "description": "Supply `quantity` or `free_quantity` of at least 1."
                  }
                },
                "payment_method": {
                  "type": "string",
                  "const": "original-payment-mode"
                },
                "bank_account_id": {
                  "description": "The customer’s verified outbound bank account. Needed when the order has a paid bank-transfer payment: its refund then goes by bank transfer even though the original mode was requested.",
                  "type": "string"
                }
              },
              "required": [
                "items",
                "payment_method"
              ]
            },
            {
              "title": "RefundShortfallByBankTransfer",
              "type": "object",
              "properties": {
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "product_id",
                      "variant_id",
                      "quantity"
                    ],
                    "properties": {
                      "product_id": {
                        "type": "string"
                      },
                      "variant_id": {
                        "description": "The unique identifier of the product variant. Use `null` if the product has no variants.",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "quantity": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "free_quantity": {
                        "type": "integer",
                        "default": 0,
                        "minimum": 0
                      }
                    },
                    "description": "Supply `quantity` or `free_quantity` of at least 1."
                  }
                },
                "payment_method": {
                  "type": "string",
                  "const": "bank-transfer"
                },
                "bank_account_id": {
                  "description": "The customer’s verified outbound bank account to refund to.",
                  "type": "string"
                }
              },
              "required": [
                "items",
                "payment_method",
                "bank_account_id"
              ]
            }
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              }
            },
            "required": [
              "message",
              "success"
            ]
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/AdminBadRequest"
    },
    "401": {
      "$ref": "#/components/responses/AdminUnauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    },
    "409": {
      "description": "The shortfall can't be refunded at the moment. Nothing is changed.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "examples": [
                  "A shortfall refund waits for the payment ledger update to finish; try again shortly",
                  "The order's payment is held for an admin to resolve; it cannot be refunded until then."
                ]
              },
              "success": {
                "type": "boolean",
                "default": false
              }
            },
            "required": [
              "message",
              "success"
            ]
          }
        }
      }
    },
    "500": {
      "$ref": "#/components/responses/AdminInternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/admin-pos/operations/pos-refund-shortfall"
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "tags": [
    "Shipments"
  ],
  "x-speakeasy-group": "pos"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: