Switch to dark theme

Switch to light theme

APIs & Features


About Fusion
Published on 25th March, 2021

After you have successfully completed the steps from the previous section you are now ready to use an instance of CardsService to work with your customers card details.

This section covers the functionalities that the Cards SDK has on offer

Cards SDK Features

After authentication and setup, you are now ready to use the cardsService to work with your users card details. The following functionalities are on offer :

1. Card View

About Card View API

  • You can get the card view with the layout and styles configured specifically for your App with the Zeta platform. The default state of the view returned is the collapsed view which shows only the card PAN.
  • On clicking the view, the user can toggle between the collapsed and the sensitive info states. User authentication is required for accessing the sensitive state of the Cards view if the user has not been asked for authentication already in the current App session.
  • Sample screenshots (Collapsed view - image 1 & Sensitive view - image 2) :

Card view events

  • EXPAND_CARD_VIEW_SUCCESS

Fired when the SDK is able to successfully render the card view in expanded state

  • COLLAPSE_CARD_VIEW_SUCCESS

Fired when the SDK is able to successfully render the card view in collapsed state

  • CHANGE_CARD_VIEW_STATE_FAILURE

Fired when there is an issue with changing the card view from Collapsed to Expanded state & vice-versa.

Card view features

  • Copy details

The SDK shows a copy card number feature on the view to copy the card on the clipboard.

  • Templates

The SDK has support for custom templates in the card view. Based on the templateId, the cards SDK can render different templates. The template must have 2 states (expanded & collapsed respectively)

Sample screenshot for a custom template with expiry label in Blue color :

Please refer to the detailed documentation for Zetlet here using the credentials you received from Zeta for more inforomation on customisation via templates.

  • Themes

The SDK can provide any kind of design with a specific theme that can be configured remotely. For example, the font style for the card number can be configured differently for the collapsed & expanded state. This can be modified in the template itself. Similarly, you can change other labels and design of the card view in the template too.

Sample screenshots for a template with different font styles for card number :

  • Passing custom attributes

By default, the template receives the card details (card number, expiry & CVV) as the payload. You can also pass some additional attributes in the payload which may be needed in the template.

This payload can be accessed in the template using the attrs attribute. Sample code follows :

Passing custom attributes

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
      JsonObject jsonPayload = new JsonObject();
      jsonPayload.addProperty("company_name", "Zeta-India");
      jsonPayload.addProperty("background_image", "https://abc.png");

      CardsService.getInstance().getCardView(this, cardId, "card_EN_UIVIEW", jsonPayload, cardViewChangeInterceptor, (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();
         }
      });
Code Copied

Sample code that can be used in the template :

Passing custom attributes

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

Example showing how additional payload can be used in the template :

Custom attributes in 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

  • Interceptor control

The get card view has a provision to set an interceptor. If the interceptor is set then, whenever the user triggers a state change, the interceptor will receive a callback. The state will only change when the callback is received from the interceptor.

Sample code below :

Interceptor control

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
CardsService.CardsViewChangeInterceptor cardsViewChangeInterceptor = new CardsService.CardsViewChangeInterceptor() {
   InterceptDone interceptDone = null;

   @Override
   public void onIntercept(@NotNull @CardViewState String requestedState) {
       Timber.d("This action was intercepted with requested state: " + requestedState);  
/*
   Here, we can write the code we want to perform whenever the state        change is triggered by the user. Once done, we can call the interceptDone.done() function to continue the regular flow.
*/
       if (interceptDone != null) {
           interceptDone.done();
       }
   }

   @Override
   public void setInterceptDone(@NotNull CardsService.CardsViewChangeInterceptor.InterceptDone interceptDone) {
       this.interceptDone = interceptDone;
   }
};
Code Copied

Sample logs :

Interceptor control

Switch Theme
Expand More
Copy
1
2
This action was intercepted with requested state: expanded
This action was intercepted with requested state: collapsed
Code Copied

2. Super PIN

About Super PIN

Super PIN is a time-synced based dynamic pin that changes every 2 minutes (configurable). The app can query for the Super PIN for different resources associated with the user.

User’s authentication is required to fetch the Super PIN.

