> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/classic-push-provisioning/ja/ysuksu/to/apuri/google-and-samsung-pay.md).

# Google & Samsung Pay

#### Google Pay の ID\&V フロー <a href="#idv-flow-for-google-pay" id="idv-flow-for-google-pay"></a>

次の図は Google Pay のアプリ間（app-to-app）ID\&V フローを示しています。ここでは Google Pay がイシュアアプリ（「銀行アプリ」）を呼び出します。

<figure><img src="/files/7e2b884a5fafa3f1ef5a68075ef09cb68d2bfc92" alt=""><figcaption></figcaption></figure>

**ステップ 1: アプリの ID\&V オプションを選択**

エンドユーザーは Google Pay ウォレット内で ID\&V 認証方法の選択を促されます。エンドユーザーは「銀行アプリにサインイン」を選択します。

**ステップ 2: イシュアアプリにログイン**

エンドユーザーは銀行アプリの資格情報を使ってログインします。

**ステップ 3: イシュアアプリの UI**

銀行アプリは Google Pay に追加されたカードの PAN の下4桁を表示します。エンドユーザーは **次へ** を選択して Google Pay でカードを有効化します。

**ステップ 4: 成功画面**

成功画面に Google Pay での有効化状況が表示されます。この画面にはエンドユーザーを Google Pay に戻すボタンが含まれます。

#### スキーム TSP 設定 <a href="#scheme-tsp-configuration-1" id="scheme-tsp-configuration-1"></a>

