• Credit

    US flag
  • Credit

    US flag

APIs and Features

At this point, you should have a successful instance of card service running and be ready to work with card details. This section will explain the different functionalities that Fusion Card SDK has to offer.

Card View API

You can get the card view layout and styles configured specifically for your app using the Zeta platform. Upon clicking on the card, the user can toggle between the collapsed and sensitive information states. To view the sensitive information about the card, the user may need to enter their authentication code or the method (fingerprint authentication) which they opted for while logging in.

Sample Screens

Issuers can opt for a simple card view with minimal information displayed upfront or a detailed view with a lot of customizations for end users.

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
/**
Parameters:
1) activity invoking activity
2) cardId The form factor id of the card
3) listener The callback listener.
*/

MyApplication.getCardsService().getCardView(this,
 cardId,
 (view, exp) -> {
   runOnUiThread(() -> {
       // Check for null value of the exception and then render the view returned.
   });
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
/**
Parameters:
1) activity invoking activity
2) cardId The form factor id of the card
3) listener The callback listener.
4) cardsViewTemplateId The templateId for the template to be used. Set this to null if you want to use the default template.
5) jsonPayload The additional json payload we need to pass to the template. We can access this payload using the 'attrs' field in the template. Set null if you don't want to pass any interceptor.
6) cardsViewChangeInterceptor The additional interceptor we can pass. Set this to null if you don't want to pass the interceptor.
*/

MyApplication.getCardsService().getCardView(this,
 cardId,
 (view, exp) -> {
   runOnUiThread(() -> {
       // Check for null value of the exception and then render the view returned.
   });
}, null,
 "card_EN_UIVIEW",
 null,
 null);
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Note: You can ignore optional params for simple integration.
getInstance().getCardView(this,
   cardId,
   object: CardsService.GetViewListener {
       override fun done(view: View?, exp: Throwable?) {
           // Check for null value of the exception and then render the view returned.
       }
   },
   state = "expanded", // (Optional) pass the state in which you want your card to be rendered.
   cardsViewTemplateId = "your_custom_template_id", // (Optional) pass any custom template id here
   jsonPayload = JsonObject(), // (Optional) pass json object with params that can be used to
   cardsViewChangeInterceptor = myInterceptor // (Optional) set this to intercept card view changing states
)
Code Copied

Features offered

The following are some features offered by the Card View API

  1. We can have custom templates for the card view. Based on the templateID, the cards SDK can render different templates. The template must have two states (expanded and collapsed).

Sample Screenshot for a custom card template below

  1. By default, the template receives the card details (card number, expiry, and CVV) as the payload. We can also pass some additional payloads that we may use in our template. This payload can be accessed in the template using the attrs attribute.
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
JsonObject jsonPayload = new JsonObject();
jsonPayload.addProperty("company_name", "Zeta-India");
jsonPayload.addProperty("background_image", "https://abc.png");

CardsService.getInstance().getCardView(
       this,
       cardId,
       (view, exp) -> {
           if(view != null) {
               // render to view received from cards sdk here..

           } else if (exp != null) {
               Toast.makeText(MainActivity.this, exp.getMessage(), Toast.LENGTH_SHORT).show();
           }
       },
       null,
       "card_EN_UIVIEW",
       jsonPayload,
       cardViewChangeInterceptor);
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
val jsonPayload = JsonObject()
jsonPayload.addProperty("company_name", "Zeta-India")
jsonPayload.addProperty("background_image", "https://abc.png")

getInstance().getCardView(
   this,
   cardId,
   object: CardsService.GetViewListener {
       override fun done(view: View?, exp: Throwable?) {
           if (view != null) {
               // render to view received from cards sdk here..
           } else if (exp != null) {
               Toast.makeText(this@MainActivity, exp.message, Toast.LENGTH_SHORT).show()
           }
       }
   },
   null,
   "card_EN_UIVIEW",
   jsonPayload,
   cardViewChangeInterceptor)
Code Copied

Sample Payload that can be used in the template:

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
   card: {
       pan: "1111111111111111",
       expiry: "1221"
       cvv: "123"
   },
   attrs: {
       company_name: “Zeta-India”,
       background_image: “https://abc.png”
   }  
}
Code Copied

Adding additional payload to existing template

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
8
{
 "companyTitle": {
   "label": "<%= attrs.company_name %>"
 },
 "backgroundImage": {
   "url": "<%= attrs.background_image %>"
 }
}
Code Copied

Super PIN

Super PIN is a time-synced dynamic pin that changes every 2 minutes (configurable via backend logic). The app can query for the Super PIN with respect to different resources associated. User’s authentication is required to fetch the Super PIN.

Super PIN for resource

The return value is a Super PIN along with its validity in milliseconds. The following code snippet will allow you to fetch the super PIN for a selected resource.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getSuperPinForResource(activity, resourceId, (superPin, exp) -> {
   if(exp != null) {
       // Exception in getting the super pin
   } else {
       // Super pin fetched successfully
   }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
getInstance().getSuperPinForResource(activity, resourceId,
   object: CardsService.GetSuperPinListener {
       override fun done(superPin: SuperPin?, exp: Throwable?) {
           if(exp != null) {
               // Exception in getting the super pin
           } else {
               // Super pin fetched successfully
           }
       }
   })
Code Copied

Super PIN API

The return value is a super PIN along with its validity in milliseconds. You can use this API when you’re sure that users have a single resource associated with their account holder ID. The following code snippet will allow you to fetch the super PIN.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getSuperPin(activity, (superPin, exp) -> {
   if(exp != null) {
       // Exception in getting the super pin
   } else {
       // Super pin fetched successfully
   }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
getInstance().getSuperPin(activity,
   object: CardsService.GetSuperPinListener {
       override fun done(superPin: SuperPin?, exp: Throwable?) {
           if(exp != null) {
               // Exception in getting the super pin
           } else {
               // Super pin fetched successfully
           }
       }
   })
Code Copied
Switch Theme
Expand More
Copy
1
2
3
4
{
	"superPin": "<superPin>",
	"validTill": <validityMilliSecs>
}
Code Copied

Super PIN UI for Resource

Cards SDK also provides a UI for fetching the Super PIN for a selected resource. The UI adds a translucent black background on the existing screen and shows a popup containing the Super PIN. The UI theme and layout would act accordingly based on how the SDK has been configured.

The following code snippet will allow you to fetch the Super PIN UI for a resource.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getSuperPinForResourceUI(activity, resourceId, (superPin, exp) -> {
   if(exp != null) {
       // Exception in getting the super pin
   } else {
       // Super pin fetched successfully
   }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().getSuperPinForResourceUI(activity, resourceId,
   object: CardsService.GetSuperPinListener {
       override fun done(superPin: SuperPin?, exp: Throwable?) {
           if(exp != null) {
               // Exception in getting the super pin
           } else {
               // Super pin fetched successfully
           }
       }
   })
Code Copied

Sample response

Super PIN UI

Cards SDK also provides a dedicated user interface for fetching the Super PIN. The UI adds a translucent black background on the existing screen and shows a popup containing the Super PIN.

The following code snippet will allow you to fetch the super PIN UI.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getSuperPinUI(activity, (superPin, exp) -> {
   if(exp != null) {
       // Exception in getting the super pin
   } else {
       // Super pin fetched successfully
   }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().getSuperPinUI(activity,
   object: CardsService.GetSuperPinListener {
       override fun done(superPin: SuperPin?, exp: Throwable?) {
           if(exp != null) {
               // Exception in getting the super pin
           } else {
               // Super pin fetched successfully
           }
       }
   })
Code Copied

Sample response

Set Static PIN UI

The SDK also provides a user interface flow for setting the static PIN. Users are asked to enter the static PIN twice while setting up and a set of validations such as PIN length are determined at this stage. After confirmation, this static PIN is stored into the encrypted vault.

The following code snippet will allow you to configure the UI for setting up the static PIN.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().setStaticPinWithUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Pin set is a success
  } else {
      // Pin set is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().setStaticPinWithUI(launchingActivity, cardId,
   object : CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if(exp == null) {
               // Pin set is a success
           } else {
               // Pin set is a failure
           }
       }
   })
Code Copied

Sample response

  • Set Static PIN UI - Initial

* Set Static PIN UI - Incorrect PIN

* Set Static PIN UI - Correct PIN

* Set Static PIN UI - Success

Change Static PIN UI

Along with setting up the static PIN during initial login, the SDK also provides a user interface to modify the already existing static PIN of the user. This static PIN authentication is closely coupled with user authentication and the users must enter their PIN during every app launch activity. The UI comprises of three input fields where we can enter:

  • Old Static PIN
  • New Static PIN
  • Re-enter New Static PIN

The user interface does the following validations:

  • PIN lengths
  • Correctness of Old Static PIN entered
  • Equality of the New Static PIN entered twice

The following code snippet will allow you to modify the static PIN on the app.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().changeStaticPinWithUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Change Static PIN is a success
  } else {
      // Change Static PIN is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().changeStaticPinWithUI(launchingActivity, cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Change Static PIN is a success
           } else {
               // Change Static PIN is a failure
           }
       }
   })
Code Copied

Sample response

  • Change Static PIN UI - Initial

  • Change Static PIN UI - New PIN Mismatch

  • Change Static PIN UI - Success

Block Card API

This API is used to block the card temporarily. The blocked cards via this API can be reactivated later.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().blockCard(cardId, (response, exp) -> {
  if(exp == null) {
      // Block card is a success
  } else {
      // Block card is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().blockCard(cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Block card is a success
           } else {
               // Block card is a failure
           }
       }
   })
Code Copied

Block Card UI

A customized user interface can be created for the blocking card functionality. This UI adds a translucent black background on the existing screen and shows a snackbar containing the option to either Cancel or Block the card.

The following code snippet will allow you to integrate this blocking UI:

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().blockCardUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Block card is a success
  } else {
      // Block card is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().blockCardUI(activity, cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Block card is a success
           } else {
               // Block card is a failure
           }
       }
   })
