API reference
A payment's webhook log
Every webhook event of one payment, sent or not and why, with each attempt and what your server answered.
GET
https://api.takaelo.com/v1/payments/{id}/webhooksThe quickest way to see why an order didn't turn paid. Each event shows its status: delivered, retrying (with next_attempt), failed, no_endpoint (no webhook address for this mode yet) or skipped (your endpoint didn't choose this event). Each attempt in deliveries has the address, your server's response_code and any error. Your own shop and your key's mode only; works with test and live keys.
# What TakaElo sent to your webhook endpoint for this payment, and what your server answered.
curl https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks \
-H "Authorization: Bearer $TAKAELO_SECRET_KEY"<?php
$ch = curl_init('https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('TAKAELO_SECRET_KEY')],
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) {
throw new RuntimeException($body['code'] . ': ' . $body['message']);
}
foreach ($body['data']['data'] as $event) {
echo $event['type'] . ' ' . $event['status'] . PHP_EOL; // e.g. "payment.completed delivered"
}const res = await fetch("https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks", {
headers: { Authorization: `Bearer ${process.env.TAKAELO_SECRET_KEY}` },
});
const body = await res.json();
if (!body.success) throw new Error(`${body.code}: ${body.message}`);
for (const event of body.data.data) {
console.log(event.type, event.status); // e.g. "payment.completed delivered"
}import json
import os
import urllib.error
import urllib.request
request = urllib.request.Request(
"https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks",
headers={"Authorization": "Bearer " + os.environ["TAKAELO_SECRET_KEY"]},
)
try:
with urllib.request.urlopen(request) as response:
events = json.load(response)["data"]["data"]
except urllib.error.HTTPError as e:
error = json.load(e)
raise SystemExit(f"{error['code']}: {error['message']}")
for event in events:
print(event["type"], event["status"]) # e.g. "payment.completed delivered"package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest(http.MethodGet, "https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("TAKAELO_SECRET_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var body struct {
Success bool `json:"success"`
Code string `json:"code"`
Message string `json:"message"`
Data struct {
Data []struct {
Type string `json:"type"`
Status string `json:"status"`
} `json:"data"`
} `json:"data"`
}
if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
log.Fatal(err)
}
if !body.Success {
log.Fatalf("%s: %s", body.Code, body.Message)
}
for _, event := range body.Data.Data {
fmt.Println(event.Type, event.Status) // e.g. "payment.completed delivered"
}
}require "json"
require "net/http"
uri = URI("https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks")
request = Net::HTTP::Get.new(uri, "Authorization" => "Bearer #{ENV.fetch("TAKAELO_SECRET_KEY")}")
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
body = JSON.parse(response.body)
raise "#{body["code"]}: #{body["message"]}" unless body["success"]
body["data"]["data"].each { |event| puts "#{event["type"]} #{event["status"]}" } # e.g. "payment.completed delivered"import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class PaymentWebhooks {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks"))
.header("Authorization", "Bearer " + System.getenv("TAKAELO_SECRET_KEY"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
JsonNode body = new ObjectMapper().readTree(response.body());
if (!body.path("success").asBoolean()) {
throw new IllegalStateException(body.path("code").asText() + ": " + body.path("message").asText());
}
for (JsonNode event : body.get("data").get("data")) {
System.out.println(event.get("type").asText() + " " + event.get("status").asText()); // e.g. "payment.completed delivered"
}
}
}using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("TAKAELO_SECRET_KEY"));
using var response = await http.GetAsync("https://api.takaelo.com/v1/payments/pay_3kT9xQm2LrV8nB4cW7yZ1aPd/webhooks");
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
if (!body.GetProperty("success").GetBoolean())
throw new Exception($"{body.GetProperty("code")}: {body.GetProperty("message")}");
foreach (var evt in body.GetProperty("data").GetProperty("data").EnumerateArray())
Console.WriteLine($"{evt.GetProperty("type")} {evt.GetProperty("status")}"); // e.g. "payment.completed delivered"{
"success": true,
"message": "Webhook events retrieved",
"data": {
"object": "list",
"data": [
{
"id": "evt_9mQ2xR7tLk4Vn8Bc3Zw6Pd1H",
"object": "webhook_event",
"type": "payment.pending",
"livemode": false,
"status": "skipped",
"attempts": 0,
"next_attempt": null,
"created": 1791533261,
"deliveries": []
},
{
"id": "evt_4Kd8Wq2Ln6Rt9Vb1Xz3Mc7Hp",
"object": "webhook_event",
"type": "payment.completed",
"livemode": false,
"status": "delivered",
"attempts": 1,
"next_attempt": null,
"created": 1791533264,
"deliveries": [
{
"attempt": 1,
"url": "https://yourshop.com/webhooks/takaelo",
"status": "delivered",
"response_code": 200,
"error": "",
"duration_ms": 84,
"created": 1791533264
}
]
}
],
"has_more": false
}
}