This repository shows how to create and tokenize credit cards with the Lithic Create Card API and forward this card to another API, for example Knot Card Swap, using Basis Theory Proxy.
Once you have a Management API Key
everything else is managed in your codebase
and this example we take 2 simple steps to make issuing and card swapping
seemless:
-
Use Basis Theory Pre-Configured Proxy to call tokenize card data returned from Lithic
sequenceDiagram participant backend as Backend participant proxy as Pre-configured Proxy participant lithic as Lithic API backend->>proxy: createCard proxy->>lithic: createCard lithic->>proxy: response(cardDetails) proxy->>proxy: tokenizeCard proxy->>backend: response(cardToken)
-
Use Basis Theory Ephemeral Proxy to forward the tokenized card data to KnotAPI
sequenceDiagram participant backend as Backend participant proxy as Ephemeral Proxy participant knot as Knot API backend->>proxy: updateUser(cardToken) proxy->>proxy: detokenizeCard proxy->>knot: updateUser(cardDetails) knot->>proxy: response proxy->>backend: response
-
Store the
knot_access_token
with your user and you are free to call the KnotAPI directly from your code without proxying any additioal calls through Basis Theory - avoiding any latency concerns!
-
Install dependencies
yarn install
-
Create a new Management Application with full
application
andproxy
permissions. -
Paste the API key to a new
terraform.tfvars
file at this repository root:# Basis Theory Management Application Key management_api_key = "key_W8wA8CmcbwXxJsomxeWHVy"
-
Initialize Terraform:
terraform init
-
Run Terraform to provision all the required resources:
terraform apply
-
Generate a Node.js
.env
file based off Terraform outputs:echo "BACKEND_APPLICATION_KEY=$(terraform output -raw backend_application_key)\nLITHIC_PROXY_KEY=$(terraform output -raw lithic_proxy_key)\nLITHIC_API_KEY=\nKNOT_API_SECRET=\nKNOT_CLIENT_ID=" > .env
-
Add your Lithic API Key, Knot API Key, and Knot Client Id to the
.env
file:BACKEND_APPLICATION_KEY=key_W8wA8CmcbwXxJsomxeWHVy LITHIC_PROXY_KEY=TzbxKOVFabX1YZfrZsGVN5 LITHIC_API_KEY=faf069d7-05ff-4d0e-b041-6c0d4d3c6f21 KNOT_API_SECRET=e6515555efc84ab097a5af7baa551982 KNOT_CLIENT_ID=555555-aae3-4cd5-8c5e-64cd293c0451
You can find more information on how to get your Lithic Sandbox API Keys here.
-
Run
yarn start