squareSquare

Setup

1

Get your Square Credentials

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

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

circle-info

To implement the complete payment flow. Checkout this demo apparrow-up-right.

Confirm Payment

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

chevron-rightPropertieshashtag
  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'
})
chevron-rightResponsehashtag
  1. PaymentI Id

  2. Order Id

  3. Status

  4. Type

Last updated