Square

Setup

1

Get your Square Credentials

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

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 demo app.

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

Last updated