Skip to content

TapPay/tappay-android-tokenpush-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tappay Push Token Sample



Flow




Flow description

  1. Make sure issuer app has been installed
  2. Setup up App schema in AndroidManifest.xml
  3. Issuer App will launch your App with tspPushToken and cancelUrl
  4. Parse TspPushToken and cancelUrl from intent data
  5. Send Push Token API to Tappay server
  6. You will get a suceess response with cardKey and cardToken
  7. You may get more card information by Card Metadata API if you want


Getting Started


Setup App schema in AndroidManifest.xml

<activity
        android:name="tech.cherri.tokenpushexample.MainActivity"
        android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" >
            <!-- please custom your app schema here-->
            <data
                android:host="mock.merchant.app"
                android:scheme="cherri" />
        </intent-filter>
 </activity>        

Fill in partner_key in string.xml

// string.xml
<string name="partner_key">your partner key</string>

TokenPushTask will show you how to send a HTTP POST request to TapPay

//change env to Prod if you has passed your test case in sandbox
env = Env.Sandbox;

...

// JSON request
JSONObject jsonRequest = new JSONObject();
try {
    jsonRequest.put("partner_key", partnerKey);
    jsonRequest.put("tsp_push_token", tokenPushParam.getTspToken());
} catch (JSONException e) {
    Log.e(TAG, "init TokenPushTask error: " + Log.getStackTraceString(e));
}

// onPostExecute , Register a callback if you need to Show Add Card Result in your UI component (MainActivity here)

tokenPushParam.getTokenPushCallback().getTaskResult(jsonObject);