Polar
Setup
1
Get your Polar credentials.
To use Dodo Payments, you need an API key. You can get them from the Polar Dashboard.
Usage
Create payment
To create payment with polar, 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: 'polar',
accessToke: 'YOUR_ACCESS_TOKEN'
})
const response = await provider.createPayment({
name: 'NAME_OF_PRODUCT',
amount: 10000,
currency: 'usd',
organizationId: 'YOUR_ORGANIZATION_ID', // optional
metadata: {} // optional
})
Confirm payment
To confirm payment with polar, 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: 'polar',
accessToke: 'YOUR_ACCESS_TOKEN'
})
const response = await provider.confirmPayment({
productId: ['PRODUCT_ID'], // You can add more product id's seperated by comma.
returnUrl: 'YOUR_RETURN_URL_AFTER_SUCCESSFULL_PAYMENT'
})
Last updated