Code Copied

Sample response

Unblock Card API

After a user has blocked a card, this API will allow them to unblock the selected card straight from the app.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().unblockCard(cardId, (response, exp) -> {
  if(exp == null) {
      // Unblock card is a success
  } else {
      // Unblock card is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().unblockCard(cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Unblock card is a success
           } else {
               // Unblock card is a failure
           }
       }
   })
Code Copied

Unblock Card UI

The following code snippet will allow you to design a user interface for unblocking the card. The UI adds a translucent black background on the existing screen and shows a snackbar containing the option to either cancel or Unblock the card.

The following code snippet will allow you to add the unblock card UI into your project:

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().unblockCardUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Unblock card is a success
  } else {
      // Unblock card is a failure
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().unblockCardUI(activity, cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Unblock card is a success
           } else {
               // Unblock card is a failure
           }
       }
   })
Code Copied

Sample response

Copy Card Number

The following code snippet adds the functionality of copying an un-masked card number to the clipboard. A toast message is displayed once the number has been copied and the user can paste it anywhere they want.

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().copyCardNumber(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Card number copied successfully
  } else {
      // Copying card number failed.
  }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CardsService.getInstance().copyCardNumber(launchingActivity, cardId,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp == null) {
               // Card number copied successfully
           } else {
               // Copying card number failed.
           }
       }
   })
