NAV
docs

Create Token

Android

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

Overview

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

Setup Environment

在 Manifest 中您欲接收 JKOPay 付款結果的 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 JKOPAY Availability

確認用戶設備支援 JKOPAY

boolean isJkoPayAvailable = TPDJkoPay.isJkoPayAvailable(this.getApplicationContext());

Setup TPDJkoPay

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

範例如下 :

TPDJkoPay tpdJkoPay = new TPDJkoPay(getApplicationContext(), "your universal links");

Get Prime

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

tpdJkoPay.getPrime(TPDJkoPayGetPrimeSuccessCallback, TPDTokenFailureCallback);

redirectWithUrl

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

tpdJkoPay.redirectWithUrl(payment_url);

JKOPAY Result

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

tpdJkoPay.parseToJkoPayResult(getApplicationContext(), intent.getData(), TPDJkoPayResultListener listener)


您於 onParseSuccess 中可取得本次 JKOPAY 交易的基本資料 (TPDJkoPayResult)

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

Test Method in sandbox

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