Skip to content

retry-order-payment ​

Method: POST
Path: /orders/{order_number}/retry-payment

Tags: Order payments

Summary ​

Retry payment

Description ​

Retries payment with an eligible payment method while an amount remains payable. A pending or failed gateway payment can be retried without a waiting period, subject to the order's payment state and retry limit. An order not on the customer's credit line that its loyalty points, credit balance or discounts pay in full has nothing to retry: the request fails with the payment-retry-not-allowed error code, or payment-already-successful once the order is paid. 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.

Storefront SDK Usage ​

SDK Method: sdk.order.retryOrderPayment()

Example:

typescript
// Juspay Hyper Checkout - Redirects to hosted payment page
const { data, error } = await sdk.order.retryOrderPayment(
  { order_number: "ORD-2024-001" },
  {
    payment_method: {
      payment_provider_slug: "juspay",
      integration_type: "hyper-checkout",
      gateway_reference_id: "gateway_ref_123",
      return_url: "https://yourapp.com/payment/return",
      action: "paymentPage"
    }
  }
);

// Juspay Express Checkout - UPI Collect
const { data, error } = await sdk.order.retryOrderPayment(
  { order_number: "ORD-2024-001" },
  {
    payment_method: {
      payment_provider_slug: "juspay",
      integration_type: "express-checkout",
      gateway_reference_id: "gateway_ref_123",
      return_url: "https://yourapp.com/payment/return",
      payment_method_type: "UPI",
      payment_method: "UPI_COLLECT",
      upi_vpa: "user@upi"
    }
  }
);

if (error) {
  console.error("Failed to retry payment:", error.message);
} else {
  console.log("Payment retry initiated");
  console.log("Payment info:", data.payment_info);

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

TypeScript Definition ​

typescript
"retry-order-payment": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description order number */
                order_number: string;
            };
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": {
                    payment_method?: components["schemas"]["RetryPaymentMethodPayload"];
                    /** @description Deprecated. Prefer payment_method; do not send both forms. */
                    payment_gateway_params?: components["schemas"]["LegacyRetryPaymentParams"];
                } | unknown | unknown;
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            /** @description Gateway initiation details for the new payment attempt. `null` when the retry starts no gateway payment: a manual payment method (such as cash on delivery) or a bank transfer. */
                            payment_info: components["schemas"]["JusPayHyperCheckoutResponse"] | components["schemas"]["JusPayExpressCheckoutResponse"] | components["schemas"]["PayuPaymentInfo"] | null;
                        };
                    };
                };
            };
            400: components["responses"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
            403: components["responses"]["Forbidden"];
            404: components["responses"]["NotFound"];
            500: components["responses"]["InternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["RetryPaymentMethodPayload"]RetryPaymentMethodPayload
components["schemas"]["LegacyRetryPaymentParams"]LegacyRetryPaymentParams
components["schemas"]["JusPayHyperCheckoutResponse"]JusPayHyperCheckoutResponse
components["schemas"]["JusPayExpressCheckoutResponse"]JusPayExpressCheckoutResponse
components["schemas"]["PayuPaymentInfo"]PayuPaymentInfo
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["NotFound"]NotFound
components["responses"]["InternalServerError"]InternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

Parameters ​

  • order_number (path): order number

Request Body ​

Content Types: application/json

Responses ​

200 ​

OK

400 ​

Bad request

401 ​

Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.

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

500 ​

The request failed because of an unexpected error.

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "tags": [
    "Order payments"
  ],
  "operationId": "retry-order-payment",
  "summary": "Retry payment",
  "description": "Retries payment with an eligible payment method while an amount remains payable. A pending or failed gateway payment can be retried without a waiting period, subject to the order's payment state and retry limit. An order not on the customer's credit line that its loyalty points, credit balance or discounts pay in full has nothing to retry: the request fails with the `payment-retry-not-allowed` error code, or `payment-already-successful` once the order is paid. 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.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/retry-order-payment",
    "description": "API reference for the retry-order-payment operation"
  },
  "parameters": [
    {
      "name": "order_number",
      "in": "path",
      "description": "order number",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "description": "Provide exactly one of payment_method or the deprecated payment_gateway_params.",
          "type": "object",
          "properties": {
            "payment_method": {
              "$ref": "#/components/schemas/RetryPaymentMethodPayload"
            },
            "payment_gateway_params": {
              "description": "Deprecated. Prefer payment_method; do not send both forms.",
              "$ref": "#/components/schemas/LegacyRetryPaymentParams"
            }
          },
          "anyOf": [
            {
              "required": [
                "payment_method"
              ],
              "not": {
                "required": [
                  "payment_gateway_params"
                ]
              }
            },
            {
              "required": [
                "payment_gateway_params"
              ],
              "not": {
                "required": [
                  "payment_method"
                ]
              }
            }
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "payment_info": {
                    "description": "Gateway initiation details for the new payment attempt. `null` when the retry starts no gateway payment: a manual payment method (such as cash on delivery) or a bank transfer.",
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/JusPayHyperCheckoutResponse"
                      },
                      {
                        "$ref": "#/components/schemas/JusPayExpressCheckoutResponse"
                      },
                      {
                        "$ref": "#/components/schemas/PayuPaymentInfo"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "payment_info"
                ],
                "type": "object"
              }
            }
          }
        }
      },
      "links": {
        "PollRetryPaymentStatus": {
          "operationId": "get-payment-status",
          "parameters": {
            "order_number": "$request.path.order_number"
          },
          "description": "Poll the payment status after retrying payment."
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    },
    "500": {
      "$ref": "#/components/responses/InternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "orders",
  "x-speakeasy-ignore": false,
  "x-speakeasy-name-override": "retryOrderPayment"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: