Better Pay
  • Introduction to Better Pay
  • Getting Started
    • Quickstart
  • Providers
    • Stripe
    • Square
    • Dodo Payments
  • Razorpay
  • Polar
  • Reference
    • Contributing
Powered by GitBook
On this page
  • Usage
  • Create payment
  • Confirm payment

Polar

PreviousRazorpayNextContributing

Last updated 17 days ago

Setup

1

Get your Polar credentials.

To use Dodo Payments, 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: 'polar',
    accessToke: 'YOUR_ACCESS_TOKEN'
})  

Usage

To implement the complete payment flow. Checkout this .

Create payment

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

Properties
  1. Name

  2. Amount

  3. Currency

  4. Metadata (optional)

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
})
Response
  1. Product Id

  2. Type


Confirm payment

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

Properties
  1. Product Id

  2. Return Url

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'
})
Response
  1. Client Secret

  2. Payment Link (use this link to make payment)

  3. Type

Polar Dashboard
demo app