Skip to content

API monetization experiment with Stripe for a Dummy Data REST API

License

Notifications You must be signed in to change notification settings

belphegor-s/dummy-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dummy Data API (Metered Billing via Stripe)

  • This is a dummy data API that requires an API key in order to use it.
  • The user can pay for the API via Stripe Checkout by hitting the route: /api/v1/billing/checkout and getting a JSON response object having a url property that leads to Stripe Checkout.
  • After adding your card and successfull payment verification the Stripe server calls a webhook endpoint: /api/v1/billing/webhook, that verifies the checkout session and generate an API key (hashed and plain) and log it on the console along with saving it in a basic JSON database.

Note: The database used in the project is a bair-bones very basic JSON file (one for mapping Hashed API keys to respective customer IDs and another one in which customer ID is mapped to object containing data like - Hashed API Key, Item ID of subscribed product, is Subscription active and other details)

e.g.

root
└── database
    ├── apiKeys.json
    └── customers.json

apiKeys.json:

{
    "hashed_api_key": "cus_customer_id"
}

customers.json:

{
    "cus_id": {
        "apikey": "hashed_api_key",
        "itemId": "si_item_id",
        "active": true
    }
}

About

API monetization experiment with Stripe for a Dummy Data REST API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published