Python
import requests
client_id = <YOUR CLIENT ID>
public_key = <YOUR CLIENT TOKEN>
request = requests.post('https://api.malga.io/v1/tokens', headers={
"X-Client-Id": client_id,
"X-Api-Key": publick_key
}, json={
"cardHolderName": "JOSE DAS NEVES",
"cardNumber": "4019598346009339",
"cardCvv": "123",
"cardExpirationDate": "12/2026"
})
print(request.json().get('tokenId'))curl --request POST \
--url https://api.malga.io/v1/tokens \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Client-Id: <api-key>' \
--data '
{
"cardHolderName": "JOSE DAS NEVES",
"cardNumber": "4019598346009339",
"cardCvv": "123",
"cardExpirationDate": "12/2026"
}
'const options = {
method: 'POST',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
cardHolderName: 'JOSE DAS NEVES',
cardNumber: '4019598346009339',
cardCvv: '123',
cardExpirationDate: '12/2026'
})
};
fetch('https://api.malga.io/v1/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.malga.io/v1/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cardHolderName' => 'JOSE DAS NEVES',
'cardNumber' => '4019598346009339',
'cardCvv' => '123',
'cardExpirationDate' => '12/2026'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Client-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.malga.io/v1/tokens"
payload := strings.NewReader("{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Client-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.malga.io/v1/tokens")
.header("X-Client-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.malga.io/v1/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}"
response = http.request(request)
puts response.read_body{
"tokenId": "cc0b1e41-2936-45c5-947f-93995ffcdc00"
}{
"error": {
"code": 123,
"declinedCode": "<string>",
"key": "<string>",
"businessCode": "<string>",
"message": "<string>",
"details": "<array>"
}
}{
"error": {
"code": 123,
"declinedCode": "<string>",
"key": "<string>",
"businessCode": "<string>",
"message": "<string>",
"details": "<array>"
}
}Tokens
Criar um novo token
POST
/
v1
/
tokens
Python
import requests
client_id = <YOUR CLIENT ID>
public_key = <YOUR CLIENT TOKEN>
request = requests.post('https://api.malga.io/v1/tokens', headers={
"X-Client-Id": client_id,
"X-Api-Key": publick_key
}, json={
"cardHolderName": "JOSE DAS NEVES",
"cardNumber": "4019598346009339",
"cardCvv": "123",
"cardExpirationDate": "12/2026"
})
print(request.json().get('tokenId'))curl --request POST \
--url https://api.malga.io/v1/tokens \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Client-Id: <api-key>' \
--data '
{
"cardHolderName": "JOSE DAS NEVES",
"cardNumber": "4019598346009339",
"cardCvv": "123",
"cardExpirationDate": "12/2026"
}
'const options = {
method: 'POST',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
cardHolderName: 'JOSE DAS NEVES',
cardNumber: '4019598346009339',
cardCvv: '123',
cardExpirationDate: '12/2026'
})
};
fetch('https://api.malga.io/v1/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.malga.io/v1/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cardHolderName' => 'JOSE DAS NEVES',
'cardNumber' => '4019598346009339',
'cardCvv' => '123',
'cardExpirationDate' => '12/2026'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Client-Id: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.malga.io/v1/tokens"
payload := strings.NewReader("{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Client-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.malga.io/v1/tokens")
.header("X-Client-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.malga.io/v1/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cardHolderName\": \"JOSE DAS NEVES\",\n \"cardNumber\": \"4019598346009339\",\n \"cardCvv\": \"123\",\n \"cardExpirationDate\": \"12/2026\"\n}"
response = http.request(request)
puts response.read_body{
"tokenId": "cc0b1e41-2936-45c5-947f-93995ffcdc00"
}{
"error": {
"code": 123,
"declinedCode": "<string>",
"key": "<string>",
"businessCode": "<string>",
"message": "<string>",
"details": "<array>"
}
}{
"error": {
"code": 123,
"declinedCode": "<string>",
"key": "<string>",
"businessCode": "<string>",
"message": "<string>",
"details": "<array>"
}
}Body
application/json
Tokenizar
Pode ser tokenizado o cartão e/ou cvv de acordo com a passagem dos atributos
- Option 1
- Option 2
Show child attributes
Show child attributes
Response
Created
Identificador do token gerado
Was this page helpful?
⌘I