-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
``` |