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

# トークン化

> 取引をキャプチャするためのホスト型決済ページ（HPP）を開くリンクを生成します。

### 重要なポイント

<Info>
  * ペイロードにデータ（例：金額、通貨、顧客詳細、return\_url、決済方法）が事前入力されている場合、これらの詳細はHPPに反映され、スムーズなユーザー体験を提供します。

  * ペイロードに必要なデータが欠けている場合、顧客はHPPで不足している情報を手動で入力する必要があります。

  * 必要なヘッダーと認証詳細が含まれていることを確認し、HPPリンクを正常に生成します。
</Info>

## フローダイアグラム

<img src="https://mintcdn.com/dasdoc/kfo25CLU3J6KbVVp/images/timeline-diagram/flows-API-Tokenization-jp.svg?fit=max&auto=format&n=kfo25CLU3J6KbVVp&q=85&s=563c36effd938a60f6ae27e4e2fec222" alt="Flow diagram image" width="1997" height="1150" data-path="images/timeline-diagram/flows-API-Tokenization-jp.svg" />

### ノート

`store_payment_method`: 将来の使用のためにカードトークンを保存するには、ペイロードで`true`に設定する必要があります。

```json リクエスト例 theme={null}
{
  "payment_method": {
    "type": "scheme",
    "store_payment_method": true
  }
```

`store_payment_method` を `true` に設定すると、カードトークンが保存され、今後の取引でカード詳細を再入力する必要がなくなります。

```json レスポンス例 theme={null}
{
  "transaction_details": {
    "id": "<transaction_id>",
    "ref": <ref>,
    "timestamp": "yyyy-mm-ddThh:mm:ss.000Z",
    "merchant_txn_ref": "<string>",
    "stored_payment_method_id": "094db781-fabc-4c6d-8fcd-18bee06a527a"
  }
}
```

`stored_payment_method_id` は、カード詳細を再入力することなく、今後の取引でカードトークンAPIを使用するために利用できます。

## APIパラメータ


## OpenAPI