Code Copied

Front Face Card UI

The front-facing portion of the virtual card can be displayed as a user interface on your android app using the Cards SDK. This UI comes as a default with the Fusion SDK and you can do a lot of customizations depending upon your customer base.

The following code snippet lets you make customizations on the front facing card UI:

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().triggerFrontFaceUI(activity, (response, exp) -> {
   if(exp != null) {
       // Exception in rendering front face UI.
   } else {
       // Front Face UI rendering successful.
   }
});
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
getInstance().triggerFrontFaceUI(activity,
   object: CardsService.ResponseListener {
       override fun done(response: JsonObject?, exp: Throwable?) {
           if (exp != null) {
               // Exception in rendering front face UI.
           } else {
               // Front Face UI rendering successful.
           }
       }
   })
Code Copied

Here are some of the UI designs supported with Front Face Card UI:

Design 1

Design 2

Customised Super PIN View

When the user clicks on the front-facing card view, our SDK by default displays the super PIN in an expanded view. This UI can be customized further as per your requirements. You can simply register the super PIN view and our SDK will handle the following:

  1. Injecting the super pin to the layout
  2. Updating the super pin whenever it expires
  3. Informing the client to update the UI when the super pin expires
  4. Hiding the super pin view in a collapsed state and showing it in an expanded state

