Stripe
Setup
1
Get your Stripe credentials.
To use Stripe, you need an API key. You can get them from the Stripe Dashboard.
Usage
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:
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
})
Confirm Payment
To confirm payment with stripe, you can use the confirmPayment
function provided by the provider. It takes object with following properties:
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';
})
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:
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
})
Last updated