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

# Subscription Application

> Create subscription order

<div class="flex flex-col gap-4">
  <div class="api-section-heading flex flex-col gap-y-4 w-full">
    <div class="flex items-baseline border-b pb-2.5 border-gray-100 dark:border-gray-800 w-full">
      <h4 class="api-section-heading-title flex-1 mb-0">Secret Key & Private Key (Generate Signature)</h4>
    </div>

    <div />
  </div>

  <input id="secret-key" placeholder="Secret Key" class="px-3 py-2 border rounded-md" />

  <input id="private-key" placeholder="Private Key" class="px-3 py-2 border rounded-md" />
</div>

## Related Topics

* [Subscription Payment API](/docs/en/api/version2/Subscription)
* [HaiPay API Reference Overview](/docs/en/api-reference/overview)
* [HaiPay Configuration and Signature Guide](/docs/en/guide/config_settings_and_signature_rules_guide)


## OpenAPI

````yaml docs/en/api-reference/subscription/subscription.openapi.json POST /subscription/apply
openapi: 3.0.1
info:
  title: 默认模块
  description: ''
  version: 1.0.0
servers:
  - url: https://uat-interface.haipay.asia
    description: 测试-interface
security: []
tags: []
paths:
  /subscription/apply:
    post:
      tags: []
      summary: Subscription Application
      description: 创建订阅订单
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                appId:
                  type: integer
                  description: >-
                    Business ID (obtained from the backend, must pass the
                    corresponding business ID according to the currency in the
                    URL)
                subscriptionOrderId:
                  type: string
                  description: Merchant order ID (must be unique, max length 48)
                  maxLength: 48
                amount:
                  type: string
                  description: >-
                    Transaction amount (accurate to two decimals; punctuation
                    such as “,” is not allowed)
                  pattern: ^\d+\.\d{2}$
                name:
                  type: string
                  description: >-
                    User name, recommended to use real name. Format: includes
                    firstName and lastName, separated by space. Example: John
                    Doe
                phone:
                  type: string
                  description: Real phone number
                email:
                  type: string
                  description: Real email
                  format: email
                subject:
                  type: string
                  description: Subscription title
                body:
                  type: string
                  description: Remark details
                inBankCode:
                  type: string
                  description: >-
                    CREDIT_CARD, GOOGLE_PAY, APPLE_PAY. Mutually exclusive with
                    paymentMethods.
                  enum:
                    - CREDIT_CARD
                    - GOOGLE_PAY
                    - APPLE_PAY
                payType:
                  type: string
                  description: SUBSCRIPTION
                  enum:
                    - SUBSCRIPTION
                callBackUrl:
                  type: string
                  description: Redirect URL after successful payment
                  format: uri
                notifyUrl:
                  type: string
                  description: Asynchronous notification URL
                  format: uri
                country:
                  type: string
                  description: Country
                currency:
                  type: string
                  description: 'Currency, currently supported: USD'
                  enum:
                    - USD
                partnerUserId:
                  type: string
                  description: >-
                    User unique identifier (e.g., userId). Used for risk
                    control. Must be real and valid, otherwise it will affect
                    the transaction. Format: digits, letters, or common symbols
                    -~!@#$%&*()_.
                  pattern: ^[A-Za-z0-9\-~!@#$%&*()_]+$
                recurringInterval:
                  type: string
                  description: Recurring cycle type D（day）,W（week）,M（month）,Y（year）
                  enum:
                    - D
                    - W
                    - M
                    - 'Y'
                recurringIntervalCount:
                  type: integer
                  description: Recurring cycle interval
                  minimum: 1
                recurringMaxNumber:
                  type: integer
                  description: >-
                    Maximum number of cycles. Regardless of cycle type, maximum
                    duration cannot exceed 3 years. Subscription will be
                    automatically canceled at expiration.
                  minimum: 1
                website:
                  type: string
                  description: Transaction website
                  format: uri
                retryTimes:
                  type: integer
                  description: Retry attempts for failed periodic deductions, default 3
                  minimum: 0
                  default: 3
                cancelUrl:
                  type: string
                  description: >-
                    If provided, the user can click “Back” on the payment page
                    to return to this URL.
                  format: uri
                couponPeriod:
                  type: integer
                  description: >-
                    Discount Period (Currently only the first period discount
                    and the full period discount are supported, i.e.,
                    couponPeriod can only be equal to 1 or recurringMaxNumber)
                couponAmountPerPeriod:
                  type: string
                  description: Discount amount per period
                  pattern: ^\d+\.\d{2}$
                sign:
                  type: string
                  description: Signature
                paymentMethods:
                  type: string
                  description: >-
                    Supported payment methods list, separated by commas, e.g.,
                    CREDIT_CARD,GOOGLE_PAY,APPLE_PAY. Mutually exclusive with
                    inBankCode. Currently only supports the front-end component
                    combination mode.
              required:
                - appId
                - subscriptionOrderId
                - amount
                - phone
                - subject
                - inBankCode
                - payType
                - callBackUrl
                - notifyUrl
                - country
                - currency
                - partnerUserId
                - recurringInterval
                - recurringIntervalCount
                - recurringMaxNumber
                - website
                - retryTimes
                - sign
              additionalProperties: false
            example:
              country: USA
              website: https://test.com
              amount: '0.5'
              callBackUrl: https://www.google.com
              inBankCode: CREDIT_CARD
              subject: Test subscription
              subscriptionOrderId: '1736739758574'
              recurringIntervalCount: 1
              sign: >-
                JeJR4N40eKncoohebUN31aNqPqpBxR799rmMutqrSmMaBn0Sjmqbskl4Wiitmatvvx6tqvuwkOYtk6ryrYj7YqJxDeNfDqthWzOxv2ixkKY0YDoWEAra9sWc4CnXBBssP0VIKg0jSTMNzdvmvuNBa7sLEQj5YjgswUnCGtYCmsz154JHSSRpdeYDLL+Nt5b96pzQn8WyRr6b/9SSCrLCWSdt22gJmY5sQh7cc9OcJfAGb5E1XflTq5Va78cV+fw9hHhaZmFzKncg4wxrdaatxg9tCElMJpL1OuWO7XLfcfqgA/8Y/qRCWmNf11Ji3ZSrr7rU4+V7Egrfu1Fcr5DTlw==
              partnerUserId: H20241231
              payType: SUBSCRIPTION
              phone: '0845632145871'
              appId: 1724
              name: howard
              notifyUrl: https://www.google.com
              currency: USD
              email: howard@gmail.com
              recurringInterval: D
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: '1: Normal, 0: Exception'
                  error:
                    type: string
                    description: Error code
                  msg:
                    type: string
                    description: Error description
                  data:
                    type: object
                    description: ''
                    properties:
                      subscriptionOrderId:
                        type: string
                        description: Merchant subscription ID (must be unique)
                      subscriptionNo:
                        type: string
                        description: Platform subscription ID
                      appId:
                        type: string
                        description: Business ID
                      subject:
                        type: string
                        description: Payment note
                      payType:
                        type: string
                        description: Subscription fixed as SUBSCRIPTION
                      inBankCode:
                        type: string
                        description: Bank code
                      amount:
                        type: string
                        description: Deduction amount
                      payUrl:
                        type: string
                        description: Authorization URL
                      recurringInterval:
                        type: string
                        description: Recurring cycle W, M, Y
                        enum:
                          - W
                          - M
                          - 'Y'
                      recurringIntervalCount:
                        type: string
                        description: Recurring cycle interval
                      status:
                        type: string
                        description: '1: Normal, 0: Exception'
                        enum:
                          - '-1'
                          - '1'
                          - '2'
                          - '3'
                          - '4'
                      clientToken:
                        type: string
                        description: >-
                          Client token used in the JavaScript Web SDK (see
                          [HaiPaySDK.js](#haipaysdk))
                      sign:
                        type: string
                        description: Signature
                additionalProperties: false
              example:
                status: '1'
                error: '00000000'
                msg: ''
                data:
                  subscriptionNo: '4025011311423010028'
                  subscriptionOrderId: '1736739758574'
                  appId: 1724
                  subject: Test subscription
                  payType: SUBSCRIPTION
                  inBankCode: CREDIT_CARD
                  amount: 0.5
                  recurringInterval: D
                  recurringIntervalCount: 1
                  status: '2'
                  sign: >-
                    QrOo7yPJMTRk92bP9WU8P0ATdRvCm8dWElhbxqV6qmZEWZDRXeJAwUvd3839zErg+3tN/U4Rwyru219AkXg9CJZtocna3fiYj7uLxwD6bpAp+i9DGz5ZKV9ab5mwIEPWIQXKuY6wATzmlz6W4TvAkRqgGtqLkwYUaeqsmgJrh4WlIMK13GW/zvoCmYfFD6pNZUByVixpll8JPeZG7F9d+x7yjDigJZ2S1wm4F307OzZJkUSKSvQn6Q0lOvp1JS0feXSC+hwCfrdllFXIE10TDV0itoPY5G7+3QdmHpINWp3kWmepR/1pOsN+09hLxe8xKAIZrX2GFHY00xo3QnxBIw==
          headers: {}
      deprecated: false
      security: []

````