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

# サブスクリプション作成API

> サブスクリプション作成APIは、加盟店が顧客向けに定期的な請求を設定できるようにし、さまざまな請求間隔、試用期間、割引を備えた柔軟なプランを提供します。

### サブスクリプション作成のリクエスト例

```json theme={null}
"subscription": {
        "plan_name": "<string>",
        "plan_desc": "<string>",
        "cycle_type": "<DAYS/WEEKLY/MONTHLY>",
        "subscription_end_type": "CYCLE",
        "cycle_interval": <int>,
        "max_cycle_count": <int>,
        "has_trial_period": <boolean>,
        "trial_period_duration_type": "DAYS",
        "trial_period_duration": <int>,
        "has_discount": <boolean>,
        "discount_percentage": <int>,
        "discount_duration": <int>
    }
```

### 重要なポイント

<Info>
  ### サブスクリプション作成

  * このAPIは、サブスクリプションプランの設定を可能にし、自動的な定期支払いを提供します。さまざまな請求サイクルや割引、試用期間などの柔軟な設定をサポートしています。

  ### サブスクリプション設定

  * 加盟店は、カスタムプランを定義できます。これには、プラン名と説明が含まれます。

  * サイクルタイプ：請求は日、週、月などに基づいて行えます。

  * サイクル間隔：請求の頻度を定義します（例：2日ごと、毎月）。

  * 最大サイクル数：請求サイクルの最大数を設定します。

  * 試用期間：サブスクリプション開始前に試用期間を提供するオプション。

  * 割引：定められた請求サイクル数に対して割引を適用する機能。
</Info>

## フローダイアグラム

<img src="https://mintcdn.com/dasdoc/kfo25CLU3J6KbVVp/images/timeline-diagram/flows-API-subs-create-jp.svg?fit=max&auto=format&n=kfo25CLU3J6KbVVp&q=85&s=9df62e1607a043ff5fb52d6eccd57309" alt="フローダイアグラム画像" width="1997" height="1150" data-path="images/timeline-diagram/flows-API-subs-create-jp.svg" />

## APIパラメータ


## OpenAPI

````yaml api-reference/jp/open-api-config/subscription/create-subscription.json POST /api/v1/server-to-server-interface/subscription/payment
openapi: 3.0.1
info:
  title: Payment Options API
  description: ホストされた決済ページ（HPP）リンクを生成し、決済を処理するためのAPI。
  version: 1.0.0
servers:
  - url: https://api-dev.paymentoptions.com
security:
  - apiKeyAuth: []
    xApiKeyAuth: []