Google の完全な手順については、Google Pay の [TSP 設定](https://developers.google.com/pay/issuers/tsp-integration/app-to-app-idv#tsp_settings).

イシュアは TSP に対して次のパラメータを提供する必要があります。Google Pay はトークン化の際に TSP からこれらのパラメータを受け取り、イシュアアプリを呼び出す際に使用します。

| パラメータ  | 例                                         | 説明                                                                                                                                                                                                                               |
| ------ | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| パッケージ名 | `com.example.mybank`                      | パッケージ名（applicationId）は、アプリ間フローを起動するために Google Pay が呼び出すべきイシュアのモバイルアプリを識別します。 [インテント](https://developer.android.com/reference/android/content/Intent) アプリがカード所有者のモバイル端末にインストールされていない場合、エンドユーザーは Google Play ストアからインストールするよう促されます。 |
| アクション  | `com.example.mybank.action.ACTIVATE_CARD` | イシュアのモバイルアプリを呼び出すとき、Google Pay アプリは明示的インテントを作成します。アクションはパッケージ名を含む完全修飾形式で提供する必要があります。また、アクションはトークン有効化で使用するために特定のものにする必要があります。                                                                                                     |
| 追加テキスト |                                           | このパラメータは、インテントに含める追加データを渡すために使用されます。通常は JSON 構造体を Base64 エンコードしたものです。この文字列の値は Google にとって不透明（オペーク）であり、標準フィールド EXTRA\_TEXT にそのまま渡されます。                                                                                            |

#### アプリ開発フロー <a href="#app-development-flow" id="app-development-flow"></a>

エンドユーザーが本人確認のためにアプリ間方式を選択した場合、イシュアアプリは次を行う必要があります：

1. Google/Samsung Wallet からの Intent を受け取る。
2. カード所有者を認証する。
3. トークンを有効化する。
4. 次の呼び出しでエンドユーザーを Google Wallet に戻す。 `activity.setResult(RESULT_OK, ...)`.

**インテントの受信**

エンドユーザーがイシュアアプリを使って本人確認することを選んだ場合、Google/Samsung Wallet はパッケージ名、アクション、および `EXTRA_TEXT` を使ってイシュアアプリを呼び出します（これらは TSP を通じて Google/Samsung Pay に提供されます）。Google Pay からのインテントを受け取るには、イシュアはアプリのマニフェストファイルを更新し、トークンを有効化するアクティビティを作成する必要があります。

**Android マニフェストファイルの更新**

イシュアは、アプリ間フロー中に Google Wallet が呼び出せるように、アクションを処理するためにイシュアアプリの Android マニフェストファイルを更新する必要があります。

アプリのリダイレクトを処理するためのアクションとアクティビティを登録するようにマニフェストファイルを更新するには：

```
<activity android:name=".CardActivationActivity">
    <!-- このアクティビティは App To App の ACTIVATE_CARD アクションを処理します -->
    <intent-filter>
        <action android:name="com.example.mybank.action.ACTIVATE_CARD"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>
```

**トークン有効化アクティビティ**

有効化を完了するために、イシュアのアプリは、で渡される有効化パラメータを使用してトークン有効化を行うアクティビティを開始する必要があります `Intent`.

```java
/*
 * イシュアのモバイルアプリ内の AppToAppActivity (CardActivationActivity) 内
 * 追加ライブラリ: com.fasterxml.jackson.core:jackson-core および com.fasterxml.jackson.core:jackson-databind
 */

import android.util.Base64;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

/*
    * インテントを受信した後、アプリケーションは Activity.getCallingPackage() API を使用して
    * リクエストが Google Pay から来ていることを次のように検証する必要があります：
    */
// 呼び出し元が Google Wallet（Google Play Services）であることを検証
if ("com.google.android.gms".equals(getCallingPackage())) {
    // トークン有効化を続行
} else {
    // トークン有効化を中止: エラーを処理
}

String data = getIntent().getStringExtra(Intent.EXTRA_TEXT);

// base64 を解析して、有効化パラメータを文字列の JSON オブジェクトとして取得
byte[] decodedDataBytes = Base64.decode(data, Base64.DEFAULT);
String decodedData = new String(decodedDataBytes, StandardCharsets.UTF_8);

// jackson を使用して JSON 文字列を読む
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(decodedData);

String tokenId = null;
String scheme = CardScheme.VISA.getScheme();
String panLast4 = null;
String tokenRequestorId = "";

if (node.get("tokenReferenceID") != null) { // VISA スキーム
    // VISA の場合 -> tokenReferenceID : tokenId
    tokenId = node.get("tokenReferenceID").asText(); //VISA
    panLast4 = node.get("panLast4").asText(); //VISA

    // tokenRequestorId -> Google Pay の場合、または Samsung Pay の場合は "40010043095" - SCHEME が VISA の場合にのみ関連、MASTERCARD の場合は空文字列にする
    tokenRequestorId = node.get("tokenRequestorID").asText(); //VISA

} else { // MASTERCARD
    // MasterCard の場合 -> tokenUniqueReference : D1 -> tokenId
    tokenId = node.get("tokenUniqueReference").asText(); //MasterCard
    panLast4 = node.get("accountPanSuffix").asText(); //MasterCard
    scheme = CardScheme.MASTERCARD.getScheme();
}

String authorizationCode = "<JWT>"; // 該当するカードに関連する JWT 値を提供、イシュアのバックエンドから取得

// 注: アプリケーションは panLast4 をカード識別情報として表示する必要があります。

TPCManager.getInstance().getTSHProxy().updateTokenState(tokenId,
        tokenRequestorId,
        scheme,
        authorizationCode,
        TokenAction.ACTIVATE,
        new TPCSDKListener<Boolean>() {
            @Override
            public void onStart() {
                // 開始時
            }

            @Override
            public void onSuccess(TPCResult<Boolean> result) {
                Log.i(TAG, "トークン状態が更新され、カードが有効化されました");
                Boolean status = result.getResult();

                // TODO: 新しいステータスに対して UI を更新する
            }

            @Override
            public void onError(TPCSDKException exception) {
                Log.e("TAG", "updateTokenState request Error = " + exception.getMessage());
            }
        });
```

#### カードとトークンの識別 <a href="#card-and-token-identification-1" id="card-and-token-identification-1"></a>

Google Pay がイシュアアプリケーションを起動すると、Base64 でエンコードされた文字列（以下と呼ぶ）を提供します `EXTRA_TEXT` Google の [TSP 設定](https://developers.google.com/pay/issuers/tsp-integration/app-to-app-idv#tsp_settings).

イシュアアプリケーションは Base64 文字列をデコードして、アクティベーションに必要なトークンの詳細を取得する必要があります。フォーマットは使用されるスキームによって異なります。

次の例は、にカプセル化された JSON オブジェクトを示しています `EXTRA_TEXT` Visa および Mastercard の場合：

> <i class="fa-exclamation-circle">:exclamation-circle:</i>
>
> #### 注意 <a href="#caution" id="caution"></a>
>
> これらの JSON サンプルは現状のまま提供されます。最新のスキーム仕様を使用する責任はあなたにあり、Thales はスキームがこれらの JSON オブジェクトに加える可能性のある変更について責任を負いません。

Visa スキームの例：

```json
{
"panReferenceID ":"V-3815023863409817870482",
"tokenRequestorID":"42301999123",
"tokenReferenceID":"DNITHE381502386342002358",
"panLast4":"1234",
"deviceID":"DEiOiJBMjU2R_0NNS1-ciLCJiI",
"walletAccountID":"AiOiJBMjU-2_R0NNS1ciLCJiI6"
}
```

Mastercard スキームの例：

```json
{
"paymentAppProviderId": "123456789",
"paymentAppInstanceId": "123456789",
"tokenUniqueReference": "DWSPMC000000000fcb2f4136b2f4136a0532d2f4136a0532",
"accountPanSuffix": "6789",
"accountExpiry": "1018"
}
```

#### 注 <a href="#note-2" id="note-2"></a>

この `tokenReferenceID` と `tokenUniqueReference` はに対応します `token ID` （TSP）。これらの ID を使用してトークンをアクティベートできます。 `panLast4` と `accountPanSuffix` はトークン化された PAN の下4桁です。これらの値を使用してカードデザインを取得し、認証リクエスト中にエンドユーザーに表示できます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/classic-push-provisioning/ja/ysuksu/to/apuri/google-and-samsung-pay.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
