### GET /api/v1/js/get3dsSettings
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Retrieves the 3DS security configuration settings required to initialize the payment flow and determine the authentication method.
```APIDOC
## GET /api/v1/js/get3dsSettings
### Description
Fetches the 3DS security settings based on the provided public key. This determines if 3DS is enabled and which method (IFRAME, REDIRECT, SCRIPT) should be used for authentication.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/api/v1/js/get3dsSettings
### Parameters
#### Query Parameters
- **publicKey** (string) - Required - The public key used to identify and authenticate the application.
### Request Example
GET https://api.sharkbanking.com.br/api/v1/js/get3dsSettings?publicKey=pk_...
### Response
#### Success Response (200)
- **threeDSSecurity** (boolean) - Indicates if 3DS authentication is active.
- **threeDSSecurityType** (string) - The method used: NONE, IFRAME, REDIRECT, or SCRIPT.
- **iframeUrl** (string) - The URL to load in an iframe if the type is IFRAME.
- **hideCardForm** (boolean) - Indicates if the standard card form should be hidden.
#### Response Example
{
"threeDSSecurity": false,
"threeDSSecurityType": "NONE",
"iframeUrl": null,
"hideCardForm": false
}
```
--------------------------------
### GET /v1/anticipations
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Lists all anticipation requests.
```APIDOC
## GET /v1/anticipations
### Description
Lists all anticipation requests.
### Method
GET
### Endpoint
/v1/anticipations
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of anticipations to return.
- **offset** (integer) - Optional - The number of anticipations to skip.
### Response
#### Success Response (200)
- **anticipations** (array) - A list of anticipation objects.
- **anticipation_id** (string) - The unique identifier for the anticipation.
- **status** (string) - The status of the anticipation.
- **anticipation_date** (string) - The date of the anticipation.
#### Response Example
```json
{
"anticipations": [
{
"anticipation_id": "ant_uvw987xyz",
"status": "approved",
"anticipation_date": "2023-11-15"
},
{
"anticipation_id": "ant_rst654mno",
"status": "pending",
"anticipation_date": "2023-11-20"
}
]
}
```
```
--------------------------------
### Prepare 3DS Authentication Parameters (Node.js)
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Prepares the necessary parameters for 3DS authentication. It's recommended to call this function before `encrypt` and whenever `amount`, `installments`, or `currency` change. Ensure monetary values are converted to cents using `convertDecimalToCents`.
```javascript
const currency = "BRL";
const amount = window["ShieldHelper"].convertDecimalToCents(3.50, currency); // Valor em centavos: 350
await window["ShieldHelper"].prepareThreeDS({
amount: 350, // Valor da transação em centavos da moeda "currency"
installments: 1, // Número de parcelas
});
```
--------------------------------
### Get 3DS Settings from SharkBanking API
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Make a GET request to the 'get3dsSettings' endpoint with your public key to retrieve essential configurations for the 3DS authentication process. This call authenticates and identifies your application.
```javascript
const publicKey = "pk_...";
const response = await fetch('https://api.sharkbanking.com.br/api/v1/js/get3dsSettings?publicKey=${publicKey}',
{
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
}
);
const data = await response.json();
console.log("Resultado da API ao carregar:", data);
```
--------------------------------
### Prepare 3DS Authentication
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Call the `prepareThreeDS()` function to prepare the necessary parameters for 3DS authentication. It's recommended to call this function whenever `amount`, `installments`, or `currency` values change. Ensure `amount` is converted to cents using `convertDecimalToCents()` before calling.
```APIDOC
## POST /prepareThreeDS
### Description
Prepares parameters for 3DS transaction authentication.
### Method
POST
### Endpoint
/prepareThreeDS
### Parameters
#### Request Body
- **amount** (integer) - Required - The transaction amount in cents.
- **installments** (integer) - Required - The number of installments.
### Request Example
```json
{
"amount": 350,
"installments": 1
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "prepared"
}
```
```
--------------------------------
### GET /v1/balance
Source: https://app.sharkbanking.com.br/docs/sales/create-sale
Retrieves the current balance information.
```APIDOC
## GET /v1/balance
### Description
Retrieves the current balance information.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/balance
### Response
#### Success Response (200)
- **availableBalance** (integer) - The available balance in cents.
- **currentBalance** (integer) - The current total balance in cents.
#### Response Example
```json
{
"availableBalance": 150000,
"currentBalance": 175000
}
```
```
--------------------------------
### GET /v1/anticipations/{id}
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Retrieves details of a specific anticipation request.
```APIDOC
## GET /v1/anticipations/{id}
### Description
Retrieves details of a specific anticipation request.
### Method
GET
### Endpoint
/v1/anticipations/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the anticipation.
### Response
#### Success Response (200)
- **anticipation_id** (string) - The unique identifier for the anticipation.
- **status** (string) - The status of the anticipation.
- **anticipation_date** (string) - The date of the anticipation.
- **transactions** (array) - A list of transactions included in the anticipation.
#### Response Example
```json
{
"anticipation_id": "ant_uvw987xyz",
"status": "approved",
"anticipation_date": "2023-11-15",
"transactions": [
{
"transaction_id": "txn_12345abcde",
"amount": 100
}
]
}
```
```
--------------------------------
### GET /v1/withdrawals
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Lists all withdrawal requests.
```APIDOC
## GET /v1/withdrawals
### Description
Lists all withdrawal requests.
### Method
GET
### Endpoint
/v1/withdrawals
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of withdrawals to return.
- **offset** (integer) - Optional - The number of withdrawals to skip.
### Response
#### Success Response (200)
- **withdrawals** (array) - A list of withdrawal objects.
- **withdrawal_id** (string) - The unique identifier for the withdrawal.
- **amount** (integer) - The amount withdrawn.
- **status** (string) - The status of the withdrawal.
#### Response Example
```json
{
"withdrawals": [
{
"withdrawal_id": "wdl_abc123xyz",
"amount": 200,
"status": "processing"
},
{
"withdrawal_id": "wdl_def456uvw",
"amount": 150,
"status": "approved"
}
]
}
```
```
--------------------------------
### Create Sale Transaction (Python)
Source: https://app.sharkbanking.com.br/docs/sales/create-sale
This Python example demonstrates creating a sale transaction using the Sharkbanking API. It employs the 'requests' library to send a POST request with the transaction payload.
```python
import requests
url = 'https://api.sharkbanking.com.br/v1/transactions'
transaction_data = {
'amount': 10000, # in cents
'paymentMethod': 'credit_card',
'installments': 1,
'card': {
'number': '...',
'cvv': '...',
'expiryMonth': '..',
'expiryYear': '..'
},
'items': [
{ 'name': 'Product A', 'quantity': 1, 'price': 10000 }
],
'customer': {
'name': 'John Doe',
'document': '12345678900',
'email': 'john.doe@example.com'
}
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS'
}
response = requests.post(url, json=transaction_data, headers=headers)
print(response.json())
```
--------------------------------
### Create Sale Transaction (Node.js)
Source: https://app.sharkbanking.com.br/docs/sales/create-sale
This code example shows how to initiate a sale transaction using the Sharkbanking API with Node.js. It utilizes the 'axios' library to send a POST request with the transaction details.
```javascript
// Example using axios library
const axios = require('axios');
const createSale = async (transactionData) => {
try {
const response = await axios.post('https://api.sharkbanking.com.br/v1/transactions', transactionData, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS'
}
});
return response.data;
} catch (error) {
console.error('Error creating sale:', error);
throw error;
}
};
// Example usage:
// const transactionDetails = {
// amount: 10000, // in cents
// paymentMethod: 'credit_card',
// installments: 1,
// card: {
// number: '...',
// cvv: '...',
// expiryMonth: '..',
// expiryYear: '..'
// },
// items: [
// { name: 'Product A', quantity: 1, price: 10000 }
// ],
// customer: {
// name: 'John Doe',
// document: '12345678900',
// email: 'john.doe@example.com'
// }
// };
// createSale(transactionDetails).then(data => console.log(data));
```
--------------------------------
### GET /v1/balance
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Retrieves the current balance of the account.
```APIDOC
## GET /v1/balance
### Description
Retrieves the current balance of the account.
### Method
GET
### Endpoint
/v1/balance
### Response
#### Success Response (200)
- **available_balance** (integer) - The available balance in the account.
- **current_balance** (integer) - The current balance in the account.
#### Response Example
```json
{
"available_balance": 1500,
"current_balance": 1600
}
```
```
--------------------------------
### GET /saldo
Source: https://app.sharkbanking.com.br/docs/intro/tokenizing-card
Retrieves the current account balance for the authenticated company.
```APIDOC
## GET /saldo
### Description
Fetches the current available balance for the company account.
### Method
GET
### Endpoint
/saldo
### Response
#### Success Response (200)
- **available_balance** (number) - The total available funds.
- **currency** (string) - The currency code (e.g., BRL).
```
--------------------------------
### GET /v1/antecipation
Source: https://app.sharkbanking.com.br/docs/antecipation/list-antecipations
Retrieves a paginated list of all anticipations associated with the account.
```APIDOC
## GET /v1/antecipation
### Description
The GET `/antecipation` endpoint allows users to retrieve a paginated list of all anticipations. This is useful for auditing and tracking financial anticipation requests.
### Method
GET
### Endpoint
`https://api.sharkbanking.com.br/v1/antecipation`
### Parameters
#### Query Parameters
- **page** (int32) - Optional - The page number to retrieve. Defaults to 1.
- **pageSize** (int32) - Optional - The number of items per page. Defaults to 20, max 50.
### Request Example
```bash
curl --request GET \
--url https://api.sharkbanking.com.br/v1/antecipation \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
- **data** (array) - List of anticipation objects.
- **meta** (object) - Pagination metadata.
#### Error Response (400)
- **error** (string) - Description of the failure.
```
--------------------------------
### Listar Vendas com Python
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Exemplo de como listar vendas utilizando Python. Este código demonstra como fazer uma requisição GET para a API Sharkbanking com autenticação Basic.
```Python
import requests
url = "https://api.sharkbanking.com.br/v1/transactions"
headers = {
'accept': 'application/json',
'authorization': 'Basic Og=='
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise an exception for bad status codes
print(response.json())
except requests.exceptions.RequestException as e:
print(f"Error listing sales: {e}")
```
--------------------------------
### Retrieve Withdrawal Details using GET /transfers/{id}
Source: https://app.sharkbanking.com.br/docs/withdraw/find-withdraw
The GET /transfers/{id} route allows retrieving the details of a withdrawal by its ID. It requires a withdrawal key in the header and the withdrawal ID in the path. Responses include success (200) or failure (400) objects.
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transfers/%7Bid%7D \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### GET /v1/company
Source: https://app.sharkbanking.com.br/docs/company/company-data
Retrieves the details of the company associated with the API credentials.
```APIDOC
## GET /v1/company
### Description
Retrieves the profile and configuration data for the company account.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/company
### Parameters
#### Path Parameters
- None
#### Query Parameters
- None
#### Request Body
- None
### Request Example
```bash
curl --request GET \
--url https://api.sharkbanking.com.br/v1/company \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
- **data** (object) - Company information object
#### Response Example
{
"company_name": "Example Corp",
"status": "active"
}
```
--------------------------------
### Listar Vendas com Node.js
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Exemplo de como listar vendas utilizando Node.js. Este código demonstra como fazer uma requisição GET para a API Sharkbanking com autenticação Basic.
```Node.js
const axios = require('axios');
const listSales = async () => {
try {
const response = await axios.get('https://api.sharkbanking.com.br/v1/transactions', {
headers: {
'accept': 'application/json',
'authorization': 'Basic Og=='
}
});
console.log(response.data);
} catch (error) {
console.error('Error listing sales:', error);
}
};
listSales();
```
--------------------------------
### GET /v1/transactions
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Lists all transactions associated with the account.
```APIDOC
## GET /v1/transactions
### Description
Lists all transactions associated with the account.
### Method
GET
### Endpoint
/v1/transactions
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of transactions to return.
- **offset** (integer) - Optional - The number of transactions to skip.
### Response
#### Success Response (200)
- **transactions** (array) - A list of transaction objects.
- **transaction_id** (string) - The unique identifier for the transaction.
- **amount** (integer) - The amount of the transaction.
- **paymentMethod** (string) - The payment method used.
- **status** (string) - The current status of the transaction.
#### Response Example
```json
{
"transactions": [
{
"transaction_id": "txn_12345abcde",
"amount": 100,
"paymentMethod": "pix",
"status": "completed"
},
{
"transaction_id": "txn_67890fghij",
"amount": 50,
"paymentMethod": "credit_card",
"status": "pending"
}
]
}
```
```
--------------------------------
### List Withdrawals - PHP
Source: https://app.sharkbanking.com.br/docs/withdraw/list-withdraw
A PHP example for listing withdrawals using cURL. This snippet demonstrates how to set up the cURL request with the necessary headers and URL for the Sharkbanking API.
```php
```
--------------------------------
### Listar Vendas com Ruby
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Exemplo de como listar vendas utilizando Ruby. Este código demonstra como fazer uma requisição GET para a API Sharkbanking com autenticação Basic.
```Ruby
require 'net/http'
require 'uri'
uri = URI.parse('https://api.sharkbanking.com.br/v1/transactions')
request = Net::HTTP::Get.new(uri)
request['accept'] = 'application/json'
request['authorization'] = 'Basic Og=='
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
```
--------------------------------
### Retrieve Antecipation Details via GET API
Source: https://app.sharkbanking.com.br/docs/antecipation/find-antecipation
Retrieves the details of a specific antecipation using its unique ID. Requires Basic authentication and returns a JSON object representing the antecipation status and data.
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/antecipation/{id} \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### Create Transaction
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Create the transaction using the hash returned by the `encrypt()` function in the `card` object. If `threeDSSecurityType` is `REDIRECT`, include the `returnURL` parameter.
```APIDOC
## POST /transactions
### Description
Creates a transaction with encrypted card data. Requires `returnURL` if `threeDSSecurityType` is `REDIRECT`.
### Method
POST
### Endpoint
/transactions
### Parameters
#### Request Body
- **card** (object) - Required - Contains the encrypted transaction data.
- **token** (string) - Required - The token generated by the encrypt function.
- **threeDSSecurityType** (string) - Required - Type of 3DS security. e.g., 'REDIRECT'.
- **returnURL** (string) - Optional - The URL to redirect to after 3DS completion, required if `threeDSSecurityType` is 'REDIRECT'.
### Request Example
```json
{
"card": {
"token": "encrypted_token_string"
},
"threeDSSecurityType": "REDIRECT",
"returnURL": "https://your-merchant-site.com/3ds-callback"
}
```
### Response
#### Success Response (200)
- **transactionId** (string) - The unique identifier for the created transaction.
- **redirectUrl** (string) - The URL for 3DS redirection if applicable.
#### Response Example
```json
{
"transactionId": "txn_12345abcde",
"redirectUrl": "https://3ds-provider.com/auth?token=xyz789"
}
```
```
--------------------------------
### GET /v1/transfers/
Source: https://app.sharkbanking.com.br/docs/withdraw/list-withdraw
Retrieves a paginated list of all withdrawals associated with the user account.
```APIDOC
## GET /v1/transfers/
### Description
The GET /transfers endpoint allows users to retrieve a list of all their withdrawals. It supports pagination to manage large datasets efficiently.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/transfers/
### Parameters
#### Header Parameters
- **x-withdraw-key** (string) - Required - External withdrawal key linked to the user.
#### Query Parameters
- **page** (int32) - Optional - Page number to retrieve. Default is 1.
- **pageSize** (int32) - Optional - Number of items per page. Default is 20, max is 50.
### Request Example
```bash
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transfers/ \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
- **data** (array) - List of withdrawal objects with pagination metadata.
#### Error Response (400)
- **error** (object) - Details regarding the failure of the request.
```
--------------------------------
### Obter Saldo
Source: https://app.sharkbanking.com.br/docs/balance/get-balance
Retrieve the available balance using the `/balance/available` endpoint. This endpoint is used to get the current available balance.
```APIDOC
## GET /v1/balance/available
### Description
Utilize the route `/balance/available` to obtain your available balance.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/balance/available
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/balance/available \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
Objeto de resposta em caso de sucesso na consulta de saldo
#### Error Response (400)
Objeto de resposta em caso de falha
```
--------------------------------
### Listar Vendas com PHP
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Exemplo de como listar vendas utilizando PHP. Este código demonstra como fazer uma requisição GET para a API Sharkbanking com autenticação Basic.
```PHP
```
--------------------------------
### Retrieve Company Data via SharkBanking API
Source: https://app.sharkbanking.com.br/docs/company/company-data
Fetches company-related information using a GET request to the /v1/company endpoint. Requires Basic Authentication and returns a JSON object indicating success or failure.
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/company \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### Include SharkBanking Tokenization Library
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Include the SharkBanking JavaScript tokenization library in your HTML header to enable card tokenization for credit card transactions. Ensure the setPublicKey method is called upon screen load.
```html
// IMPORTANTE: Certifique-se de que o setPublicKey seja chamado assim que a tela for carregada.
const publicKey = "pk_...";
const moduleName = window["ShieldHelper"].getModuleName();
await window[moduleName].setPublicKey(publicKey);
```
--------------------------------
### Listar Vendas com cURL
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Exemplo de como listar vendas utilizando cURL. Este comando envia uma requisição GET para a API Sharkbanking com autenticação Basic.
```Shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transactions \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### Dynamically Create and Append Iframe for 3DS Authentication
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Dynamically create an iframe element using the ID obtained from 'window["ShieldHelper"].getIframeId()' and set its source to the 'iframeUrl' provided in the 3DS settings. Append this iframe to your payment form for a seamless user experience.
```javascript
const iframeId = window["ShieldHelper"].getIframeId();
const iframe = document.createElement("iframe");
iframe.id = iframeId;
// Define a URL do iframe com base no campo 'iframeUrl' retornado pelo método get3dsSettings
iframe.src = settings.iframeUrl;
iframe.width = "100%";
iframe.height = "400px";
iframe.style.border = "none";
// Insere o iframe dentro de um contêiner no formulário, se houver
document.getElementById("payment-form")?.appendChild(iframe);
```
--------------------------------
### Retrieve Sale Details by ID (Shell)
Source: https://app.sharkbanking.com.br/docs/sales/find-sale
The GET /transactions/{id} route allows retrieving specific sale details using the transaction's unique identifier. This is useful for obtaining detailed information about a previously created transaction. Requires basic authentication.
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transactions/%7Bid%7D \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### POST /v1/anticipations
Source: https://app.sharkbanking.com.br/docs/sales/create-sale
Creates an anticipation request.
```APIDOC
## POST /v1/anticipations
### Description
Creates an anticipation request.
### Method
POST
### Endpoint
https://api.sharkbanking.com.br/v1/anticipations
### Parameters
#### Request Body
- **transactionIds** (array of strings) - Required - List of transaction IDs to anticipate.
- **bankAccount** (object) - Required - Details of the bank account for the anticipation payout.
- **bankCode** (string) - Required - Bank code.
- **agency** (string) - Required - Bank agency number.
- **accountNumber** (string) - Required - Bank account number.
- **accountType** (string) - Required - Account type ('checking' or 'savings').
- **document** (string) - Required - Account holder's document number.
- **name** (string) - Required - Account holder's name.
### Request Example
```json
{
"transactionIds": ["txn_abc123xyz", "txn_def456uvw"],
"bankAccount": {
"bankCode": "001",
"agency": "1234",
"accountNumber": "56789-0",
"accountType": "checking",
"document": "12345678900",
"name": "John Doe"
}
}
```
### Response
#### Success Response (200)
- **anticipationId** (string) - Unique identifier for the anticipation request.
- **status** (string) - Status of the anticipation request.
#### Response Example
```json
{
"anticipationId": "ant_abc123xyz",
"status": "processing"
}
```
```
--------------------------------
### POST /v1/anticipations
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Creates a new anticipation request.
```APIDOC
## POST /v1/anticipations
### Description
Creates a new anticipation request.
### Method
POST
### Endpoint
/v1/anticipations
### Parameters
#### Request Body
- **transaction_ids** (array) - Required - A list of transaction IDs to anticipate.
- **anticipation_date** (string) - Required - The desired date for the anticipation (YYYY-MM-DD).
### Request Example
```json
{
"transaction_ids": ["txn_12345abcde", "txn_67890fghij"],
"anticipation_date": "2023-11-15"
}
```
### Response
#### Success Response (200)
- **anticipation_id** (string) - The unique identifier for the anticipation.
- **status** (string) - The status of the anticipation (e.g., 'pending', 'approved').
#### Response Example
```json
{
"anticipation_id": "ant_uvw987xyz",
"status": "pending"
}
```
```
--------------------------------
### Tokenize credit card data
Source: https://app.sharkbanking.com.br/docs/intro/tokenizing-card
This snippet demonstrates how to initialize the SharkBanking library in the browser and generate a secure card token using Node.js. The process involves setting a public key and encrypting card details before sending them to the API.
```HTML
// IMPORTANTE: Certifique-se de que o setPublicKey seja chamado assim que a tela for carregada.
await SharkBanking.setPublicKey("chave_publica_da_company");
```
```Node.js
try {
const card = {
number: "123456789",
holderName: "João Silva",
expMonth: 1,
expYear: 2026,
cvv: "456"
}
const token = await SharkBanking.encrypt(card);
console.error('Token:', token);
} catch (error) {
console.error('Erro na requisição:', error);
}
```
--------------------------------
### GET /v1/withdrawals/{id}
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Retrieves details of a specific withdrawal request.
```APIDOC
## GET /v1/withdrawals/{id}
### Description
Retrieves details of a specific withdrawal request.
### Method
GET
### Endpoint
/v1/withdrawals/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the withdrawal.
### Response
#### Success Response (200)
- **withdrawal_id** (string) - The unique identifier for the withdrawal.
- **amount** (integer) - The amount withdrawn.
- **status** (string) - The status of the withdrawal.
- **created_at** (string) - The timestamp when the withdrawal was created.
#### Response Example
```json
{
"withdrawal_id": "wdl_abc123xyz",
"amount": 200,
"status": "processing",
"created_at": "2023-10-27T10:00:00Z"
}
```
```
--------------------------------
### GET /v1/transactions
Source: https://app.sharkbanking.com.br/docs/sales/create-sale
Retrieves a list of sales transactions based on specified filters.
```APIDOC
## GET /v1/transactions
### Description
Retrieves a list of sales transactions based on specified filters.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/transactions
### Parameters
#### Query Parameters
- **startDate** (string) - Optional - Start date for filtering transactions (YYYY-MM-DD).
- **endDate** (string) - Optional - End date for filtering transactions (YYYY-MM-DD).
- **status** (string) - Optional - Filter transactions by status (e.g., 'paid', 'pending', 'failed').
- **paymentMethod** (string) - Optional - Filter transactions by payment method (e.g., 'credit_card', 'boleto', 'pix').
### Response
#### Success Response (200)
- **transactions** (array of objects) - A list of transaction objects.
- **transactionId** (string) - Unique identifier for the transaction.
- **status** (string) - Current status of the transaction.
- **amount** (integer) - Total transaction value in cents.
- **paymentMethod** (string) - Method used for payment.
- **createdAt** (string) - Timestamp when the transaction was created.
#### Response Example
```json
{
"transactions": [
{
"transactionId": "txn_abc123xyz",
"status": "paid",
"amount": 10000,
"paymentMethod": "credit_card",
"createdAt": "2023-10-27T10:00:00Z"
},
{
"transactionId": "txn_def456uvw",
"status": "pending",
"amount": 5000,
"paymentMethod": "pix",
"createdAt": "2023-10-27T10:05:00Z"
}
]
}
```
```
--------------------------------
### GET /v1/transactions
Source: https://app.sharkbanking.com.br/docs/sales/list-sales
Retrieves a paginated list of all transactions associated with the account.
```APIDOC
## GET /v1/transactions
### Description
Allows the retrieval of a paginated list of all sales/transactions.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/transactions
### Parameters
#### Query Parameters
- **page** (int32) - Optional - Page number for results (default: 1).
- **pageSize** (int32) - Optional - Number of items per page (default: 20, max: 50).
### Request Example
```bash
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transactions \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
- **data** (array) - List of transaction objects with pagination metadata.
#### Response Example
{
"transactions": [],
"pagination": {
"page": 1,
"pageSize": 20
}
}
```
--------------------------------
### Authenticate and Execute POST Request with Node.js
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Demonstrates how to perform an authenticated POST request to the SharkBanking API using Basic Auth. It constructs the Authorization header by encoding the public and secret keys in Base64 and sends a JSON payload via the fetch API.
```javascript
try {
const url = 'https://api.sharkbanking.com.br/v1/transactions';
const publicKey = 'PUBLIC_KEY';
const secretKey = 'SECRET_KEY';
const auth = 'Basic ' + Buffer.from(publicKey + ':' + secretKey).toString('base64');
const payload = {
amount: 100,
paymentMethod: 'pix',
// Valores do payload aqui...
};
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: auth,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Erro na requisição:', error);
}
```
--------------------------------
### Card Tokenization
Source: https://app.sharkbanking.com.br/docs/intro/tokenizing-card
Explains how to securely tokenize credit card data using the SharkBanking JavaScript library before sending it to the backend.
```APIDOC
## Card Tokenization
### Description
To perform credit card transactions, you must tokenize the card data on the client-side to ensure security. This process involves using the SharkBanking JS library to generate a secure token.
### Implementation
1. Include the script in your HTML header:
``
2. Initialize with your Public Key:
`await SharkBanking.setPublicKey("chave_publica_da_company");`
3. Generate the token:
```javascript
const token = await SharkBanking.encrypt(cardData);
```
```
--------------------------------
### GET /v1/transactions/{id}
Source: https://app.sharkbanking.com.br/docs/sales/find-sale
Retrieves the detailed information of a specific transaction using its unique identifier.
```APIDOC
## GET /v1/transactions/{id}
### Description
Retrieves the details of a specific transaction by its unique ID.
### Method
GET
### Endpoint
https://api.sharkbanking.com.br/v1/transactions/{id}
### Parameters
#### Path Parameters
- **id** (int32) - Required - The unique identifier of the transaction.
### Request Example
```bash
curl --request GET \
--url https://api.sharkbanking.com.br/v1/transactions/{id} \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
### Response
#### Success Response (200)
- **transaction** (object) - Detailed object containing transaction information.
#### Error Response (400)
- **error** (object) - Details regarding the failure of the request.
### Response Example
{
"id": 12345,
"status": "approved",
"amount": 100.00
}
```
--------------------------------
### Finish 3DS Authentication
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Call the `finishThreeDS()` function to finalize the 3DS authentication process. By default, redirection is automatic unless `disableRedirect` is set to `true`.
```APIDOC
## POST /finishThreeDS
### Description
Finalizes the 3DS authentication process. Allows disabling automatic redirection.
### Method
POST
### Endpoint
/finishThreeDS
### Parameters
#### Request Body
- **transaction** (object) - Required - Transaction data returned from the server.
- **options** (object) - Optional - Configuration options for finishing 3DS.
- **disableRedirect** (boolean) - Optional - Set to `true` to disable automatic redirection. Defaults to `false`.
### Request Example
```json
{
"transaction": {
"transactionId": "txn_12345abcde",
"redirectUrl": "https://3ds-provider.com/auth?token=xyz789"
},
"options": {
"disableRedirect": true
}
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the status of the 3DS completion.
#### Response Example
```json
{
"status": "completed"
}
```
```
--------------------------------
### POST /v1/withdrawals
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Creates a new withdrawal request.
```APIDOC
## POST /v1/withdrawals
### Description
Creates a new withdrawal request.
### Method
POST
### Endpoint
/v1/withdrawals
### Parameters
#### Request Body
- **amount** (integer) - Required - The amount to withdraw.
- **bank_account** (object) - Required - Details of the bank account for withdrawal.
- **account_number** (string) - Required - The bank account number.
- **agency_number** (string) - Required - The bank agency number.
- **bank_code** (string) - Required - The bank code.
- **account_type** (string) - Required - The type of account (e.g., 'checking', 'savings').
### Request Example
```json
{
"amount": 200,
"bank_account": {
"account_number": "123456789",
"agency_number": "0001",
"bank_code": "001",
"account_type": "checking"
}
}
```
### Response
#### Success Response (200)
- **withdrawal_id** (string) - The unique identifier for the withdrawal request.
- **status** (string) - The status of the withdrawal (e.g., 'processing', 'approved', 'rejected').
#### Response Example
```json
{
"withdrawal_id": "wdl_abc123xyz",
"status": "processing"
}
```
```
--------------------------------
### List Withdrawals - Ruby
Source: https://app.sharkbanking.com.br/docs/withdraw/list-withdraw
A Ruby implementation for listing withdrawals via the Sharkbanking API. It utilizes the 'net/http' library to send a GET request with appropriate headers and query parameters for pagination.
```ruby
require 'net/http'
require 'uri'
uri = URI.parse('https://api.sharkbanking.com.br/v1/transfers?page=1&pageSize=20')
request = Net::HTTP::Get.new(uri)
request['accept'] = 'application/json'
request['authorization'] = 'Basic Og=='
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
```
--------------------------------
### Card Tokenization
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
API endpoint for card tokenization.
```APIDOC
## Tokenization of the card
### Description
This endpoint is used for tokenizing credit card information.
### Method
POST
### Endpoint
/v1/tokenize/card
### Parameters
#### Request Body
- **card_number** (string) - Required - The credit card number.
- **expiry_month** (integer) - Required - The expiration month of the card.
- **expiry_year** (integer) - Required - The expiration year of the card.
- **cvv** (string) - Required - The Card Verification Value.
- **cardholder_name** (string) - Required - The name of the cardholder.
### Request Example
```json
{
"card_number": "1234567890123456",
"expiry_month": 12,
"expiry_year": 2025,
"cvv": "123",
"cardholder_name": "John Doe"
}
```
### Response
#### Success Response (200)
- **token** (string) - The generated token for the card.
#### Response Example
```json
{
"token": "tok_xxxxxxxxxxxxxxxxxxxx"
}
```
```
--------------------------------
### POST /v1/transactions/refund
Source: https://app.sharkbanking.com.br/docs/intro/first-steps
Initiates a refund for a specific transaction.
```APIDOC
## POST /v1/transactions/refund
### Description
Initiates a refund for a specific transaction.
### Method
POST
### Endpoint
/v1/transactions/refund
### Parameters
#### Request Body
- **transaction_id** (string) - Required - The ID of the transaction to refund.
- **amount** (integer) - Optional - The amount to refund. If not provided, the full amount will be refunded.
### Request Example
```json
{
"transaction_id": "txn_12345abcde",
"amount": 50
}
```
### Response
#### Success Response (200)
- **refund_id** (string) - The unique identifier for the refund.
- **status** (string) - The status of the refund (e.g., 'processed', 'failed').
#### Response Example
```json
{
"refund_id": "ref_abcdef1234",
"status": "processed"
}
```
```
--------------------------------
### Encrypt Transaction Data
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Execute the `encrypt()` function to secure transaction data. If `hideCardForm` is true, call `encrypt` with null values for card details. Otherwise, provide the card details.
```APIDOC
## POST /encrypt
### Description
Encrypts transaction data for secure transmission. Handles scenarios where card form is hidden or visible.
### Method
POST
### Endpoint
/encrypt
### Parameters
#### Request Body
- **number** (string) - Optional - Card number. Null if `hideCardForm` is true.
- **holderName** (string) - Optional - Name of the cardholder. Null if `hideCardForm` is true.
- **expMonth** (integer) - Optional - Expiration month. Null if `hideCardForm` is true.
- **expYear** (integer) - Optional - Expiration year. Null if `hideCardForm` is true.
- **cvv** (string) - Optional - Card verification value. Null if `hideCardForm` is true.
### Request Example
```json
{
"number": "12345",
"holderName": "teste",
"expMonth": 9,
"expYear": 2027,
"cvv": "123"
}
```
### Response
#### Success Response (200)
- **token** (string) - The encrypted token representing the transaction data.
#### Response Example
```json
{
"token": "encrypted_token_string"
}
```
```
--------------------------------
### Balance API
Source: https://app.sharkbanking.com.br/docs/intro/postbacks-format
Endpoint for retrieving the current balance.
```APIDOC
## GET /saldo
### Description
Retrieves the current account balance.
### Method
GET
### Endpoint
/saldo
### Response
#### Success Response (200)
- **balance** (integer) - The current available balance in cents.
#### Response Example
```json
{
"balance": 150000
}
```
```
--------------------------------
### List Anticipations via SharkBanking API
Source: https://app.sharkbanking.com.br/docs/antecipation/list-antecipations
Retrieves a paginated list of financial anticipations from the SharkBanking platform. The request requires Basic authentication and supports query parameters for page number and page size.
```shell
curl --request GET \
--url https://api.sharkbanking.com.br/v1/antecipation \
--header 'accept: application/json' \
--header 'authorization: Basic Og=='
```
--------------------------------
### Finalize 3DS Authentication (Node.js)
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Finalizes the 3DS authentication process. It accepts transaction data from the server response and an options object. The `disableRedirect` option controls automatic redirection to the 3DS URL.
```javascript
// Obter a transação da resposta do servidor
const transaction = await response.json();
// Finalizar a autenticação 3DS
await window["ShieldHelper"].finishThreeDS(transaction, {
disableRedirect: true | false, // false para redirecionamento automático, true para desabilitar
});
```
--------------------------------
### Encrypt Transaction Data for 3DS (Node.js) - Integrated Form
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Encrypts transaction data for 3DS authentication when an integrated form is used (`hideCardForm = false`). This requires providing actual card details.
```javascript
const moduleName = window["ShieldHelper"].getModuleName();
const token = await window[moduleName].encrypt(
{
number: "12345",
holderName: "teste",
expMonth: 9,
expYear: 2027,
cvv: "123",
}
);
```
--------------------------------
### Encrypt Transaction Data for 3DS (Node.js) - External Form
Source: https://app.sharkbanking.com.br/docs/sales/using-3ds
Encrypts transaction data for 3DS authentication when an external form is required (`hideCardForm = true`). This call can be made with null values to prepare the security process.
```javascript
const moduleName = window["ShieldHelper"].getModuleName();
const token = await window[moduleName].encrypt(
{
number: null,
holderName: null,
expMonth: null,
expYear: null,
cvv: null,
}
);
```