Guides
Settling payments
Use this page when you collect the exam fee from the student yourself, on your own site, and pay Main Team for many students at once with a bank transfer. If your students pay by card on the olympiad's site instead, you don't need any of this: their payment turns paid on its own.
No money moves through the API. When you pay by bank transfer, a payment is marked paid by Main Team after your transfer arrives; what the API gives you is everything you need to tell Main Team which applications a transfer covers, and to see when Main Team has marked them paid.
Bank transfer is the default way to pay. Partners who have a wallet can pay from it instead, one credit per priced application, and the payment is paid at once, with a reference like any other. A credit is a convenience: the amount is still due to Main Team and is settled afterwards by bank transfer. The wallet is not self-service: Main Team opens it only after an agreement and on your request (your Main Team contact or info@main-team.org). Without one, wallet calls answer 403 wallet_not_enabled and this page is how you pay.
The flow at a glance
- Create the application for each student and exam, with your own
externalRef. You get itspayment._idback. - Collect the fee from the student on your site, under that
externalRef. - Send Main Team a settlement list for a batch of applications, together with one bank transfer for their total.
- Main Team marks those payments paid and replies with the payment reference.
- Check the status through the API: the payments read
paid, with theirreference. - Let the student sign in once their payment is
paid.
If you have a wallet
Only if Main Team has opened a wallet for you (after an agreement, on your request) and granted it credits can you skip the bank transfer: pass walletPay when you create the application, or when you register the student with exams (registerStudent, or a row of createStudentImport), and the payment is paid in the same write. Nothing below applies to a payment paid that way.
Step 1: Create the application first
Create the application before you collect the fee, or at the latest before you send the transfer. Without an application there is no payment to mark paid, nothing for Main Team to match your money against, and nothing the student can sit or get results for.
Send your own reference for the entry as externalRef, for example the order number your site charged the student under (at most 64 characters, see Applications):
curl -s -X POST "https://api.main-team.org/v1/<organizationId>/application" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "studentId": "<studentId>", "examId": "<examId>", "externalRef": "INV-2026-0042" }'
{
"success": true,
"message": "Application created successfully.",
"data": {
"_id": "6703d4e5f6a7b8c9d0e1f203",
"exam": "66f1a2b3c4d5e6f708192a3b",
"user": "66fa0b1c2d3e4f5a6b7c8d9e",
"payment": "6703d4e5f6a7b8c9d0e1f204",
"externalRef": "INV-2026-0042"
}
}
Keep, for each entry, the organization id, data._id (the application) and data.payment (the payment id). Read the application once with getApplication to see what is due: payment.amount is in cents, so 2500 is 25.00. The currency isn't returned; Main Team charges in euro unless it has told you otherwise.
Already created applications without a reference? Repeat the same create with an externalRef: an application that has none gets it, with 200. One that already has a different reference answers 409.
Step 2: Keep the sign-in link back
Warning
While a payment is pending, the student can still pay it by card on the olympiad's site. If you hand out the sign-in link before Main Team has marked the payment paid, the student may pay a second time, and a double payment has to be refunded by hand.
Either settle the payment before you hand out the sign-in link, or keep your "Open exam" button disabled until the payment reads paid.
Step 3: Send Main Team a settlement list
Make one bank transfer for a batch of applications, and email info@main-team.org a settlement list with it, as CSV, one row per application:
| Column | From |
|---|---|
organizationId | The organization the application is in |
applicationId | data._id from createApplication |
paymentId | data.payment from createApplication, or payment._id from a read |
externalRef | Your own reference, as you sent it |
studentName | The student's first and last name |
exam | The exam, as your records name it |
amount | payment.amount as the API gives it, in cents |
organizationId,applicationId,paymentId,externalRef,studentName,exam,amount
6501a2b3c4d5e6f708192a00,6703d4e5f6a7b8c9d0e1f203,6703d4e5f6a7b8c9d0e1f204,INV-2026-0042,Jane Doe,Science 14/11/2026 English,2500
6501a2b3c4d5e6f708192a00,6703d4e5f6a7b8c9d0e1f2a1,6703d4e5f6a7b8c9d0e1f2a2,INV-2026-0043,Ada Lovelace,Mathematics 14/11/2026 English,2500
The amounts in the list should add up to the transfer. Put the same reference in the transfer's payment details that you put in the email's subject, so the two can be matched. List only applications whose payment is still pending: build the list from ?paymentStatus=pending.
Step 4: Main Team marks the payments paid
When the transfer has arrived, Main Team marks the listed payments paid and replies with the payment reference, a code such as stx-6718a2f4c1d3e. The payments of one batch usually share one reference. If a row can't be matched, for example because the amount differs from what the API shows, Main Team tells you which and leaves that payment pending.
Step 5: See what is still open
Read the payment back through the API. A settled payment reads "status": "paid", and the application reads now carry its reference, the code from Main Team's reply:
curl -s "https://api.main-team.org/v1/<organizationId>/application/6703d4e5f6a7b8c9d0e1f203" \
-H "Authorization: Bearer $TOKEN"
{
"success": true,
"message": "Application fetched successfully.",
"data": {
"_id": "6703d4e5f6a7b8c9d0e1f203",
"externalRef": "INV-2026-0042",
"payment": {
"_id": "6703d4e5f6a7b8c9d0e1f204",
"status": "paid",
"amount": 2500,
"reference": "stx-6718a2f4c1d3e"
}
}
}
To see everything a transfer has not covered yet, list the applications whose payment is still pending, page by page:
curl -s "https://api.main-team.org/v1/<organizationId>/application?paymentStatus=pending&limit=100&page=1" \
-H "Authorization: Bearer $TOKEN"
To find one entry by your own reference, use ?externalRef=INV-2026-0042. Both filters work on all three application lists, and they combine. See Filter the lists.
// The applications of one organization whose payment is still pending.
async function pendingApplications(organizationId) {
const rows = [];
for (let page = 1; ; page++) {
const res = await fetch(
`https://api.main-team.org/v1/${organizationId}/application?paymentStatus=pending&limit=100&page=${page}`,
{ headers: { Authorization: `Bearer ${await getToken()}` } },
);
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);
rows.push(...body.data);
if (page >= body.pagination.totalPages) return rows;
}
}
<?php
// The applications of one organization whose payment is still pending.
function pendingApplications(string $organizationId): array
{
$rows = [];
for ($page = 1; ; $page++) {
$ch = curl_init("https://api.main-team.org/v1/{$organizationId}/application?paymentStatus=pending&limit=100&page={$page}");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getToken()],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
array_push($rows, ...$body['data']);
if ($page >= $body['pagination']['totalPages']) return $rows;
}
}
Poll gently: once an hour, or after Main Team's reply, is plenty. Every read counts against your rate limit.
Step 6: Let the student sign in
Enable your "Open exam" button for a student once their application's payment.status is paid, and only then create the sign-in link. A paid payment is no longer offered for card payment on the olympiad's site, so the student cannot pay twice from that point on.
When something goes wrong
| Situation | What to do |
|---|---|
| A student paid you and paid by card on the olympiad's site | Their payment is paid from the card. Leave that application out of your settlement list, and refund the student yourself; if it was already in a transfer, tell Main Team, and the double payment is refunded by hand. |
A payment is still pending after Main Team's reply | Main Team couldn't match that row. Check its amount against the API and ask info@main-team.org, quoting the applicationId and your externalRef. |
| You moved an application to an exam with another price before it was paid | The pending payment now asks for the new price (see Move an application). Settle the new amount. |
You need to withdraw a student whose payment is paid | The API refuses to delete a paid application (409). Ask Main Team; a refund happens outside the API. |
In the sandbox
The sandbox has no bank. To see a payment turn paid there:
- ask info@main-team.org to mark your sandbox payments paid, sending the same settlement list you would send for production; or
- sign the student in and pay with a test card in the sandbox (see Environments). No real money moves.