Listening to events

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

import { CardView } from '@card91/react-native-card-view';

export function CardPage() {
	const onCardViewEvent = (event) => {
  	switch (event) {
      case "C91_CARD_VIEWER_INITIALISED":
        // Do something to indicate that the API calls have Initialised
        break;
      case "C91_CARD_NUMBER_COPY_SUCCESS":
        // Do something to indicate that the Copy card number succeeded
        break;
      case "C91_CVV_NUMBER_COPY_SUCCESS":
        // Do something to indicate that the cvv number succeeded
        break;
      case "C91_CARD_DETAILS_FETCH_FAILURE":
        // Do something to indicate that the API calls have failure
        break;  
      case "C91_CARD_DETAILS_FETCH_SUCCESS":
        // Do something to indicate that the API calls have succeeded
        break;
      case "C91_CARD_NON_HTTPS_CONTEXT":
        // Do something to indicate that the non https context
        break;
      case "C91_CARD_UNSUPPORTED_OPERATION":
        // Do something to indicate that the Unsupported opeartion
        break;
      case "C91_CARD_AUTHENTICATION_FAILURE":
        // Do something to indicate that the Authentication failure
        break;
      case "C91_CARD_SERVER_FAILURE":
        // Do something to indicate that the Server Failure
        break;
      case "C91_CARD_MISSING_PARAMETER":
        // Do something to indicate that the Missing parameter
        break;
      case "C91_CARD_NUMBER_SHOWN":
        // Do something to indicate that the Card number Shown
        break;
      case "C91_CARD_CVV_SHOWN":
        // Do something to indicate that the Card CVV number Shown
        break;
    }
  };
  
  return (
    <View>
	  	<CardView ... onEvent={onCardViewEvent} />
		</View>
  );
}

The events are as follows:

Event NameDescription
C91_CARD_DETAILS_FETCH_SUCCESSCalled when the server-side APIs load successfully. At this time, the card details are available, but they will be masked if no call to action has been triggered.
C91_CARD_DETAILS_FETCH_FAILURECalled when the server-side APIs fail to load. An error message would be visible in the CardView.
C91_CARD_NUMBER_SHOWNCalled upon the successful operation of the showNumber trigger. At this time, the card number and the expiry date are un-masked and the CVV is masked.
C91_CARD_CVV_SHOWNCalled upon the successful operation of the showCVV trigger. At this time, the CVV is un-masked and the card number and the expiry date are masked.
C91_CARD_AUTHENTICATION_FAILURECall back event type when client is passing incorrect or expired auth token
C91_CARD_MISSING_PARAMETERCall back event type when client is not passing any required/blank parameter .
C91_CARD_SERVER_FAILURECall back event type when there is server service exception with error code 500 to 599
C91_CARD_VIEWER_INITIALISEDCall back event type happens when initialised
C91_CARD_NON_HTTPS_CONTEXTCall back event type occurs https failure
C91_CARD_UNSUPPORTED_OPERATIONCall back event type occurs unsupported operation
C91_CVV_NUMBER_COPY_SUCCESSCall back event type occurs on card number copy success
C91_CARD_NUMBER_COPY_SUCCESSCall back event type occurs on CVV number copy success