Note: When using the Cipher SDK along with the Cards SDK, you need to initialize Cipher SDK before accessing the Super PIN for Cards SDK.

Super PIN API

  • Note: Use this only when you are sure that users have a single resource associated with their accountHolderId’s

  • The return value is a Super PIN along with the validity in milliseconds.

  • Here is a code snippet on how you can fetch the Super PIN assuming a single resource :

Super PIN API

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

  • Sample response :

Super PIN API

Switch Theme
Expand More
Copy
1
2
3
4
{
  "superPin": "<superPin>",
  "validTill": <validityMilliSecs>
}
Code Copied

Super PIN UI

  • Note: Use this only when you are sure that users have a single resource associated with their accountHolderId’s

  • Cards SDK also provides a UI 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 UI is in accordance with the theme with which the SDK has been configured.

  • Here is a code snippet on how you can fetch the Super PIN UI assuming a single resource :

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

  • Sample response :
  • Customisation aspect

Theme changes : font & fontColors supported.

Super PIN for Resource

  • The return value is a Super PIN along with the validity in milliseconds.

  • Here is a code snippet on how you can fetch the Super PIN for a given resource :

Super PIN for 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

  • Sample response :

Super PIN for resource

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 given resource. The UI adds a translucent black background on the existing screen and shows a popup containing the Super PIN. The UI is in accordance with the theme with which the SDK has been configured.

  • Here is a code snippet on how you can fetch the Super PIN UI for a resource :

Super PIN for 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

  • Sample response :
  • Customisation aspect

Theme changes : font & fontColors supported.

3. Static PIN

About Static PIN

Cards SDK provides functionality to allow you to set Static PIN for a given card form factor ID.

Set static PIN API

  • Cards SDK exposes this API to expose the set static PIN for a given card form factor id. This API is behind user authentication and requires authentication per launch of the app.

  • Code snippet :

Static PIN API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().setStaticPin(launchingActivity, pin, cardId, (response, exp) -> {
  if(exp == null) {
      // Pin set is a success
  } else {
      // Pin set is a failure
  }
});
Code Copied

Set static PIN UI

  • Cards SDK provides a UI flow for setting the static PIN. The UI is in accordance with the theme with which the SDK has been configured. The UI allows the user to enter the static PIN twice. The entered PIN has validations for PIN length & equality. Upon authentication, the PIN is stored in an encrypted store.

  • Code snippet for same :

Static PIN UI

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

  • Sample response

Change static PIN API

  • Cards SDK exposes this API to enable the user to change the Static PIN for a given card form-factor. This API can only be used once the static PIN is set. It takes the Old Static PIN and the New Static PIN as input. It checks whether the Old PIN entered by the user is the same as the one earlier set by the user. On successfully providing the correct Old PIN and a valid new PIN, the new PIN is set for the given card form-factor.

  • Here is the code snippet for the same :

Change PIN API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().changeStaticPin(launchingActivity, oldPIN, newPIN, cardId, (response, exp) -> {
  if(exp == null) {
      // Change Static PIN is a success
  } else {
      // Change Static PIN is a failure
  }
});
Code Copied

Change static PIN UI

  • Cards SDK also provides a UI for changing the Static PIN given a card form-factor. The UI is in accordance with the theme with which the SDK has been configured. The UI comprises of three input fields where we can enter:

Old static PIN New static PIN Re-enter new static PIN

  • Users can update the Static by providing the correct Old PIN and valid new PIN. The UI also provides validations for:

PIN length Correctness of Old Static PIN entered Equality of the new static PIN twice

  • Code snippet :

Change PIN UI

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

  • Sample response
  • Customisation aspect

Theme changes : font & fontColors supported.

4. Block/ Unblock

About block card

Cards SDK offers the functionality to block the card temporarily incase the user desires. It allows the user to unblock the card in the future as and when required.

Block card API

  • Cards SDK exposes this API to expose the Block Card functionality. The user can use this API to block the card temporarily. The user may unblock the card in future if required. This API is behind user authentication and requires authentication per launch of the app.

  • Here is the code snippet for the same :

Block Card API

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

