Exchange a connection code
Your plugin server exchanges the one-time code from the TapPay Connect redirect, with its PKCE verifier, for a secret key, a signing secret and a webhook secret. TapPay returns the secrets only once, so store them right away.
Changes in 2026-09-27This operation is not available in this version.
POST /api/v1/connect/tokenSince 2026-09-27
Authentication
Secret key (Bearer)
Request body
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
code | string | yes | ||
codeVerifier | string | yes | ||
redirectUri | string | yes |
Response 200
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
success | boolean | yes | true | |
data | object | yes | ||
data.secretKey | string | yes | ||
data.signingSecret | string | yes | ||
data.webhookSecret | string | yes | ||
data.webhookEndpointId | string (uuid) | yes | ||
data.connectionId | string (uuid) | yes | ||
data.clientSystemId | string (uuid) | yes | ||
data.merchantId | string (uuid) | yes | ||
data.merchant | object | yes | ||
data.merchant.id | string (uuid) | yes | ||
data.merchant.name | string | yes | ||
data.gateHubBusinessId | string | null | yes | ||
data.terminalId | string | null | yes | ||
data.environment | string | yes | SANDBOX, PRODUCTION | |
data.stickerSecret | string | null | yes |
Errors
| Code | Status | Message |
|---|---|---|
VAL-001 | 400 | The request failed validation. |
AUTH-075 | 400 | The connection code is invalid, expired or already used. |
AUTH-077 | 409 | The maximum number of active connections has been reached. |
BIZ-005 | 403 | The merchant account is not in a state that allows this request. |
BIZ-013 | 404 | The terminal was not found. |
EVT-002 | 422 | The webhook endpoint limit has been reached. |
EVT-004 | 422 | The webhook endpoint URL must use HTTPS. |
curl -sS -X POST "https://api.tappay.mn/api/v1/connect/token" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Idempotency-Key: $(openssl rand -hex 16)" \
-H "Content-Type: application/json" \
-d '{"code":"CONNECT_CODE","codeVerifier":"PKCE_CODE_VERIFIER","redirectUri":"https://shop.example.com/tappay/callback"}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.connect.exchangeCode({
body: {
code: 'CONNECT_CODE',
codeVerifier: 'PKCE_CODE_VERIFIER',
redirectUri: 'https://shop.example.com/tappay/callback',
},
});
console.log(JSON.stringify(result));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->connect->exchangeCode([
'body' => [
'code' => 'CONNECT_CODE',
'codeVerifier' => 'PKCE_CODE_VERIFIER',
'redirectUri' => 'https://shop.example.com/tappay/callback',
],
]);
echo json_encode($result);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.connect.exchange_code({
"body": {
"code": "CONNECT_CODE",
"codeVerifier": "PKCE_CODE_VERIFIER",
"redirectUri": "https://shop.example.com/tappay/callback",
},
})
print(json.dumps(result)){
"success": true,
"data": {
"secretKey": "sk_test_YOUR_SECRET_KEY",
"signingSecret": "YOUR_SIGNING_SECRET",
"webhookSecret": "YOUR_WEBHOOK_SECRET",
"webhookEndpointId": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f0c",
"connectionId": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f0d",
"clientSystemId": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f0d",
"merchantId": "YOUR_MERCHANT_ID",
"merchant": {
"id": "YOUR_MERCHANT_ID",
"name": "Sandbox Cafe"
},
"gateHubBusinessId": null,
"terminalId": null,
"environment": "SANDBOX",
"stickerSecret": null
}
}