Document explain the process of integrating the flutter issue card plugin
Card91 issue card flutter plugin
This package is used to issue card for a customer based on the validated input taken on the form. This package directly communicates to Card91 SDK.
Features
Package directly communicate with the SDK (secured platform) to issue card and create a card holder.
Getting started
Add the widget package on your pubspec version
$ flutter pub add card91_plugin
Use this package as a library
Run this command: With Flutter:
flutter pub add card91_plugin
Import it
Now in your Dart code, you can use:
import 'package:card91_plugin/card91_flutter_library.dart';
Usage
Open the widget by passing the required parameter to use it. Check out the below code snippet for the same.
Sample code below
class OnBoarding extends StatefulWidget {
const OnBoarding({Key? key}) : super(key: key);
@override
State<OnBoarding> createState() => _OnBoardingState();
}
class _OnBoardingState extends State<OnBoarding> {
final Card91Controller _controller = Card91Controller();// create a instance of the Card91Controller which helps calling the SDK required function
String env=""; /// PROD_SANDBOX or PROD
String templateId=""; // template id will be provide separately eg."xoltt"
String cardProgramId="";// eg.230528190350397ID1CP9723194, card ID
String organizationId=""; // eg. 230526135544169ID1OID4070270, Organization id
String uniqueId="";// eg . unique, Unique Identifier
String authUrl=""; // Auth url which all application has to configure in order to get the business token
String cardMode=""; // eg. DIGITAL_ONLY_CARD, type of card user wanted to generate
String customFields="{\"step1\":[{\"name\":\"fullName\",\"displayText\":\"Full Name\",\"elements\":{\"type\":\"text\",\"defaultValue\":\"\"}},{\"name\":\"mobile\",\"displayText\":\"Mobile No.\",\"elements\":{\"type\":\"text\",\"defaultValue\":\"\"}},{\"name\":\"pan\",\"displayText\":\"PAN\",\"elements\":{\"type\":\"text\",\"defaultValue\":\"\"}},{\"name\":\"nameOnCard\",\"displayText\":\"Name on card\",\"elements\":{\"type\":\"text\",\"defaultValue\":\"\"}}]}";
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
color: Colors.black12,
child: Column(
children: [
IconButton(
onPressed: (){
_controller.callStep!("step2");
},
icon: Icon(
Icons.adb_outlined,
size: 30,
color: AppColors.blackFont,
),
),
const SizedBox(height: 20,),
IssueCard(
env: env,
templateId: templateId,
cardProgramId: cardProgramId,
organizationId: organizationId,
uniqueId: uniqueId,
authUrl: authUrl,
cardMode: cardMode,
customFields: customFields,
card91controller: _controller,
onDataResponse: (String dataResponse, String payload) {
print("dataResponse - $dataResponse");
print("payload - $payload");// Payload will contain the data reponse from issue card API
switch (dataResponse) {
case "C91_ISSUE_CARD_SCREEN_INITIALISED":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_AUTHENTICATION_FAILURE":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_SERVER_FAILURE":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_SCREEN_SUCCESS":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_MISSING_PARAMETER":
// Refer "Call Back Event Description" section for the same
break;
case 'C91_ISSUE_CARD_API_FAILURE':
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_EXTERNAL_AUTHENTICATION_FAILURE":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_EXTERNAL_SERVER_FAILURE":
// Refer "Call Back Event Description" section for the same
break;
case "C91_ISSUE_CARD_TOKEN_API_SUCCESS":
// Refer "Call Back Event Description" section for the same
break;
case 'C91_ISSUE_CARD_TOKEN_API_FAILURE':
// Refer "Call Back Event Description" section for the same
break;
case 'C91_ISSUE_CARD_EXTERNAL_MISSING_PARAMETER':
// Refer "Call Back Event Description" section for the same
break;
}
},),
// const SponsoredWidget(),
],
),
),
),
// const LoadingIndicatorConsumer<HomeViewModel>()
);
}
}
Sample steps JSON for "customFields" param
{
"step1": [
{
"name": "fullName",
"displayText": "Full Name",
"elements": {
"type": "text",
"defaultValue": "",
"disabled": true // For making the non editable field pass the value as true
}
},
{
"name": "mobile",
"displayText": "Mobile No.",
"elements": {
"type": "text",
"defaultValue": "",
"disabled": true
}
},
{
"name": "pan",
"displayText": "PAN",
"elements": {
"type": "text",
"defaultValue": "",
"disabled": true
}
},
{
"name": "nameOnCard",
"displayText": "Name on card",
"elements": {
"type": "text",
"defaultValue": "",
"disabled": true
}
}
]
}
For Issue Card takes the following props:
Input props
Name | Type | Required | Description |
---|---|---|---|
templateId | string | true | Use to indicate key for design template |
env | string | false | Use "PROD_SANDBOX" for production sandbox environment and "PROD" for production environment . |
cardProgramId | string | true | Card program id which come when you login with MPIN/Auth token |
organizationId | string | true | Need to pass business id |
uniqueId | string | true | Need to pass secret key auth url validation |
authUrl | string | true | Auth Url from client need pass in responses attached with token |
controller.callStep() | function | true | Pass string "step2" to move on to next step, "submit" on final submission |
customFields | object | true | Fields which represent which step have to show |
onDataResponse | function | true | Add a call back function to receive the error & success event, Type and payload Types are defined below and payload will contain the message. |
card91controller | string | true | value should be DIGITAL_ONLY_CARD / PHYSICAL_NAMED_CARD |
Call Back Event Type Description
Event Name | Description |
---|---|
C91_ISSUE_CARD_SCREEN_INITIALISED | The issue card screen SDK has been initialised. |
C91_ISSUE_CARD_SCREEN_SUCCESS | The API request related to the issue card was successful. That means card holder is created successfully. |
C91_ISSUE_CARD_API_FAILURE | The API request related to the issue card has failed. That means card holder is created not created due to api failed. Find the reason on the payload which client will receive in the widget. |
C91_ISSUE_CARD_AUTHENTICATION_FAILURE | Authentication for the issue card screen has failed. Thats mean Business Token generated from the AuthURL web-hook does not return the valid token which is passed to issue card API. |
C91_ISSUE_CARD_SERVER_FAILURE | The server encountered an error while processing the issue card API request. |
C91_ISSUE_CARD_MISSING_PARAMETER | A required parameter is missing in the issue card request. Client application has to make sure validate the params they are passing to SDK should correct and not empty. |
C91_ISSUE_CARD_TOKEN_API_SUCCESS | Thats means Business Auth Token from the Auth URL web hook received successfully. |
C91_ISSUE_CARD_TOKEN_API_FAILURE | While retrieving the Business Auth Token service has encounter a issue. |
C91_ISSUE_CARD_EXTERNAL_SERVER_FAILURE | An external server encountered an error while retrieving the Business Auth Token. |
C91_ISSUE_CARD_EXTERNAL_MISSING_PARAMETER | A required parameter is missing in the external issue card request. |
C91_ISSUE_CARD_EXTERNAL_AUTHENTICATION_FAILURE | Authentication for the external issue card request has failed. |