Skip to content

Commit

Permalink
feat(transfer): create doc (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eckzzo authored Jul 10, 2023
1 parent bcef9a5 commit 41829eb
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/transfer/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"label": "Transferência",
"collapsible": true,
"collapsed": true,
"className": "red",
"link": {
"type": "generated-index",
"title": "Transferência visão geral"
},
"customProps": {
"description": "Transferência documentação"
}
}
88 changes: 88 additions & 0 deletions docs/transfer/how-to-transfer-values-between-accounts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
id: how-to-create-charge-with-split-using-api
title: Como usar a API para criar uma cobrança com split?
tags:
- concept
- api
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::info
Para a ultilização dessa funcionalidade é necessário possuir a funcionalidade BETA
:::

Para transferir valores entre suas subcontas você por utilizar o _endpoint_ `/api/v1/transfer` da API.

Os campos obrigatórios para criar uma transferência entre sub contas são os seguintes:

- **`value`**: O valor em centavos a ser transferido.
- **`fromPixKey`**: A chave pix da conta de origem
- **`toPixKey`**: A chave pix da conta de destino

## Exemplo

O body da sua requisição será semelhante a este exemplo:

```json
{
"value": 100,
"fromPixKey": "[email protected]",
"toPixKey": "[email protected]"
}
```

O valor do campo `value` é o valor desejado para a transferência em **centavos**.

Após efetuar a requisição, se tudo ocorreu bem, o _status code_ da requisição será `2xx` e no `body` da resposta, será retornado os seguintes campos:

```json
{
"transaction": {
"value": 100,
"time": "2023-06-22T15:33:27.165Z",
"correlationID": "c782e0ac-833d-4a89-9e73-9b60b2b41d3a"
}
}
```

### Exemplos em código

```mdx-code-block
<Tabs>
<TabItem value="shell-curl" label="Shell + cURL" default>
```

```sh
curl 'https://api.openpix.com.br/api/v1/transfer' -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "user-agent: node-fetch" \
--data-binary '{"value": 100, "fromPixKey": "[email protected]", "toPixKey": "[email protected]"}'
```

```mdx-code-block
</TabItem>
<TabItem value="javascript" label="JavaScript + Fetch" default>
```

```js
fetch('https://api.openpix.com.br/api/v1/transfer', {
method: 'POST',
body: JSON.stringify({
value: 100,
fromPixKey: '[email protected]',
toPixKey: '[email protected]',
}),
headers: {
Authorization: 'AUTHORIZATION',
'Content-Type': 'application/json',
},
}).then((res) => res.json());
```

```mdx-code-block
</TabItem>
</Tabs>
```

0 comments on commit 41829eb

Please sign in to comment.