API Reference

Add Address Card91 Flutter Plugin

Document explain the process of integrating the flutter print card plugin

Add Address Card91 Flutter Plugin

This package is used to print a digital only cards 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 take the print card request

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



import 'package:card91/app/login_screen/screens/card91_print_card.dart';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

class PrintCard extends StatefulWidget {
  const PrintCard({Key? key}) : super(key: key);

  @override
  State<PrintCard> createState() => _PrintCardState();
}

class _PrintCardState extends State<PrintCard> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Container(
          color: Colors.black12,
          child: Column(
            children: [
              const SizedBox(
                height: 20,
              ),
              Container(
                height: Get.height,
                width: Get.width,
                child: Card91PrintCard(

                  env: 'PROD_SANDBOX',
                  templateId: '<template id provided by Card91>',
                  cardId: '<card programs in Card91 portal>',//Card program ID
                  organizationId: '<business or the org id as in the Card91 Portal>',
                  uniqueId: 'string',
                  authUrl: 'https://your-domain-url/',
                  mobile: "<mobile number>",
                  customerId: "<customer id as in Card91 portal>",
                  onDataResponse: (String dataResponse, String payload) {
                    print("dataResponse111 - $dataResponse"+payload);

                    switch (dataResponse) {
                      case "C91_PRINT_CARD_SCREEN_INITIALISED":
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_AUTHENTICATION_FAILURE":
                        // Refer  "Call Back Event Description" section for the same

                        //String data =
                           // payload.substring(9, payload.trim().length - 1);
                        ///CustomDialog.customDialog(context, data);
                        break;
                      case "C91_PRINT_CARD_SERVER_FAILURE":
                       // print("11st response--->${payload.toString()}");

                        //var data =
                            //payload.substring(9, payload.trim().length - 1);

                        //CustomDialog.customDialog(context, data);
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_SCREEN_SUCCESS":
                        // Get.to(() => SuccessfulScreen(
                        //       screenType: "issueCard",
                        //       successMessage:
                        //           payload.substring(9, payload.trim().length - 1),
                        //     ));
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_MISSING_PARAMETER":
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case 'C91_PRINT_CARD_API_FAILURE':
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_EXTERNAL_AUTHENTICATION_FAILURE":
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_EXTERNAL_SERVER_FAILURE":
                        // Refer  "Call Back Event Description" section for the same
                        break;
                      case "C91_PRINT_CARD_TOKEN_API_SUCCESS":
                        // Refer  "Call Back Event Description" section for the same
                        // Navigate to successfully after calling print call function
                        //reposne type would be "C91_PRINT_CARD_API_SUCCESS" payload "{nameOnCard: Some name, addressId: 21354}"
                        break;
                      case 'C91_PRINT_CARD_TOKEN_API_FAILURE':
          							// Refer  "Call Back Event Description" section for the same
                        break;

                      case 'C91_PRINT_CARD_EXTERNAL_MISSING_PARAMETER':
        							 // Refer  "Call Back Event Description" section for the same
                        break;
                      case 'C91_FETCH_ADDRESS_API_FAILURE':
                        // Refer  "Call Back Event Description" section for the same
                        break;
                    }
                  },
                ),
              ),

              // const SponsoredWidget(),
            ],
          ),
        ),
      ),
    );
  }
}


For Issue Card takes the following props:

Input props

NameTypeRequiredDescription
templateIdstringtrueUse to indicate key for design template
envstringfalseUse "PROD_SANDBOX" for production sandbox environment and "PROD" for production environment .
cardIdstringtrueCard id of the card holder
organizationIdstringtrueNeed to pass business id
uniqueIdstringtrueNeed to pass secret key auth url validation
authUrlstringtrueAuth Url from client need pass in responses attached with token
onDataResponsefunctiontrueAdd a call back function to receive the error & success event,
Type and payload
Types are defined below and payload will contain the message.

Call Back Event Type Description

Event NameDescription
C91_PRINT_CARD_SCREEN_INITIALISEDThe add address screen SDK has been initialised.
C91_PRINT_CARD_API_SUCCESSThe API request related to the add address was successful.
That means card holder address added successfully.
Payload on success .
eg:{
"type": "C91_PRINT_CARD_API_SUCCESS",
"payload": {
"nameOnCard": "SAI KUMAR",
"addressId": 21336
}
}
Navigate to another screen on this event type and call print call
C91_PRINT_CARD_API_FAILUREThe API request related to the add address has failed.
That means card holder address is not added due to api failed.
Find the reason on the payload which client will receive in the widget.
C91_FETCH_ADDRESS_API_FAILUREWhile fetching the address from api encountered error
C91_PRINT_CARD_AUTHENTICATION_FAILUREAuthentication 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 add address API.
C91_PRINT_CARD_SERVER_FAILUREThe server encountered an error while processing the add address API request.
C91_PRINT_CARD_MISSING_PARAMETERA 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_PRINT_CARD_TOKEN_API_SUCCESSThats means Business Auth Token from the Auth URL web hook received successfully.
C91_PRINT_CARD_TOKEN_API_FAILUREWhile retrieving the Business Auth Token service has encounter a issue.
C91_PRINT_CARD_EXTERNAL_SERVER_FAILUREAn external server encountered an error while retrieving the Business Auth Token.
C91_PRINT_CARD_EXTERNAL_MISSING_PARAMETERA required parameter is missing in the add address card request.
C91_PRINT_CARD_EXTERNAL_AUTHENTICATION_FAILUREAuthentication for the external add address request has failed.