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

# Create Payment

> Registers a payment record.

**Auto attribution:**
- If `campaignId` is not specified, automatically attributed to the project's active campaign

**Currency conversion:**
- If `currency` is not USD, USD amount will be automatically calculated (`amountUsd`)




## OpenAPI

````yaml /api_docs/openapi.yaml post /v1/server/payments
openapi: 3.0.3
info:
  title: PlayCamp SDK API
  description: >
    PlayCamp SDK API - Game analytics and creator campaign integration API


    ## Required Integration APIs (Server API)

    3 APIs that must be integrated for campaign operation:

    - `POST /v1/server/sponsors` - User boosts a creator

    - `POST /v1/server/coupons/validate` - Validate coupon code

    - `POST /v1/server/payments` - Register in-game payment


    ## Authentication

    - **Client API**: `Authorization: Bearer {CLIENT_KEY_ID}:{CLIENT_SECRET}`

    - **Server API**: `Authorization: Bearer {SERVER_KEY_ID}:{SERVER_SECRET}`


    ## Servers

    - **Live**: https://sdk-api.playcamp.io (Production data)

    - **Sandbox**: https://sandbox-sdk-api.playcamp.io (Test data)


    ## Key Types

    - **Client Key**: For game client (read-only - campaign, creator queries)

    - **Server Key**: For game server (read/write - coupon redemption, payment
    registration, etc.)


    ## Test Mode (isTest)

    Before campaign launch, use `isTest: true` parameter to test API
    integration.

    - Request parameter validation is performed identically to production

    - Returns mock data without recording to actual DB

    - Verify integration in Sandbox environment before campaign launch, then
    remove `isTest` parameter for actual campaign
  version: 1.1.0
  contact:
    name: PlayCamp Support
servers:
  - url: https://sdk-api.playcamp.io
    description: Live Server
  - url: https://sandbox-sdk-api.playcamp.io
    description: Sandbox Server
  - url: http://localhost:3001
    description: Local Live Server
  - url: http://localhost:3003
    description: Local Sandbox Server
security: []
tags:
  - name: Health
    description: Server health check
  - name: Client Campaign
    description: Campaign queries (Client API)
  - name: Client Creator
    description: Creator queries (Client API)
  - name: Client Coupon
    description: Coupon validation (Client API)
  - name: Client Sponsor
    description: Boost status queries — Sponsor API (Client API)
  - name: Server Campaign
    description: Campaign queries (Server API)
  - name: Server Creator
    description: Creator queries (Server API)
  - name: Server Coupon
    description: Coupon management (Server API)
  - name: Server Sponsor
    description: Boost management — Sponsor API (Server API)
  - name: Server Payment
    description: Payment management (Server API)
  - name: Server Playtime
    description: Playtime session management (Server API)
  - name: Server Webhook
    description: Webhook management (Server API)
  - name: Server Webview
    description: WebView management (Server API)