Block card UI

  • Cards SDK also provides a UI for blocking the card. The UI is in accordance with the theme with which the SDK has been configured. The UI adds a translucent black background on the existing screen and shows a snackbar containing the option to either cancel or Block the card. Upon authentication, the Block card API is triggered.

  • Here is the code snippet for the same.

Block Card 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

  • Sample output

Unblock card API

  • Cards SDK exposes this API to expose the Unblock Card functionality. The user can use this API to unblock the card which was blocked temporarily using the Block Card API. This API is behind user authentication and requires authentication per launch of the app.

  • Here is the code snippet for the same.

Unblock Card API

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

Unblock card UI

  • Cards SDK also provides a UI for unblocking the card. The UI is in accordance with the theme with which the SDK has been configured. 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. Upon authentication, the Unblock card API is triggered.

  • Here is the code snippet for the same :

Unblock Card UI

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

  • Sample output :
  • Customisation aspect

Theme changes : font & fontColors supported.

5. Hotlist

About hotlisting card

Cards SDK allows the user to hotlist the card in case the user wishes to do so in a scenario where the card is lost, damaged or stolen.

Hotlist card API

  • Cards SDK exposes this API to expose the Hotlist Card functionality. The user can use this API to block the card permanently. This can be done in a case when the user has lost his card and wants to block the card permanently to prevent any misuse. This API is behind user authentication and requires authentication per launch of the app.

  • Here is the code snippet for the same :

Hotlist Card API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().hotlistCard(cardId, (response, exp) -> {
  if(exp == null) {
      // Hotlist card is a success
  } else {
      // Hotlist card is a failure
  }
});
Code Copied

Hotlist card UI

  • Cards SDK also provides a UI for hotlisting the card. The UI is in accordance with the theme with which the SDK has been configured. The UI adds a translucent black background on the existing screen and shows a snackbar containing the option to either cancel or Hotlist the card. Upon authentication, the Hotlist card API is triggered.

  • Here is the code snippet for the same :

Hotlist Card UI

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().hotlistCardUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Hotlist card is a success
  } else {
      // Hotlist card is a failure
  }
});
Code Copied

  • Sample output
  • Customisation aspect

Theme changes : font & fontColors supported.

6. Activate

About activate card

The Cards SDK provides an API to activate the card using card sensitive information.

Activate card with sensitive information API

The card sensitive information includes:

  • Card Number
  • Expiry Date
  • CVV

This API is behind user authentication and requires authentication per launch of the app. Here is the code snippet for the same.

Activate Card API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().activateCard(launchingActivity, cardNumber, expiryDate, cvv,  (response, exp) -> {
  if(exp == null) {
      // Activate card is a success
  } else {
      // Activate card is a failure
  }
});
Code Copied

Activate card with sensitive infromation UI

Cards SDK also provides a UI for activating the card. The UI is in accordance with the theme with which the SDK has been configured. The UI allows us to enter the three required fields and supports the following checks:

  • Validation check on the length of the card number.
  • Validation check on the length of the expiry date.
  • Validation check on the length of the CVV number.
  • Validation for the date entered in the expiry date field.

Here is the code snippet for the same:

Activate Card UI

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().activateCardUI(launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Activate card is a success
  } else {
      // Activate card is a failure
  }
});
Code Copied

  • Sample output

Card activation with card ID API (for proxy users only)

  • Cards SDK provides the functionality to activate a card using Card ID. The API only requires the user to enter the Card ID. Using this, the API is able to activate the card. This API is behind user authentication and requires authentication per launch of the app.

  • Here is the code snippet for the same :

Activate Card proxy API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().activateCard(launchingActivity, cardId,  (response, exp) -> {
  if(exp == null) {
      // Activate card is a success
  } else {
      // Activate card is a failure
  }
});
Code Copied

Card activation with card ID UI (proxy users only)

Cards SDK also provides the UI for activating cards using Card ID. The UI comprises of a two fields:

  • Card ID - Editable field that allows the user to enter the Card ID. Validations on Card ID length are added to this field.
  • DNI Number - Non - Editable user property.

Here is the code snippet for the same.

