Cards and payment methods
Charge a card
Charges one of the calling user’s saved cards through a payment gateway and returns the recorded transaction. amount_in_cents is required; currency defaults to USD. Pass company_id (a company the caller is an admin or member of) to charge through that company’s gateway, optionally for a specific country_id; without it the platform gateway is used. Returns 400 with the gateway’s message when the amount is missing or the charge fails, 403 when the merchant has paused billing, and 404 when the card is not the caller’s. Requires a Bearer token for a company admin, rep, or customer that resolves to a user; admin users, company API tokens, and partner tokens also need the payment_methods update permission.
POST
/
api
/
cards
/
{card_id}
/
charge
Charge a card
curl --request POST \
--url https://api.fluid.app/api/cards/{card_id}/charge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount_in_cents": 5499,
"currency": "USD",
"company_id": 1405
}
'import requests
url = "https://api.fluid.app/api/cards/{card_id}/charge"
payload = {
"amount_in_cents": 5499,
"currency": "USD",
"company_id": 1405
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount_in_cents: 5499, currency: 'USD', company_id: 1405})
};
fetch('https://api.fluid.app/api/cards/{card_id}/charge', 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.fluid.app/api/cards/{card_id}/charge",
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([
'amount_in_cents' => 5499,
'currency' => 'USD',
'company_id' => 1405
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.fluid.app/api/cards/{card_id}/charge"
payload := strings.NewReader("{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fluid.app/api/cards/{card_id}/charge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/cards/{card_id}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}"
response = http.request(request)
puts response.read_body{
"id": 918344,
"succeeded": true,
"state": "completed",
"order_number": "DM-100482",
"amount": 5499,
"currency_code": "USD",
"message": "Transaction approved",
"card": {
"id": 30271,
"full_name": "Michael Scott",
"month": 11,
"year": 2029,
"last_four_digits": "4242",
"first_six_digits": "424242",
"card_network": "visa",
"default": true,
"email": "michael.scott@dundermifflin.com",
"source": "card"
}
}{
"message": "<string>"
}Body
application/json
⌘I
Charge a card
curl --request POST \
--url https://api.fluid.app/api/cards/{card_id}/charge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount_in_cents": 5499,
"currency": "USD",
"company_id": 1405
}
'import requests
url = "https://api.fluid.app/api/cards/{card_id}/charge"
payload = {
"amount_in_cents": 5499,
"currency": "USD",
"company_id": 1405
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({amount_in_cents: 5499, currency: 'USD', company_id: 1405})
};
fetch('https://api.fluid.app/api/cards/{card_id}/charge', 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.fluid.app/api/cards/{card_id}/charge",
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([
'amount_in_cents' => 5499,
'currency' => 'USD',
'company_id' => 1405
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.fluid.app/api/cards/{card_id}/charge"
payload := strings.NewReader("{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fluid.app/api/cards/{card_id}/charge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/cards/{card_id}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_cents\": 5499,\n \"currency\": \"USD\",\n \"company_id\": 1405\n}"
response = http.request(request)
puts response.read_body{
"id": 918344,
"succeeded": true,
"state": "completed",
"order_number": "DM-100482",
"amount": 5499,
"currency_code": "USD",
"message": "Transaction approved",
"card": {
"id": 30271,
"full_name": "Michael Scott",
"month": 11,
"year": 2029,
"last_four_digits": "4242",
"first_six_digits": "424242",
"card_network": "visa",
"default": true,
"email": "michael.scott@dundermifflin.com",
"source": "card"
}
}{
"message": "<string>"
}