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
  • Confirm Payment
  1. Providers

Square

PreviousStripeNextDodo Payments

Last updated 1 month ago

Setup

1

Get your Square Credentials

To use Square, you need an API token. You can get them from the .

2

Configure the provider

To configure the provider

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'square',
    apiToken: 'YOUR_SQUARE_API_TOKEN'
})  

Usage

To implement the complete payment flow. Checkout this .

Confirm Payment

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

Properties
  1. Source Id

  2. Amount

  3. Currency

import { BetterPay } from "better-pay"

const provider = new BetterPay({
    provider: 'square',
    apiToken: 'YOUR_SQUARE_API_TOKEN'
})  

const response = await provider.confirmPayment({
    sourceId: 'YOUR_SQUARE_SOURCE_ID',
    amount: 1000,
    currency: 'USD'
})
Response
  1. PaymentI Id

  2. Order Id

  3. Status

  4. Type

Square Dashboard
demo app