NAV
docs

Create Token

Android

如欲了解最新版號 SDK 以及各版號之間的差異性,請參考 Github Release Page : TapPay Android Github

Overview

  1. 專案設置 , 並使用 TPDSetup 設定環境
  2. 確認用戶設備支援 Easy Wallet
  3. 建立 TPDEasyWallet 並給入對應intent filter 的 uri
  4. 利用 TPDEasyWallet 取得 Prime
  5. 利用 redirectWithUrl 開啟 Easy Wallet Application
  6. 用戶付款完成後從 onNewIntent 取得 EasyWalletResult

Setup Environment

在 Manifest 中您欲接收 Easy Wallet 付款結果的 Activity 中新增 intent filter 並設定為 single Task:

<activity
    android:name=".MainActivity"
    android:launchMode="singleTask">

    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="your host"
            android:pathPattern="/your path"
            android:scheme="https" />

    </intent-filter>
</activity>

TPDSetup

static void initInstance(Context context, int appID, String appKey, TPDServerType serverType);

名稱 類別 內容
context Context Android Context
appID int 請參考 appid
appKey String 請參考 appkey
serverType TPDServerType 使用的伺服器種類
測試時請使用 Sandbox 環境 (TPDServerType.Sandbox)
實體上線後請切換至 Production 環境 (TPDServerType.Production)
TPDSetup.initInstance(getApplicationContext(), APP_ID, "APP_KEY", TPDServerType.SANDBOX);

1 . 在您的 server 設定回傳 JSON string 的 config, API path https://"your host"/"your path" JSON String 範例如下

[{
  "relation": ["delegate_permission/common.get_login_creds"],
  "target": {
    "namespace": "android_app",
    "package_name": "your package name",
    "sha256_cert_fingerprints":
    ["your sha256_cert_fingerprints"]
  }
}]


2 . 如何取得 JSON String,使用 android studio 點擊 Tools 選擇 App Links Assistant



Check Easy Wallet Availability

確認用戶設備支援 Easy Wallet

boolean isEasyWalletAvailable = TPDEasyWallet.isAvailable(this.getApplicationContext());

Setup TPDEasyWallet

用 universal links 初始化 TPDEasyWallet 物件 該 link 為您在 Setup Environment 中設定的

範例如下 :

TPDEasyWallet tpdEasyWallet = new TPDEasyWallet(getApplicationContext(), "your universal links");

Get Prime

利用 TPDEasyWallet 取得 prime, 並將 prime 送至您的 server 呼叫 Pay-By-Prime API

tpdEasyWallet.getPrime(TPDEasyWalletGetPrimeSuccessCallback, TPDGetPrimeFailureCallback);

redirectWithUrl

從 TapPay Server 取得 payment_url 後, 您可以使用 redirectWithUrl(payment_url)開啟 Easy Wallet Application 或是對應的付款連結.

tpdEasyWallet.redirectWithUrl(payment_url);

Easy Wallet Result

用戶付款完成後您將於 Activity 生命週期的 onCreate 或 onNewIntent (視您的 Activity 是否被 destroyed ) 中取得 EasyWalletResult, 範例如下:

tpdEasyWallet.parseToEasyWalletResult(getApplicationContext(), intent.getData(), TPDEasyWalletResultListener listener)


您於 onParseSuccess 中可取得本次 Easy Wallet 交易的基本資料 (TPDEasyWalletResultListener)

Name Content
status 0 代表交易成功
recTradeId 由 TapPay 伺服器產生的交易字串
bankTransactionId 銀行端的訂單編號
orderNumber 您自定義的訂單編號,用於 TapPay 做訂單識別,可重複帶入

Test Method in sandbox

請聯絡 TapPay Support
Email : Support@cherri.tech