To use the custom super PIN view, you need to register a SuperPinViewHolder with the Cards SDK. This process must be done during every session.

Sample code snippet to register a SuperPinViewHolder

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
8
9
public class ClientSuperPinViewHolder implements CardsService.SuperPinViewProvider {
    @NotNull
    @Override
    public CardsService.SuperPinView getInstance() {
        return new ClientSuperPinView();
    }
}

CardsService.getInstance().registerSuperPinViewProvider(new ClientSuperPinViewHolder());
Code Copied
Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
8
9
class MyClientSuperPinViewHolder: ClientSuperPinViewHolder() {

   override fun getInstance(): CardsService.SuperPinView {
       return ClientSuperPinView()
   }
}


CardsService.getInstance().registerSuperPinViewProvider(MyClientSuperPinViewHolder())
Code Copied

The super PIN view implements the 3 following methods:

  1. getSuperPinPlaceHolder(superPinViewData): The client must return a text-view where the super pin needs to be placed.
  2. configureSuperPinValidity(superPinViewData, validity): This method is called by Cards SDK when the super pin is expired. The SDK will refresh the super pin on its own and trigger this method to refresh the UI if necessary.
  3. getView(superPinViewData, context): This method is called to get the parent-view that needs to be placed.

While invoking the methods of super pin view, the SDK will also send superPinViewData. This data comprises the card ID and template ID. You can return a different UI based on the card ID, or based on the template ID. For instance, if you want to show a super pin on two different screens with different UI, you may achieve that using the superPinViewData.

View the following sample code snippet of the super PIN view:

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
public class ClientSuperPinView implements CardsService.SuperPinView {
   private static final long PROGRESS_VIEW_INTERVAL_MS = 10;

   private View nativeView;
   private TextView pinLabel;
   private TextView pinView;
   private ProgressBar progressBar;
   private CountDownTimer codeHiderTimer;
   private Context context;

   @NotNull
   @Override
   public View getView(@NotNull SuperPinViewData superPinViewData, @NotNull Context context) {
       this.context = context;
       init();
       return nativeView;
   }

   @NotNull
   @Override
   public TextView getSuperPinPlaceHolder(@NotNull SuperPinViewData superPinViewData) {
       return pinView;
   }

   @Override
   public void configureSuperPinValidity(@NotNull SuperPinViewData superPinViewData, long validity) {
       showSuperCardPinTimer(validity);
   }

   private void showSuperCardPinTimer(long duration) {
       updateCodeHiderTimer(duration);
   }

   private void updateCodeHiderTimer(final long duration) {
       cancelCountdownTimer();
       codeHiderTimer = new CountDownTimer(duration, PROGRESS_VIEW_INTERVAL_MS) {
           @Override
           public void onTick(long timeUntilFinishedMs) {
               progressBar.setProgress((int)((1.0 + duration - timeUntilFinishedMs)/duration*100));
           }

           @Override
           public void onFinish() {

           }
       };
       codeHiderTimer.start();
   }

