Skip to content

Basis-Theory-Labs/lithic-knot-example

Repository files navigation

Lithic / Knot Example

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:

  1. 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)
    
    Loading
  2. 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
    
    Loading
  3. 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!

Run this POC

  1. Install dependencies

    yarn install
  2. Create a new Management Application with full application and proxy permissions.

  3. Paste the API key to a new terraform.tfvars file at this repository root:

    # Basis Theory Management Application Key
    management_api_key = "key_W8wA8CmcbwXxJsomxeWHVy"
  4. Initialize Terraform:

    terraform init
  5. Run Terraform to provision all the required resources:

    terraform apply
  6. 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
  7. 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.

  8. Run yarn start

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published