import os, sodacards
from sodacards.models import (
SodacardsDevpublicV1PlaceOrderRequest,
SodacardsDevpublicV1OrderLine,
)
config = sodacards.Configuration(host="https://api.sodacards.com")
config.api_key["ApiKeyAuth"] = os.environ["SODACARDS_API_KEY"]
client = sodacards.DefaultApi(sodacards.ApiClient(config))
order = client.place_order(
SodacardsDevpublicV1PlaceOrderRequest(
lines=[SodacardsDevpublicV1OrderLine(product_id="prod_123", quantity=1)],
reference="order-0001",
),
idempotency_key="order-0001",
)
import { Sodacards } from "@sodacards/sdk";
const sodacards = new Sodacards({ apiKeyAuth: process.env.SODACARDS_API_KEY });
const order = await sodacards.placeOrder({
idempotencyKey: "order-0001",
body: {
lines: [{ productId: "prod_123", quantity: 1 }],
reference: "order-0001",
},
});
client := sodacards.NewAPIClient(sodacards.NewConfiguration())
auth := context.WithValue(context.Background(), sodacards.ContextAPIKeys,
map[string]sodacards.APIKey{"ApiKeyAuth": {Key: os.Getenv("SODACARDS_API_KEY")}})
line := sodacards.NewSodacardsDevpublicV1OrderLine()
line.SetProductId("prod_123")
line.SetQuantity(1)
body := sodacards.NewSodacardsDevpublicV1PlaceOrderRequest()
body.SetLines([]sodacards.SodacardsDevpublicV1OrderLine{*line})
body.SetReference("order-0001")
order, _, err := client.DefaultAPI.PlaceOrder(auth).
IdempotencyKey("order-0001").
SodacardsDevpublicV1PlaceOrderRequest(*body).
Execute()
$config = Sodacards\Configuration::getDefaultConfiguration()
->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));
$client = new Sodacards\Api\DefaultApi(new GuzzleHttp\Client(), $config);
$order = $client->placeOrder('order-0001', new Sodacards\Model\SodacardsDevpublicV1PlaceOrderRequest([
'lines' => [
new Sodacards\Model\SodacardsDevpublicV1OrderLine([
'product_id' => 'prod_123',
'quantity' => 1,
]),
],
'reference' => 'order-0001',
]));
curl --request POST \
--url https://api.sodacards.com/v1/orders \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"lines": [
{
"productId": "<string>",
"quantity": 123,
"inputFields": {}
}
],
"reference": "<string>",
"maxTotal": {
"amount": "5000",
"currency": "XOF",
"minorUnitExponent": "0"
}
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lines: [{productId: '<string>', quantity: 123, inputFields: {}}],
reference: '<string>',
maxTotal: {amount: '5000', currency: 'XOF', minorUnitExponent: '0'}
})
};
fetch('https://api.sodacards.com/v1/orders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.sodacards.com/v1/orders")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"lines\": [\n {\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"inputFields\": {}\n }\n ],\n \"reference\": \"<string>\",\n \"maxTotal\": {\n \"amount\": \"5000\",\n \"currency\": \"XOF\",\n \"minorUnitExponent\": \"0\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sodacards.com/v1/orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"lines\": [\n {\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"inputFields\": {}\n }\n ],\n \"reference\": \"<string>\",\n \"maxTotal\": {\n \"amount\": \"5000\",\n \"currency\": \"XOF\",\n \"minorUnitExponent\": \"0\"\n }\n}"
response = http.request(request)
puts response.read_body{
"order": {
"id": "<string>",
"status": "pending",
"total": {
"amount": "5000",
"currency": "XOF",
"minorUnitExponent": "0"
}
}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Place an order
PlaceOrder buys one or more products, settled from the reseller’s prepaid wallet. It is asynchronous: the order is accepted and fulfilled in the background, so the response carries the order id and a status to poll. The request MUST carry an Idempotency-Key header, so a retried request never places a second order.
import os, sodacards
from sodacards.models import (
SodacardsDevpublicV1PlaceOrderRequest,
SodacardsDevpublicV1OrderLine,
)
config = sodacards.Configuration(host="https://api.sodacards.com")
config.api_key["ApiKeyAuth"] = os.environ["SODACARDS_API_KEY"]
client = sodacards.DefaultApi(sodacards.ApiClient(config))
order = client.place_order(
SodacardsDevpublicV1PlaceOrderRequest(
lines=[SodacardsDevpublicV1OrderLine(product_id="prod_123", quantity=1)],
reference="order-0001",
),
idempotency_key="order-0001",
)
import { Sodacards } from "@sodacards/sdk";
const sodacards = new Sodacards({ apiKeyAuth: process.env.SODACARDS_API_KEY });
const order = await sodacards.placeOrder({
idempotencyKey: "order-0001",
body: {
lines: [{ productId: "prod_123", quantity: 1 }],
reference: "order-0001",
},
});
client := sodacards.NewAPIClient(sodacards.NewConfiguration())
auth := context.WithValue(context.Background(), sodacards.ContextAPIKeys,
map[string]sodacards.APIKey{"ApiKeyAuth": {Key: os.Getenv("SODACARDS_API_KEY")}})
line := sodacards.NewSodacardsDevpublicV1OrderLine()
line.SetProductId("prod_123")
line.SetQuantity(1)
body := sodacards.NewSodacardsDevpublicV1PlaceOrderRequest()
body.SetLines([]sodacards.SodacardsDevpublicV1OrderLine{*line})
body.SetReference("order-0001")
order, _, err := client.DefaultAPI.PlaceOrder(auth).
IdempotencyKey("order-0001").
SodacardsDevpublicV1PlaceOrderRequest(*body).
Execute()
$config = Sodacards\Configuration::getDefaultConfiguration()
->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));
$client = new Sodacards\Api\DefaultApi(new GuzzleHttp\Client(), $config);
$order = $client->placeOrder('order-0001', new Sodacards\Model\SodacardsDevpublicV1PlaceOrderRequest([
'lines' => [
new Sodacards\Model\SodacardsDevpublicV1OrderLine([
'product_id' => 'prod_123',
'quantity' => 1,
]),
],
'reference' => 'order-0001',
]));
curl --request POST \
--url https://api.sodacards.com/v1/orders \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"lines": [
{
"productId": "<string>",
"quantity": 123,
"inputFields": {}
}
],
"reference": "<string>",
"maxTotal": {
"amount": "5000",
"currency": "XOF",
"minorUnitExponent": "0"
}
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
lines: [{productId: '<string>', quantity: 123, inputFields: {}}],
reference: '<string>',
maxTotal: {amount: '5000', currency: 'XOF', minorUnitExponent: '0'}
})
};
fetch('https://api.sodacards.com/v1/orders', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.sodacards.com/v1/orders")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"lines\": [\n {\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"inputFields\": {}\n }\n ],\n \"reference\": \"<string>\",\n \"maxTotal\": {\n \"amount\": \"5000\",\n \"currency\": \"XOF\",\n \"minorUnitExponent\": \"0\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sodacards.com/v1/orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"lines\": [\n {\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"inputFields\": {}\n }\n ],\n \"reference\": \"<string>\",\n \"maxTotal\": {\n \"amount\": \"5000\",\n \"currency\": \"XOF\",\n \"minorUnitExponent\": \"0\"\n }\n}"
response = http.request(request)
puts response.read_body{
"order": {
"id": "<string>",
"status": "pending",
"total": {
"amount": "5000",
"currency": "XOF",
"minorUnitExponent": "0"
}
}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Authorizations
Your API key, prefixed sc_live_ or sc_test_.
Headers
A unique key so a retried request never places a second order. Reuse the same key to retry a call safely; reusing it with a different body is a conflict.
Body
lines are the products to buy and how many of each. At least one is required.
Show child attributes
Show child attributes
reference is an optional identifier you attach to the order to correlate it with your own system and look it up later. Reusing an Idempotency-Key with a different reference is a conflict.
Money is an amount in a currency's minor units, together with the currency's ISO-4217 code and its number of decimal places, so the amount can be interpreted without assuming the currency. XOF (the West-African CFA franc) has no minor unit, so an XOF amount is a whole franc value.
Show child attributes
Show child attributes
Response
Success
order is the accepted order. It is settled from the wallet at placement, so it is born already paid: its status is "processing" while it is being fulfilled, or "completed" when fulfillment is immediate. It is never "pending" -- the developer API charges synchronously, so an order awaiting payment is not a state it produces. Poll the order to follow it to "completed".
Show child attributes
Show child attributes