   private void init() {
       LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       nativeView = layoutInflater.inflate(R.layout.layout_client_super_pin_view, null);

       initViewIds();
   }

   private void initViewIds() {
       pinView = nativeView.findViewById(R.id.pin_value);
       progressBar = nativeView.findViewById(R.id.progress_bar);
       pinLabel = nativeView.findViewById(R.id.pin_label);
   }

   private void cancelCountdownTimer() {
       if (codeHiderTimer != null) {
           codeHiderTimer.cancel();
       }
   }
}
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class ClientSuperPinView : CardsService.SuperPinView {
   private var nativeView: View? = null
   private var pinLabel: TextView? = null
   private var pinView: TextView? = null
   private var progressBar: ProgressBar? = null
   private var codeHiderTimer: CountDownTimer? = null
   private var context: Context? = null
  
   override fun getView(superPinViewData: SuperPinViewData, context: Context): View {
       this.context = context
       init()
       return nativeView!!
   }

   override fun getSuperPinPlaceHolder(superPinViewData: SuperPinViewData): TextView {
       return pinView!!
   }

   override fun configureSuperPinValidity(superPinViewData: SuperPinViewData, validity: Long) {
       showSuperCardPinTimer(validity)
   }

   private fun showSuperCardPinTimer(validity: Long) {
       updateCodeHiderTimer(validity)
   }

   private fun updateCodeHiderTimer(duration: Long) {
       cancelCountdownTimer()
       codeHiderTimer = object : CountDownTimer(duration, PROGRESS_VIEW_INTERVAL_MS) {
           override fun onTick(timeUntilFinishedMs: Long) {
               progressBar!!.progress =
                   ((1.0 + duration - timeUntilFinishedMs) / duration * 100).toInt()
           }

           override fun onFinish() {}
       }
       codeHiderTimer?.start()
   }

   private fun init() {
       val layoutInflater =
           context!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
       nativeView = layoutInflater.inflate(R.layout.layout_client_super_pin_view, null)
       initViewIds()
       initTypeface()
   }

   private fun initViewIds() {
       pinView = nativeView!!.findViewById(R.id.pin_value)
       progressBar = nativeView!!.findViewById(R.id.progress_bar)
       pinLabel = nativeView!!.findViewById(R.id.pin_label)
   }

   private fun initTypeface() {
       pinView!!.typeface =
           Typeface.createFromAsset(context!!.assets, "fonts/IBMPlexSans-Bold.otf")
       pinLabel!!.typeface =
           Typeface.createFromAsset(context!!.assets, "fonts/IBMPlexSans-Regular.otf")
   }

   private fun cancelCountdownTimer() {
       if (codeHiderTimer != null) {
           codeHiderTimer!!.cancel()
       }
   }

   companion object {
       private const val PROGRESS_VIEW_INTERVAL_MS: Long = 10
   }
}
Code Copied

Sample Output

Logout

When a user logs out of the app or wants to switch user sessions, you can utilize the following code in your project to safely log out that user. This is a necessary step to ensure that the SDK is working properly.

Switch Theme
Expand More
Copy
1
2
3
CardsService.getInstance().logout(() -> {
   // The user is logged out …
});
Code Copied
Switch Theme
Expand More
Copy
1
2
3
4
getInstance().logout(object: CardsService.LogoutListener {
   override fun done() {
   }
})
Code Copied

Card Events

