openapi: 3.0.0
info:
  title: Payment Embedded Session API
  version: 1.0.0
paths:
  /embedded/initiate:
    post:
      operationId: initiatePaymentSession
      summary: Initiate Payment Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateEmbeddedPaymentSessionRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  hasErrors:
                    type: boolean
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/ErrorItem'
                  data:
                    $ref: '#/components/schemas/InitiateEmbeddedPaymentSessionResult'
  /embedded/initiate-manage-autopay:
    post:
      operationId: initiateManageAutopay
      summary: Initiate Manage Autopay Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateEmbeddedManageAutopaySessionRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  hasErrors:
                    type: boolean
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/ErrorItem'
                  data:
                    $ref: '#/components/schemas/EmbeddedGenericSessionResult'
  /embedded/initiate-manage-paperless:
    post:
      operationId: initiateManagePaperless
      summary: Initiate Manage Paperless Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/InitiateEmbeddedManagePaperlessSessionRequest
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  hasErrors:
                    type: boolean
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/ErrorItem'
                  data:
                    $ref: '#/components/schemas/EmbeddedGenericSessionResult'
  /embedded/initiate-manage-wallet:
    post:
      operationId: initiateManageWallet
      summary: Initiate Manage Wallet Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateEmbeddedManageWalletSessionRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  hasErrors:
                    type: boolean
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/ErrorItem'
                  data:
                    $ref: '#/components/schemas/EmbeddedGenericSessionResult'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Paystar-Api-Key
  schemas:
    ErrorItem:
      type: object
      required:
        - propertyName
        - errorMessage
      properties:
        propertyName:
          type: string
        errorMessage:
          type: string
    ClientUserDto:
      type: object
      properties:
        EmailAddress:
          type: string
        FirstName:
          type: string
        LastName:
          type: string
    ClientAccountDto:
      type: object
      properties:
        AccountNumber:
          type: string
        SubAccountNumber:
          type: string
        Balance:
          type: integer
        Name:
          type: string
        PhoneNumber:
          type: string
        DueDate:
          type: string
          format: date-time
          description: |
            `yyyy-mm-ddThh:mm:ssz`\
            `yyyy-mm-ddThh:mm:ss±hh:mm`
        IssueDate:
          type: string
          format: date-time
          description: |
            `yyyy-mm-ddThh:mm:ssz`\
            `yyyy-mm-ddThh:mm:ss±hh:mm`
        Note:
          type: string
        MetaJson:
          type: string
        Address:
          $ref: '#/components/schemas/OptionalAddress'
    OptionalAddress:
      type: object
      properties:
        StreetAddress:
          type: string
          maxLength: 100
        StreetAddress2:
          type: string
          maxLength: 100
        City:
          type: string
          maxLength: 100
        State:
          type: string
        ZipCode:
          type: string
    EmbeddedGenericSessionResult:
      type: object
      properties:
        SessionLink:
          type: string
        SessionType:
          type: string
        SessionStatus:
          type: string
        ValidUntil:
          type: string
          format: date-time
          description: |
            `yyyy-mm-ddThh:mm:ssz`\
            `yyyy-mm-ddThh:mm:ss±hh:mm`
    InitiateEmbeddedPaymentSessionResult:
      type: object
      properties:
        PaymentSessionIdentifier:
          type: string
        PaymentLogInLink:
          type: string
        Status:
          type: string
    InitiateEmbeddedPaymentSessionRequest:
      type: object
      properties:
        PaymentDescriptor:
          type: string
        Channel:
          type: string
          default: QuickPay
          description: Available options are `QuickPay` and `POS`
        ClientReference:
          type: string
        PaymentSourceIdentifier:
          type: string
        Charges:
          type: array
          items:
            $ref: '#/components/schemas/EmbeddedCharges'
        PaymentFields:
          type: object
          additionalProperties:
            type: string
        ClientUser:
          $ref: '#/components/schemas/ClientUserDto'
    EmbeddedCharges:
      type: object
      properties:
        Amount:
          type: integer
        Description:
          type: string
        ChargeType:
          type: string
        ClientAccount:
          $ref: '#/components/schemas/ClientAccountDto'
    InitiateEmbeddedManageAutopaySessionRequest:
      type: object
      properties:
        ClientAccount:
          $ref: '#/components/schemas/ClientAccountDto'
        ClientUser:
          $ref: '#/components/schemas/ClientUserDto'
    InitiateEmbeddedManagePaperlessSessionRequest:
      type: object
      properties:
        ClientAccount:
          $ref: '#/components/schemas/ClientAccountDto'
        ClientUser:
          $ref: '#/components/schemas/ClientUserDto'
    InitiateEmbeddedManageWalletSessionRequest:
      type: object
      properties:
        ClientUser:
          $ref: '#/components/schemas/ClientUserDto'
servers:
  - url: https://dev-gateway.paystar.io
security:
  - ApiKeyAuth: []