````yaml /api-reference/jp/open-api-config/hpp/generate-link-token.json POST /api/v1/server-to-server-interface/hpp/generate/link
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/hpp/generate/link:
    post:
      summary: HPPリンクを生成
      description: このエンドポイントは、ホスト型決済ページ（HPP）リンクを生成するためのものです。
      operationId: generateHppLink
      requestBody:
        description: HPPリンクを生成するためのリクエストペイロード。
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                return_url:
                  type: object
                  additionalProperties: false
                  description: リターンURLを含むJSONオブジェクト。
                  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/
                    cancel_url:
                      type: string
                      description: 決済がキャンセルされた場合にユーザーをリダイレクトするURL。
                      maxLength: 255
                      example: http://cancelurl.com/
                amount:
                  type: number
                  description: 取引の金額。
                  example: 1000
                currency:
                  type: string
                  description: 処理通貨（例：JPY）。
                  maxLength: 3
                  example: JPY
                merchant_id:
                  type: string
                  description: 加盟店ID（DASMID）。
                  maxLength: 128
                  example: < Merchant ID >
                merchant_email:
                  type: string
                  description: 加盟店のメールアドレス。
                  maxLength: 45
                  example: merchant@testemail.com
                merchant_txn_ref:
                  type: string
                  description: 加盟店の取引参照ID。
                  maxLength: 45
                  example: 2003089893366DTEST
                payment_method:
                  type: object
                  additionalProperties: false
                  description: 支払い方法を含むJSONオブジェクト。
                  properties:
                    type:
                      type: string
                      description: 支払い方法の種類（例：「scheme」）。
                      maxLength: 128
                      example: scheme
                    store_payment_method:
                      type: boolean
                      description: トークンを生成する場合はTrue、生成しない場合はFalse。
                      example: true
                billing_address:
                  type: object
                  additionalProperties: false
                  description: カード所有者の請求先住所を含むJSONオブジェクト。
                  properties:
                    country:
                      type: string
                      description: カード所有者の請求先国コード。
                      maxLength: 2
                      example: JP
                    email:
                      type: string
                      description: カード所有者の請求先メールアドレス。
                      maxLength: 45
                      example: billing@testemail.com
                    phone_number:
                      type: string
                      description: カード所有者の請求先電話番号。
                      maxLength: 15
                      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: カード所有者の配送先住所を含むJSONオブジェクト。
                  properties:
                    country:
                      type: string
                      description: カード所有者の配送先国コード。
                      maxLength: 2
                      example: JP
                    email:
                      type: string
                      description: カード所有者の配送先メールアドレス。
                      maxLength: 45
                      example: shipping@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'
              required:
                - return_url
                - currency
                - merchant_id
                - merchant_email
                - payment_method
                - billing_address
      responses:
        '200':
          description: HPPリンクが正常に生成されました
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 取引参照ID。
                    example: f49173ce-4916-445c-a831-3c1468acf14e
                  url:
                    type: string
                    description: 生成されたホスト型決済ページ（HPP）リンクのURL。
                    example: >-
                      https://checkout-dev.paymentoptions.com/jp/HostedPaymentPage/hKJsdByR
                  amount:
                    type: number
                    description: 取引の金額。
                    example: 1000
                  currency:
                    type: string
                    description: 取引の処理通貨。
                    example: JPY
                  merchant_txn_ref:
                    type: string
                    description: 加盟店の取引参照ID。
                    example: 2003089893366DTEST
                  merchant_id:
                    type: string
                    description: 実行された取引のDAS加盟店ID。
                    example: < Merchant ID >
                  merchant_email:
                    type: string
                    description: 加盟店のメールアドレス。
                    example: merchant@testemail.com
                  return_url:
                    type: object
                    additionalProperties: false
                    description: リターンURLを含むJSONオブジェクト。
                    properties:
                      webhook_url:
                        type: string
                        description: 非同期通知用のWebhook URL。
                        example: < Webhook url >
                      success_url:
                        type: string
                        description: 決済成功後にユーザーをリダイレクトするURL。
                        example: http://www.successurl.com/
                      decline_url:
                        type: string
                        description: 決済失敗後にユーザーをリダイレクトするURL。
                        example: http://www.declineurl.com/
                      cancel_url:
                        type: string
                        description: 決済がキャンセルされた場合にユーザーをリダイレクトするURL。
                        example: http://cancelurl.com/
                  billing_address:
                    type: object
                    additionalProperties: false
                    description: カード所有者の請求先住所を含むJSONオブジェクト。
                    properties:
                      city:
                        type: string
                        description: カード所有者の請求先都市。
                        example: Shinjuku-ku
                      email:
                        type: string
                        description: カード所有者の請求先メールアドレス。
                        example: billing@testemail.com
                      phone_number:
                        type: string
                        description: カード所有者の請求先電話番号。
                        example: '8112345678'
                      state:
                        type: string
                        description: カード所有者の請求先都道府県。
                        example: Tokyo
                      country:
                        type: string
                        description: カード所有者の請求先国コード。
                        example: JP
                      address1:
                        type: string
                        description: カード所有者の請求先住所行。
                        example: 1-2-3 Shinjuku
                      postal_code:
                        type: string
                        description: カード所有者の請求先郵便番号。
                        example: '1600022'
                  shipping_address:
                    type: object
                    additionalProperties: false
                    description: カード所有者の配送先住所を含むJSONオブジェクト。
                    properties:
                      city:
                        type: string
                        description: カード所有者の配送先都市。
                        example: Shinjuku-ku
                      email:
                        type: string
                        description: カード所有者の配送先メールアドレス。
                        example: shipping@testemail.com
                      phone_number:
                        type: string
                        description: カード所有者の配送先電話番号。
                        example: '8112345678'
                      state:
                        type: string
                        description: カード所有者の配送先都道府県。
                        example: Tokyo
                      country:
                        type: string
                        description: カード所有者の配送先国コード。
                        example: JP
                      address1:
                        type: string
                        description: カード所有者の配送先住所行。
                        example: 1-2-3 Shinjuku
                      postal_code:
                        type: string
                        description: カード所有者の配送先郵便番号。
                        example: '1600022'
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キー。

````