Activate Card proxy UI

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
8
9
UserPropertiesWithDNINumber userPropertiesWithDNINumber = new UserPropertiesWithDNINumber();
userPropertiesWithDNINumber.setDNINumber(dniNumber);
CardsService.getInstance().activateCard(launchingActivity, userPropertiesWithDNINumber,  (response, exp) -> {
  if(exp == null) {
      // Activate card is a success
  } else {
      // Activate card is a failure
  }
});
Code Copied

  • Sample output
  • Customisation aspect

Theme changes : font & fontColors supported.

7. Get Card Data & sensitive data

About get card data

Cards SDK provides the functionality to get the un-masked card number.

Get card data API

  • The cards SDK invokes the API which gives the card information in encrypted form. This information is then decrypted by Cards SDK to get the un-masked card number. This API is behind user authentication and requires authentication per launch of the app.

  • Here is the code snippet for the same.

Get card data API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getCardData(cardId, launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Get Card Data is a success
  } else {
      // Get Card Data is a failure
  }
});
Code Copied

  • Sample response

Get card data API response

Switch Theme
Expand More
Copy
1
2
3
{
  "cardPan": "<cardPan>"
}
Code Copied

Get card sensitive data API

Cards SDK provides the functionality to get the Card Sensitive information. The cards SDK invokes the API which gives the card information in encrypted form. The information contains following information:

  • Masked Card Number
  • Expiry
  • CVV
  • CSV4
  • Creation Date and Time

This API is behind user authentication and requires authentication per launch of the app.

Sample code snippet for the same :

Get card sensitive data API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getCardSensitiveData(cardId, launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Get Card Sensitive Data is a success
  } else {
      // Get Card Sensitive Data is a failure
  }
});
Code Copied

  • Sample response

Get card sensitive data API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
8
{
  "maskedPan": "<maskedPan>",
      "expiry": "<expiry>",
      "cvv": "<cvv>",
      "csv4": "<csv4>",
      "isVirtual": isVirtual (boolean),
      "createdAt": "<createdAt>"
}
Code Copied

  • Customisation aspect

Theme changes : font & fontColors supported.

8. FIS static PIN

About get FIS static PIN

Cards SDK provides the functionality to get the FIS Static PIN for a specific card ID

get FIS static PIN API (proxy users only)

It takes card ID as input. This API is behind user authentication and requires authentication per launch of the app.

Sample code for the same :

Get FIS static PIN API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getFISStaticPin(cardId, launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Get FIS Static PIN is a success
  } else {
      // Get FIS Static PIN is a failure
  }
});
Code Copied

  • Sample response

Get FIS static PIN API

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getFISStaticPin(cardId, launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Get FIS Static PIN is a success
  } else {
      // Get FIS Static PIN is a failure
  }
});
Code Copied

get FIS static PIN UI (proxy users only])

Cards SDK also provides the UI to get the FIS Static PIN for a specific card ID. The UI adds a translucent black background on the existing screen and shows a snackbar containing the FIS Static PIN. The UI is in accordance with the theme with which the SDK has been configured.

Code snippet for same :

Get FIS static PIN UI

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().getFISStaticPin(cardId, launchingActivity, (response, exp) -> {
  if(exp == null) {
      // Get FIS Static PIN is a success
  } else {
      // Get FIS Static PIN is a failure
  }
});
Code Copied

  • Sample output
  • Customisation aspect

Theme changes : font & fontColors supported.

9. Transaction Limits

About Transaction limits webview

Cards SDK provides the functionality to set limits for a transaction in the form of a webview. This will set an upper limit on the transaction allowed for the card in question.

Transaction limits

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().triggerCardLimitsUI(launchingActivity, cardId, (response, exp) -> {
  if(exp == null) {
      // Card Limits UI rendered successfully.
  } else {
      // Rendering of Card Limits UI Failed.
  }
});
Code Copied

  • Sample output
  • Customisation aspect

Theme changes : font & fontColors supported.

10. Request New Card

About request new card webview

Cards SDK provides this functionality to order a new card in the form of a webview. Using this functionality - the user can fill in his personal details such as Name, Address lines, Contact number etc. post which the card order will be placed. The webview has validations on the Name, State & City fields to check for data.

The consumer can send the jsonContext to this method. This information can be used to render the information on the new card order form. A sample call is shown below :

Card Order

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
{
 "quantity": 1,
 "records": [
   {
     "recordID": 1,
     "cardSkuID": "SODEXO_SPAIN", // get from optima

     // Delivery address will be taken care by webview (Can be passed to pre fill default values)
     "deliveryAddress": {
       "name": "JAVIER JAVIER",
       "addressLine1": "AVD/Santuario de Valverde, 61.Esc.",
       "addressLine2": "D 1 B", // Optional
       "addressLine3": "R1037377 / 0001 / DC", // Optional
       "addressLine4": " ", // Optional
       "city": "Madrid",
       "state": "MADRID",
       "country": "724",
       "postalCode": "28049",
       "contactNumber": ""
     },
     
     "plasticCode": "SDSE01", // Optional
     "thirdLineEmbossing": "JAVIER RODRIGUEZ", // Optional
     "additionalAttributes": {
       "email": "[email protected]",
       "dni": "12344HBN"
     }
   }
 ],
 "attributes": {
   "companyId": "61318",
   "enrichmentFlowKey": "SdxSpainEnrichment",
   "espId": "4",
   "referenceName": "String",
   "corporateId": "61815",
   "processKey": "PersonalizedCardOrder"
 }
}
Code Copied

The context is optional and can be set to null. Code snippet for the same is shown below :

Card Order

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().triggerNewCardOrder(launchingActivity, (response, exp) -> {
  if(exp == null) {
      // New Card Order page was opened successfully.
  } else {
      // Failed to open New Card Order web-view.
  }
}, jsonContext);
Code Copied

  • Sample output :
  • Customisation aspect

Theme changes : font & fontColors supported.

11. Request physical card

About Request physical card webview

Cards SDK provides this functionality to order a physical card in the form of a webview. Using this functionality - the user can fill in his personal details such as Name & Address, post which the order will be placed. The webview has validations on the Name, Address line fields to check for data.

The consumer can send the jsonContext to this method. This information can be used to render the information on the physical card order form. A sample call is shown below :

Physical Card Order

Switch Theme
Expand More
Copy
1
2
3
4
5
6
7
CardsService.getInstance().triggerRequestPhysicalCard(launchingActivity, cardIdOfVirtualCard, (response, exp) -> {
  if(exp == null) {
      // Request Physical Card page was opened successfully.
  } else {
      // Failed to open Request Physical Card web-view.
  }
}, jsonContext);
Code Copied

  • Sample output :
  • Customisation aspect

Theme changes : font & fontColors supported.

12. Logout

About Logout

Ensure that you logout the user by calling this API when you want to switch a user or the user logs out from the app. Failing to do this, the SDK may behave erratically later on.

Logout API

Code snippet for the same

Logout API

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

Card developer events

Cards SDK events for use in development.

About Card events

The Cards SDK publishes certain events that can be subscribed to by anyone.

Events list

Event Description
SETUP_SDK_SUCCESS Fired when the SDK is setup 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.

Sample code snippet to add or remove card SDK listener

Card Events

Switch Theme
Expand More
Copy
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

Card Events

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

This section covers the exceptions and error code specifications that Cards SDK throws

Error fields

All exceptions thrown will have the following fields in addition to the message

  • 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)

Types of Exceptions

There are 2 kinds of exceptions that the Cards SDK can throw

  • SdkAuthException
  • CardsSdkException
  • Note: All the exception classes extend the ApolloException class

Error codes & meaning along with description

Event Description
SDKAUTH_ERR_001 Triggered when authentication of tenantAuthToken fails. Reasons :

1. Token was signed with the incorrect private key

2. The token does not have the configured claim

3. Token is expired

SDKAUTH_ERR_002 Internal error caused while trying to authenticate the user. Contact Zeta support if the issue persists.
CARDS_ERR_001 Exception in hitting the cards API. Retry or contact Zeta 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 support for further assistance on this.
ERR_005 You are doing an operation that is not allowed.

Sample error response

SDK errors

Switch Theme
Expand More
Copy
1
2
[email protected]$ 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