Listening to events

You can listen to various events in the TransactionsView using the onEvent prop.

You can listen to various events in the TransactionsView using the onEvent prop.

import { TransactionsView } from '@card91/react-native-transactions-view';

export function TransactionPage() {
	const onTxnViewEvent = (event) => {
  	switch (event) {
      case "C91_TXN_MISSING_PARAMETER":
        // Do something to indicate that Parameter is missing
        break;
      case "C91_TXN_AUTHENTICATION_FAILURE":
        // Do something to indicate that the API calls have Unauthorized
        break;
      case "C91_TXN_SERVER_FAILURE":
        // Do something to indicate that the API calls have Server Error
        break;
      case "C91_TXN_SCREEN_SUCCESS":
        // Do something to indicate that the API calls have succeeded
        break;
      case 'C91_TXN_API_FAILURE':
        // Do something to indicate that the API calls have failed
        break;
       case 'C91_TXN_DOWNLOAD_BASE64_FILE':
        // Base64 which comes in payload by using convert and download as PDF.Below you can see sample object
        //{
        //"type":"C91_TXN_DOWNLOAD_BASE64_FILE",
        //"payload":{
        //   "base64":"data:application/pdf;base64,JVBERi0xLjMKJf////",
        //  "fileName":"Transactions_1672311285480.pdf"
        //} }
          case 'C91_TXN_PAGE_STATE':
        //"type":"C91_TXN_PAGE_STATE",
        //"payload":{     
        //  "pageName":"TXN_LIST" /* TXN_LIST or TXN_DETAIL
        //} }
        break;
    }
  };
  
  return (
    <View>
	  	<TransactionsView ... onEvent={onTxnViewEvent} />
		</View>
  );
}

The events are as follows:

Event NameDescription
C91_TXN_SCREEN_SUCCESSCalled when the server-side APIs load successfully.
C91_TXN_API_FAILURECalled when the server-side APIs fail to load.
C91_TXN_AUTHENTICATION_FAILURECalled when Token is expired or invalid Parameter
C91_TXN_SERVER_FAILURECalled when the server-side APIs fail to load.
C91_TXN_MISSING_PARAMETERCalled when Input props are missing.
C91_TXN_DOWNLOAD_BASE64_FILEDownload pdf using base64 data
C91_TXN_PAGE_STATEIn Payload we passing page name either TXN_LIST or TXN_DETAIL