Better Pay
  • Introduction to Better Pay
  • Getting Started
    • Quickstart
  • Providers
    • Stripe
    • Square
    • Dodo Payments
  • Razorpay
  • Polar
  • Reference
    • Contributing
Powered by GitBook
On this page
  • Setup
  • Usage
  • Stripe Card Payments
  • Create payment
  • Confirm Payment
  • Stripe Payment Links.
  • Create payment link
  1. Providers

Stripe

PreviousQuickstartNextSquare

Last updated 1 month ago

Setup

1

Get your Stripe credentials.

To use Stripe, you need an API key. You can get them from the .

2

Configure the provider

To configure the provider

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'stripe',
    apiKey: 'YOUR_STRIPE_API_KEY'
})  

Usage

To implement the complete payment flow. Checkout this .

Stripe Card Payments

Create payment

To create payment with stripe, you can use the createPayment function provided by the provider. It takes object with following properties:

Properties
  1. Amount

  2. Currency

  3. Receipt Email (optional)

  4. Metadata (optional)

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'stripe',
    apiKey: 'YOUR_STRIPE_API_KEY'
})  

const response = await provider.createPayment({
    amount: 1000,
    currency: 'usd',
    receiptEmail: '', // optional
    metadat: {} // optional
})
Response
  1. Payment Intent Id

  2. Payment Intent Client Secret

  3. Status

  4. Type


Confirm Payment

To confirm payment with stripe, you can use the confirmPayment function provided by the provider. It takes object with following properties:

Properties
  1. Payment Intent Id

  2. Payment Method Id

  3. Return Url

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'stripe',
    apiKey: 'YOUR_STRIPE_API_KEY'
})  

const response = await provider.confirmPayment({
   paymentIntentId: 'YOUR_PAYMENT_INTENT_ID',
   paymentMethodId: 'YOUR_PAYMENT_INTENT_ID';
   returnUrl: 'URL_TO_RETURN_ON_SUCCESSFULL_PAYMENT';
})
Response
  1. Payment Intent Id

  1. Payment Intent Client Secret

  1. Status

  1. Type


Stripe Payment Links.

Create payment link

To create payment link with stripe, you can use the createPaymentLink function provided by the provider. It takes object with following properties:

Properties
  1. Name

  2. Amount

  3. Quantity (optional)

  4. Metadata (optional)

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'stripe',
    apiKey: 'YOUR_STRIPE_API_KEY'
})  

const response = await provider.createPaymentLink({
    name: ['NAME_OF_YOUR_PRODUCT'], //  You can add for multiple products.
    amount: [1000], // You can add for multiple products.
    currency: 'usd',
    quantity: '', // optional. By default set to 1
    metadat: {} // optional
})
Response
  1. Product Id

  2. Price Id

  3. Payment Link Id

  4. Payment Link

  5. Type

Stripe Dashboard
demo app