Skip to content

cancel-payment-request

Method: POST
Path: /orders/{order_number}/cancel-payment-request

Tags: Orders

Summary

Cancel payment request

Description

Use when the express checkout payment flow is used and the user wants to switch payment methods (e.g. started with UPI, then chose another). Without this call, the user must wait until the payment-status API returns status: failed and is_retry_available: true (typically ~3 minutes). Calling this endpoint cancels the existing payment request so the user can retry payment immediately.

Storefront SDK Usage

SDK Method: sdk.order.cancelPaymentRequest()

Example:

typescript
// Cancel an in-progress payment request to switch payment methods
const { data, error } = await sdk.order.cancelPaymentRequest({
  order_number: "ORD-2024-001"
});

if (error) {
  console.error("Failed to cancel payment request:", error.message);
} else {
  console.log("Payment request cancelled:", data.success);
  console.log("Message:", data.message);
}

TypeScript Definition

typescript
"cancel-payment-request": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description order number */
                order_number: string;
            };
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                    };
                };
            };
            400: components["responses"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
            404: components["responses"]["NotFound"];
        };
    };

Component References

ReferenceResolves To
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["NotFound"]NotFound

Parameters

  • order_number (path): order number

Responses

200

OK

400

Bad request

401

Not authorized for given operation on the Resource

404

Requested resource not found

OpenAPI Definition

json
{
  "tags": [
    "Orders"
  ],
  "operationId": "cancel-payment-request",
  "summary": "Cancel payment request",
  "description": "Use when the express checkout payment flow is used and the user wants to switch payment methods (e.g. started with UPI, then chose another). Without this call, the user must wait until the payment-status API returns `status: failed` and `is_retry_available: true` (typically ~3 minutes). Calling this endpoint cancels the existing payment request so the user can retry payment immediately.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/cancel-payment-request",
    "description": "API reference for the cancel-payment-request operation"
  },
  "parameters": [
    {
      "name": "order_number",
      "in": "path",
      "description": "order number",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "links": {
        "GetPaymentStatusAfterCancel": {
          "operationId": "get-payment-status",
          "parameters": {
            "order_number": "$request.path.order_number"
          },
          "description": "Poll the payment status after canceling payment."
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "orders",
  "x-speakeasy-ignore": false,
  "x-speakeasy-name-override": "cancelPaymentRequest"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: