> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stash.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel pending payment

> Step 2B: Cancels a pending purchase that was previously registered. IMPORTANT: Always expects HTTP 200 OK response with inline error codes in the body.



## OpenAPI

````yaml /egress-openapi.json post /api/v1/purchase/cancel
openapi: 3.0.0
info:
  title: Stash Web Shop API
  description: >-
    Server-side APIs for Stash web shop integration. This API set includes
    catalog management, purchase processing, and user management endpoints
    designed for server-to-server communication between game backends and Stash
    services.
  version: '1.0'
  contact:
    name: API Support
    url: https://docs.stash.gg/
    email: help@stash.gg
servers: []
security: []
tags:
  - name: Catalog
    description: Product catalog endpoints
  - name: Purchase
    description: Purchase processing endpoints
  - name: Players
    description: Player management endpoints
paths:
  /api/v1/purchase/cancel:
    post:
      tags:
        - Purchase
      summary: Cancel pending payment
      description: >-
        Step 2B: Cancels a pending purchase that was previously registered.
        IMPORTANT: Always expects HTTP 200 OK response with inline error codes
        in the body.
      operationId: CancelPayment
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/server.egress.shop.purchase.v1.CancelPaymentRequest
        description: Request to cancel a pending purchase that was previously registered.
        required: true
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/server.egress.shop.purchase.v1.CancelPaymentResponse
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/google.rpc.Status'
      security:
        - hmac: []
components:
  schemas:
    server.egress.shop.purchase.v1.CancelPaymentRequest:
      type: object
      properties:
        playerId:
          type: string
          description: The user canceling the purchase
        transactionId:
          type: string
          description: Transaction identifier to cancel
        checkoutLinkId:
          type: string
          description: >-
            Optional checkout link identifier if purchase was made through a
            checkout link
        shopId:
          type: string
          description: >-
            The originating Stash shop identifier (mirrors the shopId sent in
            webhooks)
        environment:
          $ref: '#/components/schemas/server.egress.shop.v1.PaymentEnvironment'
        currency:
          type: string
          description: Currency code (ISO-4217 code, e.g., 'USD', 'EUR')
        decimalPlaces:
          type: integer
          format: int64
          description: >-
            Number of decimal places in this request's line-item `cents` values
            for this ISO 4217 currency, under the minor-unit standard configured
            for your shop: Unicode CLDR release 32 by default. See `cents` in
            GetCatalog for the standards a shop can use and their sources.
            Always sent, including the literal 0 for zero-decimal currencies
            (e.g. JPY, KRW).
        items:
          type: array
          items:
            $ref: >-
              #/components/schemas/server.egress.shop.purchase.v1.CancelPaymentRequest.CanceledItem
          description: List of items in this canceled purchase
      description: Request to cancel a pending purchase that was previously registered.
      title: Cancel Payment Request
      required:
        - currency
        - decimalPlaces
        - playerId
        - transactionId
        - items
    server.egress.shop.purchase.v1.CancelPaymentResponse:
      type: object
      properties:
        status:
          $ref: >-
            #/components/schemas/server.egress.shop.purchase.v1.PurchaseCancellationStatus
        message:
          type: string
          description: Optional human-readable status message
      description: >-
        Expected response format for the CancelPayment endpoint from the game
        backend (response body includes status indicating success or failure).
      title: Cancel Payment Response
    google.rpc.Status:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/google.protobuf.Any'
    server.egress.shop.v1.PaymentEnvironment:
      type: string
      enum:
        - PAYMENT_ENVIRONMENT_UNSPECIFIED
        - PAYMENT_ENVIRONMENT_TEST
        - PAYMENT_ENVIRONMENT_PRODUCTION
      default: PAYMENT_ENVIRONMENT_UNSPECIFIED
      description: Represents the payment environment for the request
    server.egress.shop.purchase.v1.CancelPaymentRequest.CanceledItem:
      type: object
      properties:
        guid:
          type: string
          description: >-
            The offer/product GUID being canceled (can be auto-generated UUID v5
            if not provided in catalog response)
        productId:
          type: string
          description: The offer/product SKU being canceled
        quantity:
          type: integer
          format: int64
          description: Quantity canceled (must be positive)
        cents:
          type: integer
          format: int64
          description: >-
            Integer minor units per item for this ISO 4217 currency (e.g. 999
            per item in USD), scaled by this request's `decimalPlaces` under the
            minor-unit standard configured for your shop, the same standard
            Stash reads your catalog prices with (see `cents` in GetCatalog).
        purchasePackId:
          type: string
          description: >-
            Identifier of the purchase pack the item was selected from: the
            pack's id in the catalog response the purchase was made from, echoed
            so the purchase can be attributed to the offer as it was displayed
            without a reverse lookup. Required when the selected item came from
            a purchase pack, omitted otherwise; a present but empty value is
            rejected. product_id still identifies which price point was bought.
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Optional key-value pairs for additional item metadata
      description: Represents a single item in the canceled purchase
      title: Canceled Item
      required:
        - guid
        - productId
        - quantity
        - cents
    server.egress.shop.purchase.v1.PurchaseCancellationStatus:
      type: string
      enum:
        - PURCHASE_CANCELLATION_STATUS_UNSPECIFIED
        - PURCHASE_CANCELLATION_STATUS_SUCCESS_CANCELLED
        - PURCHASE_CANCELLATION_STATUS_FAILED_TRANSACTION_NOT_FOUND
        - PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_COMPLETED
        - PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_CANCELLED
      default: PURCHASE_CANCELLATION_STATUS_UNSPECIFIED
      description: Represents the status of a purchase cancellation
      title: >-
        - PURCHASE_CANCELLATION_STATUS_UNSPECIFIED: Default unknown cancellation
        error status
         - PURCHASE_CANCELLATION_STATUS_SUCCESS_CANCELLED: Cancellation was successful
         - PURCHASE_CANCELLATION_STATUS_FAILED_TRANSACTION_NOT_FOUND: Cancellation failed because transaction was not found
         - PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_COMPLETED: Cancellation failed because transaction was already completed
         - PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_CANCELLED: Cancellation failed because transaction was already cancelled
    google.protobuf.Any:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties: {}
  securitySchemes:
    hmac:
      type: apiKey
      description: >-
        Versioned HMAC-SHA256 signature for server-to-server communication
        between game backends and Stash services. Recommended over the
        deprecated legacyHmac scheme for the best security. Header format:
        v1;{shopId};{unixMillisTimestamp};{base64Signature}
        (semicolon-delimited). {base64Signature} is the base64-encoded
        HMAC-SHA256 of the string {unixMillisTimestamp}.{requestBody} signed
        with your Egress API key, where {requestBody} is the compact request
        JSON. The timestamp must be within 5 minutes of Stash server time. Your
        shopId is your immutable shop identifier; it and your Egress API key are
        available in Stash Studio under Project Settings > API Secrets.
      name: x-stash-hmac-signature
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.