Document explain the process to add the flutter plugin to card view
Installation and Usage Guide
Card91 card view plugin
This package is made to utilize to display the card details which includes the card number, expiry and the CVV associated with card. This package directly communicates to Card91 SDK to fetch the card details issued to the cardholder.
Features
Package directly communicate with the SDK (secured platform) with provided details basic details
of the card and in return package display the card details
Getting started
Add the widget package on your pubspec version
$ flutter pub add card91_plugin
For webview_flutter 4 and above add below widget
$ flutter pub add card91_plugin_v2
Use this package as a library
Depend on it
Run this command:
With Flutter:
$ flutter pub add card91_plugin or $ flutter pub add card91_plugin_v2
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:card91_plugin: (updated version)
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Import it
Now in your Dart code, you can use:
import 'package:card91_plugin/card91_flutter_library.dart';
Usage
Add the widget on the specified container as child specifically as per the your design choice. Check out the below code snippet for the same. Since the card may be multiple so try to add the CardViewItemWidget inside the PageView builder and then within itembuilder add the CardViewItemWidget
Sample code below
import 'package:card91_plugin/card91_flutter_library.dart';
PageView.builder(
itemBuilder:(context, index)
{
return Column
(
children:[
Center(
child:Stack(
children: [
Container
(
child: Image(
height: 200,
width:Get.width,
fit: BoxFit.contain,
image: AssetImage('assets/app_images/card_image_nsdl_rupay.png'), // Put a image on the back of card view (preferrable dark background) to see card view
),
),
CardViewItemWidget(
cardId: "", // provide card id here
customerId: "", // Customer id
cardLastFourDigit: "", // last four digit of the card for which details need to be loaded
token: "", //card holder auth token needs to be provided here
nameOnCard: "", // provide name on card value here
templateId: "default", // based on card layout and function selected
env:"PROD", // based on env base url for webview will change eg. PROD, PROD_SANDBOX
onDataResponse:(String response, String payload){
print("Reponse from SDK"+reponse+payload);
}),
]
)
)
]
)
}
)
Input parameter for CardViewItemWidget
Name | Type | Required | Description |
---|---|---|---|
cardId | string | true | cardId which has been received form login token service . Refer customer service SDK for getting the card holder card Id and other details. |
customerId | string | true | customerId which has been received form login token service . Refer customer service SDK for getting the card holder card Id and other details. |
cardLastFourDigit | string | true | cardId which has been received form login token service . Refer customer service SDK for getting the card holder card Id and other details. |
token | string | true | Auth Token which has been received form login token service . Refer customer service SDK for getting the card holder card Id and other details. |
nameOnCard | string | true | Name of the customer to appear in the CardView |
templateId | string | true | Look and feel of the card based on templateId, Bydefault its "default" |
env | string | true | based on env base url for webview will change eg. PROD, PROD_SANDBOX |
onDataResponse | Function | true | Add a call back function to receive the error & success event |
Basic call back event type
Event Types that can be handled
Event Name | Description |
---|---|
C91_CARD_DETAILS_FETCH_SUCCESS | Called when the server-side APIs load successfully. At this time, the card details are available, but they will be masked. |
C91_CARD_DETAILS_FETCH_FAILURE | Called when the server-side APIs fail to load. An error message would be visible in the CardView . |
C91_CARD_NUMBER_SHOWN | Called 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_SHOWN | Called 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_FAILURE | Call back event type when client is passing incorrect or expired auth token |
C91_CARD_MISSING_PARAMETER | Call back event type when client is not passing any required/blank parameter . |
C91_CARD_SERVER_FAILURE | Call back event type when there is server service exception with error code 500 to 599 |