> For the complete documentation index, see [llms.txt](https://docs.bloqifi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bloqifi.com/reference/api-reference/payment.md).

# Payment

Making an authenticated call to the payment endpoint

## Get a new blockchain address

Bloqifi allows privacy minded users the ability to generate a new address using the API.

If users prefer to pay with balance, Bloqifi protect your privacy by generating a new address every time funds is received.

## Create address

<mark style="color:blue;">`GET`</mark> `https://api.bloqifi.com/v0/payment/:BLOCKCHAIN`

Create a new receiving address

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json      |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer ${accessToken} |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    address: address
}
```

{% endtab %}

{% tab title="503: Service Unavailable " %}

```javascript
{
    message: `Payment with ${blockchain} unavailable at the moment..`
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="curl" %}

```
curl -X POST https://api.bloqifi.com/v0/payment/${blockchain} \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}"
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const rawResponse = await fetch(`https://api.bloqifi.com/v0/payment/${blockchain}`, {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  }
});

const json = await rawResponse.json();

if (rawResponse.status === 200) {
  return json.address;
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** Note that all old used addresses are discarded by Bloqifi.

Do not send funds to any old address generated by Bloqifi.
{% endhint %}

## Generate payment request

Get payment request for storage / website using bloq `ObjectId` from [previous step](/reference/api-reference/bloq.md#merge-chunks-for-created-bloq).

## Get Payment Request

<mark style="color:green;">`POST`</mark> `https://api.bloqifi.com/v0/payment`

Get a new payment request

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json      |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer ${accessToken} |

#### Request Body

| Name                                         | Type   | Description                               |
| -------------------------------------------- | ------ | ----------------------------------------- |
| blockchain<mark style="color:red;">\*</mark> | String | `Bloqcoin`, `Dogecoin`, `Bitcoin`, `IPFS` |
| ids<mark style="color:red;">\*</mark>        | Array  | List of ids \[`'123', '321']`             |

{% tabs %}
{% tab title="402: Payment Required " %}

```javascript
{
	message: `${blockchain} waiting for transfer`,
	amount: 0.01,
	address: 'address'
}
```

{% endtab %}

{% tab title="503: Service Unavailable " %}

```javascript
{
	message: `Payment with ${blockchain} unavailable at the moment.`
}
```

{% endtab %}
{% endtabs %}

## Cancel Order

Cancel the payment, and remove any added bloqs, folders, chunk entries etc.

## Cancel order

<mark style="color:red;">`DELETE`</mark> `https://api.bloqifi.com/v0/payment`

Cancel generated payment request

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json      |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer ${accessToken} |

#### Request Body

| Name                                      | Type   | Description                  |
| ----------------------------------------- | ------ | ---------------------------- |
| address<mark style="color:red;">\*</mark> | String | Generated blockchain address |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
	message: 'Payment cancelled.'
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** This endpoint only affects bloq's with a status of 402 Payment Required
{% endhint %}
