# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://better-pay.gitbook.io/better-pay/providers/square.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
