> ## 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

> カードトークンは、敏感なカード詳細を再入力することなく、購入または認証取引を安全に完了するために使用されます。このトークン化アプローチは、セキュリティとユーザー体験を向上させます。

### 重要なポイント

<Info>
  * 一度カードトークンが生成されると、それを使用して購入または認証取引を実行できます。
  * カードトークンは実際のカード詳細の必要性を置き換え、取引中に敏感なデータが決して公開されないことを保証します。
  * この方法は通常、次の目的で使用されます： ワンクリック決済、 定期的な取引（例：サブスクリプション）、 保存された顧客の支払い詳細。
</Info>

## フローダイアグラム

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

## APIパラメータ

### カードトークン

`stored_payment_method_id`（トークン作成時に生成される）をペイロードに使用して取引を完了します。

```json リクエスト例 theme={null}
  "payment_method":{
        "type":"scheme",
        "stored_payment_method_id": "094db781-fabc-4c6d-8fcd-18bee06a527a"
    },  
```

`stored_payment_method_id` はカードトークン化プロセスから生成されたトークンであり、今後の取引を安全に完了させるために使用されます。


## OpenAPI

````yaml api-reference/jp/open-api-config/tokenization/use-token.json POST /api/v1/server-to-server-interface/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/payment:
    post:
      operationId: usetoken
      requestBody:
        description: 決済トランザクションを処理するためのリクエストペイロード。
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                amount:
                  type: string
                  description: 取引の金額。
                  example: '1000'
                currency:
                  type: string
                  description: 処理通貨の略称（例：JPY）。
                  example: JPY
                  maxLength: 3
                payment_method:
                  type: object
                  additionalProperties: false
                  description: 決済方法を含むJSONオブジェクト。
                  properties:
                    type:
                      type: string
                      description: 決済方法の種類（例：「scheme」）。
                      example: scheme
                      maxLength: 128
                    store_payment_method_id:
                      type: string
                      description: 決済方法を保存する場合はTrue、保存しない場合はFalse（トークン化のため）。
                      example: 094db781-fabc-4c6d-8fcd-18bee06a527a
                      maxLength: 128
                merchant_txn_ref:
                  type: string
                  description: 加盟店の取引参照ID。
                  example: qwe
                  maxLength: 45
                customer_ip:
                  type: string
                  description: カード所有者のIPアドレス。
                  example: 127.0.0.1
                  maxLength: 45
                merchant_id:
                  type: string
                  description: 加盟店ID（DASMID）。
                  example: < Merchant ID >
                  maxLength: 128
                return_url:
                  type: object
                  additionalProperties: false
                  description: リターンURLを含むJSONオブジェクト。（このフィールドは3DSトランザクションに必須です。）
                  properties:
                    webhook_url:
                      type: string
                      description: Webhook URLリンク。
                      example: < Webhook url >
                      maxLength: 255
                    success_url:
                      type: string
                      description: 支払い成功後のリダイレクトURL。
                      example: http://www.successurl.com/
                      maxLength: 255
                    decline_url:
                      type: string
                      description: 支払い失敗後のリダイレクトURL。
                      example: http://www.declineurl.com/
                      maxLength: 255
                billing_address:
                  type: object
                  additionalProperties: false
                  description: カード所有者の請求先住所を含むJSONオブジェクト。
                  properties:
                    country:
                      type: string
                      description: カード所有者の請求先国コード。
                      example: JP
                      maxLength: 2
                    email:
                      type: string
                      description: カード所有者の請求先メールアドレス。
                      example: billing@testemail.com
                      maxLength: 45
                    phone_number:
                      type: string
                      description: カード所有者の請求先電話番号。
                      example: '8112345678'
                      maxLength: 20
                    address1:
                      type: string
                      description: カード所有者の請求先住所の詳細。
                      example: 1-2-3 Shinjuku
                      maxLength: 199
                    city:
                      type: string
                      description: カード所有者の請求先市区町村。
                      example: Shinjuku-ku
                      maxLength: 65
                    state:
                      type: string
                      description: カード所有者の請求先都道府県。
                      example: Tokyo
                      maxLength: 65
                    postal_code:
                      type: string
                      description: カード所有者の請求先郵便番号。
                      example: '1600022'
                      maxLength: 45
                shipping_address:
                  type: object
                  additionalProperties: false
                  description: カード所有者の配送先住所を含むJSONオブジェクト（オプション）。
                  properties:
                    country:
                      type: string
                      description: カード所有者の配送先国コード。
                      example: JP
                      maxLength: 2
                    email:
                      type: string
                      description: カード所有者の配送先メールアドレス。
                      example: shipping@testemail.com
                      maxLength: 45
                    phone_number:
                      type: string
                      description: カード所有者の配送先電話番号。
                      example: '8112345678'
                      maxLength: 20
                    address1:
                      type: string
                      description: カード所有者の配送先住所の詳細。
                      example: 1-2-3 Shinjuku
                      maxLength: 199
                    city:
                      type: string
                      description: カード所有者の配送先市区町村。
                      example: Shinjuku-ku
                      maxLength: 65
                    state:
                      type: string
                      description: カード所有者の配送先都道府県。
                      example: Tokyo
                      maxLength: 65
                    postal_code:
                      type: string
                      description: カード所有者の配送先郵便番号。
                      example: '1600022'
                      maxLength: 45
                time_zone:
                  type: string
                  description: 取引の国タイムゾーン。
                  example: Asia/Kuala_Lumpur
                  maxLength: 128
              required:
                - amount
                - currency
                - payment_method
                - merchant_id
      responses:
        '201':
          description: 支払いが正常に処理されました。
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: 取引が成功した場合は「true」、失敗した場合は「false」。
                    example: true
                  status_code:
                    type: integer
                    description: 取引のステータスコード。
                    example: 201
                  is_live:
                    type: boolean
                    description: 本番取引の場合は「true」、テスト取引の場合は「false」。
                    example: false
                  transaction_type:
                    type: string
                    description: 取引タイプ（例：CAPTURE）。
                    example: CAPTURE
                  gateway_response:
                    type: object
                    description: ゲートウェイからのレスポンスを含むJSONオブジェクト。
                    properties:
                      version:
                        type: string
                        description: ゲートウェイのバージョン。
                        example: '1'
                      type:
                        type: string
                        description: レスポンスタイプ（例：INFO）。
                        example: INFO
                      message:
                        type: string
                        description: ゲートウェイからのメッセージレスポンス。
                        example: Payment Successful.
                      code:
                        type: string
                        description: レスポンスのメッセージコード。
                        example: INFO0000
                  merchant_details:
                    type: object
                    description: 加盟店の詳細を含むJSONオブジェクト。
                    properties:
                      legal_name:
                        type: string
                        description: 加盟店の正式名称。
                        example: アイベック株式会社
                      mid:
                        type: string
                        description: 加盟店ID（DASMID）。
                        example: < Merchant ID >
                      merchant_txn_ref:
                        type: string
                        description: 加盟店取引参照ID。
                        example: qwe
                      billing_details:
                        type: object
                        description: 請求情報を含むJSONオブジェクト。
                        properties:
                          billing_address:
                            type: object
                            description: 請求先住所を含むJSONオブジェクト。
                            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: デバイスの詳細情報を含むJSONオブジェクト。
                        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: 支払い詳細を含むJSONオブジェクト。
                    properties:
                      amount:
                        type: number
                        description: 取引の金額。
                        example: 1000
                      response_code:
                        type: integer
                        description: アクワイアラーのレスポンスコード。
                        example: 0
                      auth_code:
                        type: string
                        description: アクワイアラーの認証コード。
                        example: '268004'
                      currency:
                        type: string
                        description: 取引の通貨。
                        example: JPY
                      payment_method:
                        type: string
                        description: 支払いカードの種類（例：クレジットカード）。
                        example: ECMC-SSL
                      scheme:
                        type: string
                        description: カードブランドスキーム（例：MASTERCARD）。
                        example: MASTERCARD
                      card:
                        type: object
                        description: カードの詳細情報を含むJSONオブジェクト。
                        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: 追加データを含むJSONオブジェクト。
                        properties:
                          payment_data_source:
                            type: object
                            description: 支払いデータソースを含むJSONオブジェクト。
                            properties:
                              type:
                                type: string
                                description: 支払いデータソースの種類。
                                example: card
                  transaction_details:
                    type: object
                    description: 取引の詳細を含むJSONオブジェクト。
                    properties:
                      id:
                        type: string
                        description: 取引ID。
                        example: 0db1fac1-e064-4644-a387-08d143960c8f
                      ref:
                        type: integer
                        description: 取引の認証コード。
                        example: 74811
                      timestamp:
                        type: string
                        description: 取引の日時。
                        example: '2024-11-25T08:24:36.000Z'
                      merchant_txn_ref:
                        type: string
                        description: 加盟店の取引参照ID。
                        example: qwe
                      stored_payment_method_id:
                        type: string
                        description: 保存された決済方法ID（該当する場合）。
                        example: 094db781-fabc-4c6d-8fcd-18bee06a527a
                  risk-details:
                    type: object
                    description: リスクの詳細を含むJSONオブジェクト。
                    properties:
                      risk_score:
                        type: string
                        description: リスクスコア（該当する場合）。
                        example: null
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キー。

````