PYTHON - Business SDK services

Card91BusinessSDK Library can be used to get the business related services

Installation:

To install our package in your Django, Flask or FastAPI project follow the below steps and make sure you are inside a virtual environment.
Enter the following command into the terminal

pip install card91BusinessSDK

🚧

Important

Package support Django, Flask or FastAPI Framework

Usage:

After the successful installation of the project go to the file where you want to use our SDK. For example views.py
Import our package as below:
from card91_business_sdk import Card91BusinessSDK
Now we are ready to use our package. It contains the following 8 functions

Use the method to integrate place you want to use:

Method NameDescription
getCardDetailsuse to fetch card details
getCardholderStatususe to fetch customer status
loadFundToCarduse to load money to individual card
addAddressuse to create address for customer
getAddressuse to fetch customer addresses
printCarduse for converting virtual card to physical card
mapCustomerToInstakituse to map insta kit to customer

Request:

getCardDetails

Now for example if you want to use the getCardDetails with your flask app. Your code should look similar to the code below

@app.route("/yourEndpoint/<cardId>")  
def my_url(cardId):  
token = request.headers.get("Authorization").split()[1]  
config = {  
"environment": "PROD_SANDBOX",  // "PROD_SANDBOX" for production sandbox and "PROD" for production
"token": token,  // Business token
}  
payload = {"cardId": cardId}  // CardId for which detail reponse needed
response = Card91BusinessSDK.getCardDetails(config=config,  
payload=payload)  
return jsonify(response)

getCardholderStatus

Now for example if you want to use the getCardholderStatus with your flask app. Your code should look similar to the code below

@app.route("/yourEndpoint/<mobileNo>")
def getCardHolderStatus(mobileNo):
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {"mobileNo": mobileNo}
    response = Card91BusinessSDK.getCardHolderStatus(config=config, payload=payload)
    return jsonify(response)

addAddress

Now for example if you want to use the addAddress with your flask app. Your code should look similar to the code below

@app.route("/testAddAddress", methods=["POST"])
def addAddress():
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {
        "entityId":"221006115850551ID1CUSTID8228036",
        "entityType":"CUST",
        "address": 
            {
                "address1": "1142,card91 6th main road, sector 7",
                "address2": "Hsr layout",
                "addressType": "DELIVERY_ADDRESS",
                "pincode": "560102",
                "city": "Bangalore",
                "state": "KARNATAKA",
                "country": "IND"
            }
    }
    response = Card91BusinessSDK.addAddress(config=config, payload=payload)
    return jsonify(response)

getAddress

Now for example if you want to use the getCardDetails with your flask app. Your code should look similar to the code below

@app.route("/testGetAddress/<customerId>", methods=["GET"])
def getAddress(customerId):
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {"customerId": customerId}
    response = Card91BusinessSDK.getAddress(config=config, payload=payload)
    return jsonify(response)

printCard

Now for example if you want to use the getCardDetails with your flask app. Your code should look similar to the code below

@app.route("/testPrintCard", methods=["PUT"])
def printCard():
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {
        "cardId":"221104191215049ID1CARD5148700",
        "nameOnCard":"surya",
        "addressId":3123
    }
    response =  Card91BusinessSDK.printCard(config=config, payload=payload)
    return jsonify(response)

mapCustomerToInstakit

Now for example if you want to use the getCardDetails with your flask app. Your code should look similar to the code below

@app.route("/testMapCustomersToInstaKit", methods=["POST"])
def mapCustomersToInstaKit():
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {
        "kitNumber": "230000070080",
        "mobile": "916728065319",
        "orgId" :"230509105814076ID1OID4457878",
        "cardProgramId": "230509110159460ID1CP8610546"
    }
    response = Card91BusinessSDK.mapCustomersToInstaKit(config=config, payload=payload)
    return jsonify(response)

loadFundToCard

Now for example if you want to use the loadFundToCard with your flask app. Your code should look similar to the code below

@app.route("/testLoadFundToCard", methods=["POST"])
def addFundToCards():
    token = request.headers.get("Authorization").split()[1]
    config = {
        "environment": "PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
        "token": token,
    }
    payload = {
        "refId": "Ref53452",
        "walletId": "5676462b-3d80-43eb-a8fa-a399d0d8c893",
        "amount": "28"    
    }
    response = Card91BusinessSDK.loadFundToCard(config=config, payload=payload)
    return jsonify(response)

In this sample code we have a route and its endpoint is yourEndpoint and we are passing the cardId in the url as a parameter.

1-This will be the same for each framework in python whether it is Django, Flask or FastAPI.
2-We then fetch the token from the request headers. Make sure to validate the token as per your requirement. For example null validations or incorrect tokens.
3-Then we need to create a config dictionary which will have two keys named environment and token.
4-The environment will be according to the environment we are using in this example we are using the PROD_SANDBOX environment. Make sure to pass it in all caps.
5-Then we pass the token we fetched earlier.
6-Next we need to create a payload dict and pass on the cardId as key and value. In all of the remaining APIs if there is such a requirement it will follow the same steps unless it is an POST or PUT request which requires the payload here is an example

@app.route("/testLoadFundToCard", methods=["POST"])
defaddFundToCards():
token = request.headers.get("Authorization").split()[1]
config = {
"environment":"PROD_SANDBOX",// "PROD_SANDBOX" for production sandbox and "PROD" for production
"token":token, 
}
payload = {
        "refId": "Ref53452",
        "walletId": "5676462b-3d80-43eb-a8fa-a399d0d8c893",
        "amount": "28"    
    }
response=Card91BusinessSDK.loadFundToCard(config=config, payload=payload)
return jsonify(response)

This is for flask. For DRF, Django and FastAPI it will change accordingly. For example in DRF it will be payload = request.data.

Then create a response variable and use our import and the required method.
For example we need to use the getCardDetails so we need to use it like
Card91BusinessSDK.getCardDetails(config=config, payload=payload)
The config and the payload must be passed as arguments to the method.
In the end we can show the response as per our requirement. Here in flask we are using jsonify to show our response as a JSON response.