The following tracking events are fired by the Cards SDK by default and you can subscribe to these events and monitor the respective performance metrics:

  • SETUP_SDK_SUCCESS - Fired when the SDK setup is completed successfully
  • SETUP_SDK_FAILURE - Fired when there is some failure in SDK setup
  • AUTHENTICATE_SDK_SUCCESS - Fired when the SDK is authenticated successfully
  • AUTHENTICATE_SDK_FAILURE - Fired when there is some failure in SDK Authentication
  • EXPAND_CARD_VIEW_SUCCESS - Fired when the SDK is able to successfully render Card View in Expanded State
  • COLLAPSE_CARD_VIEW_SUCCESS - Fired when the SDK is able to successfully render Card View in Collapsed State
  • CHANGE_CARD_VIEW_STATE_FAILURE - Fired when there is some error in changing the card view state from Expanded to Collapsed or vice-versa
  • LOGOUT_SDK_SUCCESS - Fired when the logout is successful
  • LOGOUT_SDK_FAILURE - Fired when there is some error in logout
  • BLOCK_CARD_SUCCESS - Fired when there is successful block action triggered
  • BLOCK_CARD_FAILURE - Fired when block card action fails due to some reason
  • UNBLOCK_CARD_SUCCESS - Fired when there is successful unblock action triggered
  • UNBLOCK_CARD_FAILURE - Fired when unblock card action fails due to some reason

You can configure or remove a card listener using the following code snippet:

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
CardsService.CardsEventListener cardsEventListener = (event, exp) -> {
   Timber.d("Event Received from CARDS SDK: " + event);
   //Perform the required functionality here..
   if (exp != null) {
       Timber.d("Error: " + exp.getMessage());
   }
};

// Use this to add the listener
CardsService.getInstance().addCardsEventsListener(cardsEventListener);

// Use this to remove the listener
CardsService.getInstance().removeCardsEventsListener(cardsEventListener);
Code Copied
Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
val cardsEventListener = object: CardsService.CardsEventListener() {

   override fun onReceive(event: String?, exp: Throwable?) {
       Timber.d("Event Received from CARDS SDK: $event")
       //Perform the required functionality here..
       if (exp != null) {
           Timber.d("Error: " + exp.message)
       }
   }
}

// Use this to add the listener
getInstance().addCardsEventsListener(cardsEventListener)

// Use this to remove the listener
getInstance().removeCardsEventsListener(cardsEventListener)
Code Copied

Sample logs:

Switch Theme
Expand More
Copy
1
2
3
4
Event Received from CARDS SDK: AUTHENTICATE_SDK_SUCCESS
Event Received from CARDS SDK: SETUP_SDK_SUCCESS
Event Received from CARDS SDK: COLLAPSE_CARD_VIEW_SUCCESS
Event Received from CARDS SDK: EXPAND_CARD_VIEW_SUCCESS
Code Copied

Exceptions and error codes

As part of the error response message the following fields will also be present:

  • code - The error code related to the response
  • traceId - The trace id which can be provided to Zeta support for identifying the root cause
  • errorType - The type of error (Added for verbosity)

The following types of exceptions are thrown by the SDK:

  1. SdkAuthException

  2. CardsSdkException

Note: All the exception classes extend the ApolloException




Following are the error codes and their meaning:



* SDKAUTH_ERR_001 - Authentication of tenantAuthToken fails. Potential reasons
    * Token was signed with the incorrect private key
    * The token does not have the configured claim
    * Token is expired
* SDKAUTH_ERR_002 - Internal error caused while trying to authenticate the user. Contact support if the issue persists.
* CARDS_ERR_001 - Exception in hitting the cards API. Retry/ Contact support if the issue persists.
* ERR_001 - Exception is thrown due to a bad request. This might be due to an invalid input or the SDK is not initialized properly.
* ERR_002 - Internal server error. Contact support if the issue persists.
* ERR_003 - Internal SDK error. You can try logging out or contact support if the issue persists.
* ERR_004 - Invalid response from the server. Contact Zeta for further assistance on this.
* ERR_005 - You are doing an operation that is not allowed.

**Error response**






Switch Theme
Expand More
Copy
1
2
apollo@console$ in.zeta.apollo.sdkauth.SdkAuthException: The jwt token set seems invalid. Please check the parameters and signature to create the token
SdkAuthException.code: SDKAUTH_ERR_001
Code Copied