paths:
  /api/v1/server-to-server-interface/subscription/payment:
    post:
      summary: サブスクリプション支払いを処理
      description: カードおよびサブスクリプションの詳細を使用して定期支払いを処理します。
      operationId: processSubscriptionPayment
      requestBody:
        description: サブスクリプション支払いを処理するためのペイロード。
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - amount
                - currency
                - card
                - payment_method
                - merchant_id
                - billing_address
                - subscription
              properties:
                amount:
                  type: string
                  description: 取引金額。
                  maxLength: 15
                  example: '1000'
                currency:
                  type: string
                  description: 取引のISO通貨コード（例：JPY）。
                  maxLength: 3
                  example: JPY
                card:
                  type: object
                  additionalProperties: false
                  description: 支払いに使用するカードの詳細。
                  required:
                    - cvc
                    - expiry_month
                    - expiry_year
                    - name
                    - number
                  properties:
                    cvc:
                      type: string
                      description: カードのセキュリティコード。
                      maxLength: 4
                      example: '112'
                    expiry_month:
                      type: string
                      description: カードの有効期限（月）。
                      maxLength: 2
                      example: '12'
                    expiry_year:
                      type: string
                      description: カードの有効期限の年（例：29 または 2029 年）。
                      example: '29'
                      maxLength: 4
                    name:
                      type: string
                      description: カード所有者の名前。
                      maxLength: 255
                      example: John Doe
                    number:
                      type: string
                      description: カード番号。
                      maxLength: 16
                      example: '4000000000001091'
                payment_method:
                  type: object
                  additionalProperties: false
                  description: 決済方法の詳細。
                  required:
                    - type
                    - store_payment_method
                  properties:
                    type:
                      type: string
                      description: 決済方法の種類（例：カード決済の場合は 'scheme'）。
                      maxLength: 128
                      example: scheme
                    store_payment_method:
                      type: boolean
                      description: 将来の取引のために支払い方法を保存するかどうか。
                      example: false
                merchant_txn_ref:
                  type: string
                  description: 一意の決済取引参照ID。
                  maxLength: 45
                  example: qwe
                customer_ip:
                  type: string
                  description: 取引を開始した顧客のIPアドレス。
                  maxLength: 45
                  example: 127.0.0.1
                merchant_id:
                  type: string
                  description: 加盟店の一意識別子。
                  maxLength: 128
                  example: < Merchant ID >
                return_url:
                  type: object
                  additionalProperties: false
                  description: リターンURLを含むJSONオブジェクト。（3DS取引では必須）
                  properties:
                    webhook_url:
                      type: string
                      description: Webhook通知のためのURL。
                      maxLength: 255
                      example: < Webhook url >
                    success_url:
                      type: string
                      description: 取引成功後のリダイレクトURL。
                      maxLength: 255
                      example: http://www.successurl.com/
                    decline_url:
                      type: string
                      description: 取引が拒否された場合のリダイレクトURL。
                      maxLength: 255
                      example: http://www.declineurl.com/
                billing_address:
                  type: object
                  additionalProperties: false
                  description: カード所有者の請求先住所の詳細。
                  required:
                    - country
                    - email
                    - phone_number
                    - address1
                    - city
                    - postal_code
                  properties:
                    country:
                      type: string
                      description: 請求先の国コード（ISO 3166-1 alpha-2）。
                      maxLength: 2
                      example: JP
                    email:
                      type: string
                      description: 請求先メールアドレス。
                      maxLength: 45
                      example: billing@testemail.com
                    phone_number:
                      type: string
                      description: 請求先電話番号。
                      maxLength: 20
                      example: '8112345678'
                    address1:
                      type: string
                      description: 請求先住所。
                      maxLength: 199
                      example: 1-2-3 Shinjuku
                    city:
                      type: string
                      description: 請求先市区町村。
                      maxLength: 65
                      example: Shinjuku-ku
                    state:
                      type: string
                      description: 請求先の州（任意）。
                      maxLength: 65
                      example: Tokyo
                    postal_code:
                      type: string
                      description: 請求先郵便番号。
                      maxLength: 45
                      example: '1600022'
                shipping_address:
                  type: object
                  additionalProperties: false
                  description: カード所有者の配送先住所の詳細。
                  properties:
                    country:
                      type: string
                      description: 配送先の国コード（ISO 3166-1 alpha-2）。
                      maxLength: 2
                      example: JP
                    email:
                      type: string
                      description: 配送先メールアドレス。
                      maxLength: 45
                      example: billing@testemail.com
                    phone_number:
                      type: string
                      description: 配送先電話番号。
                      maxLength: 20
                      example: '8112345678'
                    address1:
                      type: string
                      description: 配送先住所。
                      maxLength: 199
                      example: 1-2-3 Shinjuku
                    city:
                      type: string
                      description: 配送先市区町村。
                      maxLength: 65
                      example: Shinjuku-ku
                    state:
                      type: string
                      description: 配送先の州（任意）。
                      maxLength: 65
                      example: Tokyo
                    postal_code:
                      type: string
                      description: 配送先郵便番号。
                      maxLength: 45
                      example: '1600022'
                time_zone:
                  type: string
                  description: 取引のタイムゾーン。
                  maxLength: 128
                  example: Asia/Kuala_Lumpur
                subscription:
                  type: object
                  additionalProperties: false
                  description: 処理されるサブスクリプションの詳細。
                  required:
                    - plan_name
                    - plan_desc
                    - cycle_type
                    - subscription_end_type
                    - cycle_interval
                    - max_cycle_count
                    - has_trial_period
                    - has_discount
                    - discount_percentage
                    - discount_duration
                  properties:
                    plan_name:
                      type: string
                      description: サブスクリプションプラン名。
                      maxLength: 100
                      example: Three weeks plan
                    plan_desc:
                      type: string
                      description: サブスクリプションプランの説明。
                      maxLength: 200
                      example: Billed every two days
                    cycle_type:
                      type: string
                      description: サブスクリプションのサイクルタイプ (e.g., DAYS, WEEKLY or MONTHLY)。
                      example: DAYS
                    subscription_end_type:
                      type: string
                      description: サブスクリプションの終了タイプ（例：CYCLE）。
                      example: CYCLE
                    cycle_interval:
                      type: integer
                      description: 請求サイクル間の間隔。
                      example: 2
                    max_cycle_count:
                      type: integer
                      description: 最大請求サイクル数。
                      example: 10
                    has_trial_period:
                      type: boolean
                      description: サブスクリプションに試用期間が含まれるかどうかを示します。
                      example: false
                    trial_period_duration_type:
                      type: string
                      description: 試用期間の期間タイプ（例：DAYS, MONTHS）。
                      example: DAYS
                    trial_period_duration:
                      type: integer
                      description: 試用期間の長さ。
                      example: 14
                    has_discount:
                      type: boolean
                      description: サブスクリプションに割引が適用されているかどうかを示します。
                      example: true
                    discount_percentage:
                      type: number
                      description: サブスクリプションに適用される割引率。
                      example: 10
                    discount_duration:
                      type: integer
                      description: 請求サイクル単位での割引の期間。
                      example: 2
      responses:
        '201':
          description: サブスクリプション支払いが正常に処理されました。
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: 取引が成功したかどうかを示します。
                    example: true
                  status_code:
                    type: integer
                    description: 取引のHTTPステータスコード。
                    example: 201
                  is_live:
                    type: boolean
                    description: 取引が本番環境のものかテスト環境のものかを示します。
                    example: false
                  transaction_type:
                    type: string
                    description: 実行された取引の種類（例：CAPTURE）。
                    example: CAPTURE
                  gateway_response:
                    type: object
                    description: 決済ゲートウェイからの応答。
                    properties:
                      version:
                        type: string
                        description: ゲートウェイ応答のバージョン。
                        example: '1'
                      type:
                        type: string
                        description: ゲートウェイ応答のタイプ。
                        example: INFO
                      message:
                        type: string
                        description: ゲートウェイからのメッセージ。
                        example: Payment Successful.
                      code:
                        type: string
                        description: ゲートウェイからの応答コード。
                        example: INFO0000
                  merchant_details:
                    type: object
                    description: 加盟店に関する詳細情報。
                    properties:
                      legal_name:
                        type: string
                        description: 加盟店の正式名称。
                        example: Beck's Coffee Shop Pvt. Ltd.
                      mid:
                        type: string
                        description: 加盟店ID。
                        example: JP00000472
                      merchant_txn_ref:
                        type: string
                        description: 加盟店の取引参照ID。
                        example: qwe
                      billing_details:
                        type: object
                        description: 請求先および配送先住所の詳細。
                        properties:
                          billing_address:
                            type: object
                            description: 加盟店の請求先住所。
                            properties:
                              country:
                                type: string
                                description: 国コード。
                                example: JP
                              email:
                                type: string
                                description: 請求先メールアドレス。
                                example: billing@testemail.com
                              phone_number:
                                type: string
                                description: 請求先電話番号。
                                example: '8112345678'
                              address1:
                                type: string
                                description: 請求先住所。
                                example: 1-2-3 Shinjuku
                              city:
                                type: string
                                description: 請求先の市区町村。
                                example: Shinjuku-ku
                              state:
                                type: string
                                description: 請求先の都道府県。
                                example: Tokyo
                              postal_code:
                                type: string
                                description: 請求先の郵便番号。
                                example: '1600022'
                          shipping_address:
                            type: object
                            description: 加盟店の配送先住所。
                            properties:
                              country:
                                type: string
                                description: 国コード。
                                example: JP
                              email:
                                type: string
                                description: 配送先メールアドレス。
                                example: billing@testemail.com
                              phone_number:
                                type: string
                                description: 配送先電話番号。
                                example: '8112345678'
                              address1:
                                type: string
                                description: 配送先住所。
                                example: 1-2-3 Shinjuku
                              city:
                                type: string
                                description: 配送先の市区町村。
                                example: Shinjuku-ku
                              state:
                                type: string
                                description: 配送先の都道府県。
                                example: Tokyo
                              postal_code:
                                type: string
                                description: 配送先の郵便番号。
                                example: '1600022'
                      device_details:
                        type: object
                        description: 顧客のデバイス詳細。
                        properties:
                          visited_ip:
                            type: string
                            description: 決済ページのIPアドレス。
                            example: 127.0.0.1
                          merchant_ip:
                            type: string
                            description: 加盟店のIPアドレスです。
                            example: 127.0.0.1
                          customer_ip:
                            type: string
                            description: カード所有者のIPアドレス。
                            example: 127.0.0.1
                  payment_details:
                    type: object
                    description: 決済取引の詳細。
                    properties:
                      amount:
                        type: number
                        description: 取引金額。
                        example: 900
                      response_code:
                        type: integer
                        description: アクワイアラーからの応答コード。
                        example: 0
                      auth_code:
                        type: string
                        description: アクワイアラーからの認証コード。
                        example: '175438'
                      currency:
                        type: string
                        description: 取引通貨。
                        example: JPY
                      payment_method:
                        type: string
                        description: 使用された支払い方法。
                        example: VISA_DEBIT-SSL
                      scheme:
                        type: string
                        description: 使用されたカードスキーム。
                        example: VISA
                      card:
                        type: object
                        description: 使用されたカードの詳細。
                        properties:
                          name:
                            type: string
                            description: カード所有者の名前。
                            example: John Doe
                          number:
                            type: string
                            description: マスクされたカード番号。
                            example: '4000000000001091'
                          exp_month:
                            type: string
                            description: カードの有効期限（月）。
                            example: '12'
                          exp_year:
                            type: string
                            description: カードの有効期限（年）。
                            example: '29'
                      additional_data:
                        type: object
                        description: 追加の決済関連データ。
                        properties:
                          payment_data_source:
                            type: object
                            description: 決済のデータソース。
                            properties:
                              type:
                                type: string
                                description: 決済データソースの種類。
                                example: card
                  transaction_details:
                    type: object
                    description: 取引の詳細。
                    properties:
                      id:
                        type: string
                        description: 取引ID。
                        example: 359f39bd-673a-47b3-b9ec-cbd6cd313b8e
                      ref:
                        type: integer
                        description: 取引参照番号。
                        example: 74860
                      timestamp:
                        type: string
                        format: date-time
                        description: 取引のタイムスタンプ。
                        example: '2024-11-26T01:31:29.000Z'
                      merchant_txn_ref:
                        type: string
                        description: 加盟店の取引参照ID。
                        example: qwe
                      stored_payment_method_id:
                        type: string
                        nullable: true
                        description: 保存された決済方法ID（該当する場合）。
                        example: null
                  risk-details:
                    type: object
                    description: リスク評価の詳細。
                    properties:
                      risk_score:
                        type: number
                        nullable: true
                        description: 取引のリスクスコア。
                        example: null
                  subscription_details:
                    type: object
                    description: サブスクリプションの詳細。
                    properties:
                      id:
                        type: string
                        description: サブスクリプションID。
                        example: 664dc930-88bd-4696-8807-5e0f1fedba0b
                      type:
                        type: string
                        description: サブスクリプションの種類（例：CYCLE）。
                        example: CYCLE
                      max_cycle_count:
                        type: integer
                        description: 最大請求サイクル数。
                        example: 10
                      status:
                        type: string
                        description: サブスクリプションのステータス。
                        example: ACTIVE
                      completed_payment_cycle:
                        type: integer
                        description: 完了した支払いサイクルの数。
                        example: 1
                      next_payment_date:
                        type: string
                        format: date-time
                        description: 次回の支払い日。
                        example: '2024-11-28T01:31:29.154Z'
                      next_payment_cycle:
                        type: integer
                        description: 次の支払いサイクル番号。
                        example: 2
                      subscription_plan_details:
                        type: object
                        description: サブスクリプションプランの詳細。
                        properties:
                          name:
                            type: string
                            description: サブスクリプションプランの名前。
                            example: Three weeks plan
                          desc:
                            type: string
                            description: サブスクリプションプランの説明。
                            example: Billed every two days
                          billing_cycle_type:
                            type: string
                            description: 請求サイクルの種類（例：DAYS、MONTHS）。
                            example: DAYS
                          billing_cycle_interval:
                            type: integer
                            description: 請求サイクル間の間隔。
                            example: 2
                          amount:
                            type: number
                            description: 各請求サイクルの金額。
                            example: 1000
                          ccy:
                            type: string
                            description: サブスクリプションの通貨コード。
                            example: JPY
                          trial_period_duration:
                            type: string
                            nullable: true
                            description: 試用期間の期間。
                            example: ''
                          trial_period_duration_type:
                            type: string
                            description: 試用期間の種類。
                            example: NONE
                          plan_discount_percentage:
                            type: number
                            description: サブスクリプションプランに適用される割引率。
                            example: 10
                          plan_discount_duration:
                            type: integer
                            description: 割引の適用期間（請求サイクル数）。
                            example: 2
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      name: Authorization
      in: header
      description: 認証用のAPIキー。フォーマット：「Basic YOUR_API_KEY_HERE」
    xApiKeyAuth:
      type: apiKey
      name: x-api-key
      in: header
      description: x-api-key専用のAPIキー。

````