Skip to content

berlified/checkout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pocketsflow Checkout Boilerplate

A minimal Bun + TypeScript example demonstrating how to create a Pocketsflow Checkout Session for a subscription product using the Pocketsflow API.

Features

  • Bun + TypeScript
  • Hosted Checkout Session
  • Subscription product support
  • Environment variable configuration
  • Simple, production-ready structure

Prerequisites

  • Bun v1.3+
  • A Pocketsflow account
  • A Subscription Product created in the Pocketsflow Dashboard
  • Your Pocketsflow Secret API Key

Installation

Install dependencies:

bun install

Configuration

Create a .env file in the project root.

POCKETSFLOW_SECRET_KEY=your_secret_api_key

Usage

Update the following values inside src/index.ts:

productId: "YOUR_PRODUCT_ID",
successUrl: "https://yourdomain.com/success",
cancelUrl: "https://yourdomain.com/cancel",

Run the project:

bun run src/index.ts

or

bun src/index.ts

Example Response

{
  "id": "cs_xxxxxxxxxxxxxxxxx",
  "url": "https://checkout.pocketsflow.com/checkout?subscriptionId=..."
}

Redirect your customer to the returned url to start the checkout flow.


Project Structure

.
├── src
│   ├── index.ts
│   ├── pocketsflow.ts
│   └── types.ts
├── .env
├── package.json
└── tsconfig.json

Checkout Flow

Customer
    │
    ▼
Create Checkout Session
    │
    ▼
Receive Checkout URL
    │
    ▼
Redirect Customer
    │
    ▼
Hosted Pocketsflow Checkout
    │
    ▼
Successful Payment
    │
    ├── Redirect to Success URL
    └── Send Webhook to Your Backend

Next Steps

In a production application, you should:

  • Redirect users to the returned checkout URL.
  • Listen for Pocketsflow webhook events.
  • Update your database when a subscription becomes active.
  • Grant or revoke access based on the subscription status.

About

Create checkout session for subscriptions on pocketsflow

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages