Server-to-Server Implementation Guide

This guide walks backend developers step by step with pseudocode through everything needed to integrate server-to-server endpoints.

1. Database Deposits Table

Create the deposits table:

CREATE TABLE deposits (
    deposit_id VARCHAR(36) PRIMARY KEY,
    user_id VARCHAR(36) NOT NULL,
    amount INTEGER NOT NULL,
    result VARCHAR(36)
);

2. /thndr/pay Endpoint

Payload:

{
  "userId": "<userId>",
  "depositId": "<depositId>",
  "amount": 1234
}

Execute following commands in one SQL transaction:

  1. Check if this deposit was already processed:

  1. Debit the user

  1. Store deposit for idempotency and future result:

3. /thndr/results Endpoint

Payload:

Execute following commands in one SQL transaction:

  1. Check if deposit exists

  1. Check if result already processed

  1. Process the result:

  1. Mark deposit as processed

Last updated