paths:
  /v1/server/payments:
    post:
      tags:
        - Server Payment
      summary: Create Payment
      description: >
        Registers a payment record.


        **Auto attribution:**

        - If `campaignId` is not specified, automatically attributed to the
        project's active campaign


        **Currency conversion:**

        - If `currency` is not USD, USD amount will be automatically calculated
        (`amountUsd`)
      operationId: serverCreatePayment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - userId
                - transactionId
                - productId
                - amount
                - currency
                - platform
                - distributionType
                - purchasedAt
              properties:
                userId:
                  type: string
                  description: User ID
                transactionId:
                  type: string
                  description: Unique transaction ID (provided by platform)
                productId:
                  type: string
                  description: Product ID
                productName:
                  type: string
                  description: Product name (optional)
                amount:
                  type: number
                  minimum: 0.01
                  description: Payment amount
                currency:
                  type: string
                  pattern: ^[A-Z]{3}$
                  description: |
                    Currency code (ISO 4217, required)
                    - USD, KRW recommended
                    - e.g., USD, KRW, JPY, EUR
                platform:
                  type: string
                  enum:
                    - iOS
                    - Android
                    - Web
                    - Roblox
                    - Other
                  description: Payment platform
                distributionType:
                  type: string
                  enum:
                    - MOBILE_STORE
                    - MOBILE_SELF_STORE
                    - PC_STORE
                    - PC_SELF_STORE
                  description: >
                    Distribution type (required, determines store fee):

                    - `MOBILE_STORE`: Mobile external store (Google Play, App
                    Store) - 30%

                    - `PC_STORE`: PC external store (Steam, etc.) - 30%

                    - `MOBILE_SELF_STORE`: Mobile self-payment - 0%

                    - `PC_SELF_STORE`: PC self-store - 0%
                purchasedAt:
                  type: string
                  format: date-time
                  description: |
                    Actual payment time (ISO 8601 UTC format)
                    - Format: `YYYY-MM-DDTHH:mm:ss.sssZ`
                    - Example: `2024-01-15T10:30:00.000Z`
                callbackId:
                  type: string
                  description: >-
                    Webhook tracking ID (included in webhook events triggered by
                    this request)
                isTest:
                  type: boolean
                  default: false
                  description: Test mode (does not create actual data)
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/Payment'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: Duplicate transactionId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: 409
                error: Conflict
                message: 'Payment already exists: txn-12345'
                code: CONFLICT
      security:
        - ServerAuth: []
components:
  schemas:
    Payment:
      type: object
      properties:
        id:
          type: integer
        transactionId:
          type: string
        userId:
          type: string
        productId:
          type: string
        productName:
          type: string
        amount:
          type: number
        currency:
          type: string
        amountUsd:
          type: number
          description: USD converted amount (auto-calculated)
        platform:
          type: string
          enum:
            - iOS
            - Android
            - Web
            - Roblox
            - Other
        distributionType:
          type: string
          enum:
            - MOBILE_STORE
            - MOBILE_SELF_STORE
            - PC_STORE
            - PC_SELF_STORE
          description: >
            Distribution type (determines store fee):

            - `MOBILE_STORE`: Mobile external store (Google Play, App Store) -
            30%

            - `PC_STORE`: PC external store (Steam, etc.) - 30%

            - `MOBILE_SELF_STORE`: Mobile self-payment - 0%

            - `PC_SELF_STORE`: PC self-published store - 0%
        status:
          type: string
          enum:
            - COMPLETED
            - REFUNDED
        campaignId:
          type: string
        creatorKey:
          type: string
        purchasedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - status
        - error
        - message
        - code
      properties:
        status:
          type: integer
          description: HTTP status code
        error:
          type: string
          description: HTTP status name
        message:
          type: string
          description: Detailed error message
        code:
          type: string
          description: |
            Error codes:
            - `VALIDATION_ERROR`: Request parameter validation failed
            - `BAD_REQUEST`: Invalid request
            - `UNAUTHORIZED`: Authentication failed (API key error)
            - `FORBIDDEN`: Access denied
            - `NOT_FOUND`: Resource not found
            - `CONFLICT`: Duplicate resource (already exists)
            - `INTERNAL_ERROR`: Internal server error
        details:
          type: array
          description: Validation error details (for VALIDATION_ERROR)
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
      example:
        status: 404
        error: Not Found
        message: 'Payment not found: txn-12345'
        code: NOT_FOUND
    ValidationError:
      type: object
      required:
        - status
        - error
        - message
        - code
        - details
      properties:
        status:
          type: integer
          example: 400
        error:
          type: string
          example: Bad Request
        message:
          type: string
          example: Validation failed
        code:
          type: string
          example: VALIDATION_ERROR
        details:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
                description: Field path where error occurred
              message:
                type: string
                description: Error message
          example:
            - path: userId
              message: Required
            - path: amount
              message: Expected number, received string
  responses:
    ValidationError:
      description: Request parameter validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    Unauthorized:
      description: Authentication failed (API key error)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 401
            error: Unauthorized
            message: Invalid API key
            code: UNAUTHORIZED
  securitySchemes:
    ServerAuth:
      type: http
      scheme: bearer
      description: 'Server API Key (format: {keyId}:{secret})'

````