Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

stripe create subscription

/*
	1) Create a stripe customer
    2) Create a product
    3) Create payment session
*/

// Create payment session
const amount = 100 // 100 usd

const session = await stripe.core.checkout.sessions.create({
   customer: customerId,
   payment_method_types: ['card'],
   line_items: [
     {
       price_data: {
         currency: 'usd',
         product: productId,
         unit_amount: amount * 100,
         recurring: {
           interval: 'month' // 'month' | 'year'
         }
       },
       quantity: 1
     }
   ],
   mode: 'subscription',
   success_url: successUrl,
   cancel_url: cancelUrl
 })
 
PREVIOUS NEXT
Tagged: #stripe #create #subscription
ADD COMMENT
Topic
Name
6+7 =