> For the complete documentation index, see [llms.txt](https://better-pay.gitbook.io/better-pay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://better-pay.gitbook.io/better-pay/providers/square.md).

# Square&#x20;

## Setup

{% stepper %}
{% step %}

### Get your Square Credentials

To use Square, you need an API token. You can get them from the [Square Dashboard](https://developer.squareup.com/).&#x20;
{% endstep %}

{% step %}

### Configure the provider

To configure the provider

```javascript
import { BetterPay } from "better-pay"

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

{% endstep %}
{% endstepper %}

## Usage

{% hint style="info" %}
To implement the complete payment flow. Checkout this [demo app](https://github.com/Muhammad-Owais-Warsi/square_demo).
{% endhint %}

### Confirm Payment

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

<details>

<summary>Properties</summary>

1. Source Id
2. Amount
3. Currency

</details>

```javascript
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'
})
```

<details>

<summary>Response</summary>

1. PaymentI Id
2. Order Id
3. Status
4. Type

</details>
