Skip to content

create-order-payment-request ​

Method: POST
Path: /orders/{order_number}/payments

Tags: Order payments

Summary ​

Create order payment

Description ​

Requests a payment of amount toward what is left to pay on an order, with another payment method: to pay after a failed or abandoned payment, or to split the payment across methods. Returns the order's OrderPayments, the pending_amount left to request and, for a gateway, the payment_info to start its payment flow. A shopper's token reaches only their own orders; a POS token, the orders rung up at its location. The payment method must be one the store offers on the token's sales channel (GET /payments/payment-methods lists them); any other is refused with a 400. A manual method the store marks as paid is recorded as paid at once. E-collection, NACH and credit-line methods can't be added, and a cancelled order takes no payment (the order-cancelled error code).

Storefront SDK Usage ​

SDK Method: sdk.order.createOrderPaymentRequest()

Example:

typescript
const { data, error } = await sdk.order.createOrderPaymentRequest(
  { order_number: "ORD-2024-001" },
  {
    amount: 500,
    payment_method: {
      payment_provider_slug: "juspay",
      integration_type: "hyper-checkout",
      return_url: "https://yourapp.com/payment/return",
      action: "paymentPage"
    }
  }
);

if (error) {
  console.error("Failed to request payment:", error.message);
} else {
  console.log("Pending amount:", data.pending_amount);
  console.log("Payments:", data.payments.length);

  // For hyper-checkout, redirect to payment page
  if (data.payment_info && "payment_links" in data.payment_info) {
    window.location.href = data.payment_info.payment_links?.web;
  }
}

TypeScript Definition ​

typescript
"create-order-payment-request": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description The unique identifier of the Order. */
                order_number: string;
            };
            cookie?: never;
        };
        /** @description Request body */
        requestBody: {
            content: {
                "application/json": {
                    /**
                     * Format: double
                     * @description Amount to request for this payment method. The total requested amount cannot exceed the order's `to_be_paid`.
                     */
                    amount: number;
                    payment_method: components["schemas"]["PosPaymentMethodPayload"];
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: $Read<string>;
                        success: $Read<boolean>;
                        content: {
                            /** @description All payment records for the order after creating this request. */
                            payments: components["schemas"]["OrderPayment"][];
                            /** @description `true` if the order has a payable amount. */
                            payment_required: boolean;
                            /**
                             * Format: double
                             * @description Remaining amount that can still be requested for this order: what is left of its `to_be_paid` after the payments requested so far, never below `0`. Payments that failed or were refunded don't count against it, nor do loyalty points or the credit balance the order uses.
                             */
                            pending_amount: number;
                            /** @description Gateway initiation details when an auto payment method is used; otherwise `null`. */
                            payment_info: components["schemas"]["JusPayHyperCheckoutResponse"] | components["schemas"]["JusPayExpressCheckoutResponse"] | null;
                        };
                    };
                };
            };
            400: components["responses"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
            404: components["responses"]["NotFound"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["PosPaymentMethodPayload"]PosPaymentMethodPayload
components["schemas"]["OrderPayment"]OrderPayment
components["schemas"]["JusPayHyperCheckoutResponse"]JusPayHyperCheckoutResponse
components["schemas"]["JusPayExpressCheckoutResponse"]JusPayExpressCheckoutResponse
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["NotFound"]NotFound

Parameters ​

  • order_number (path): The unique identifier of the Order.

Request Body ​

Request body

Content Types: application/json

Responses ​

200 ​

OK

400 ​

Bad request

401 ​

Not authorized for given operation on the Resource

404 ​

Requested resource not found

OpenAPI Definition ​

json
{
  "tags": [
    "Order payments"
  ],
  "operationId": "create-order-payment-request",
  "summary": "Create order payment",
  "description": "Requests a payment of `amount` toward what is left to pay on an order, with another payment method: to pay after a failed or abandoned payment, or to split the payment across methods. Returns the order's `OrderPayment`s, the `pending_amount` left to request and, for a gateway, the `payment_info` to start its payment flow. A shopper's token reaches only their own orders; a POS token, the orders rung up at its location. The payment method must be one the store offers on the token's sales channel (`GET /payments/payment-methods` lists them); any other is refused with a 400. A manual method the store marks as paid is recorded as paid at once. E-collection, NACH and credit-line methods can't be added, and a cancelled order takes no payment (the `order-cancelled` error code).",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/create-order-payment-request",
    "description": "API reference for the create-order-payment-request operation"
  },
  "parameters": [
    {
      "name": "order_number",
      "in": "path",
      "description": "The unique identifier of the Order.",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "description": "Request body",
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "amount",
            "payment_method"
          ],
          "properties": {
            "amount": {
              "description": "Amount to request for this payment method. The total requested amount cannot exceed the order's `to_be_paid`.",
              "type": "number",
              "format": "double",
              "exclusiveMinimum": 0
            },
            "payment_method": {
              "$ref": "#/components/schemas/PosPaymentMethodPayload"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string",
                "readOnly": true
              },
              "success": {
                "type": "boolean",
                "readOnly": true
              },
              "content": {
                "properties": {
                  "payments": {
                    "description": "All payment records for the order after creating this request.",
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/OrderPayment"
                    }
                  },
                  "payment_required": {
                    "description": "`true` if the order has a payable amount.",
                    "type": "boolean"
                  },
                  "pending_amount": {
                    "description": "Remaining amount that can still be requested for this order: what is left of its `to_be_paid` after the payments requested so far, never below `0`. Payments that failed or were refunded don't count against it, nor do loyalty points or the credit balance the order uses.",
                    "type": "number",
                    "format": "double"
                  },
                  "payment_info": {
                    "description": "Gateway initiation details when an auto payment method is used; otherwise `null`.",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/JusPayHyperCheckoutResponse"
                      },
                      {
                        "$ref": "#/components/schemas/JusPayExpressCheckoutResponse"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "payments",
                  "payment_required",
                  "pending_amount",
                  "payment_info"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "orders",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "createOrderPaymentRequest"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: