Skip to main content

Sample App: TypeScript

A working TypeScript integration against the PayKore sandbox. Clone it, set your API key, and run — every core flow covered in 5 minutes.

Source: samples/typescript/ in the PayKore repo.


What it covers

StepFlow
1Create two wallets
2Fund wallet A (sandbox only)
3P2P transfer: A → B
4Bank transfer from A (async, settles via webhook)
5QR payment: merchant creates intent, payer pays
6USSD payment: initiate + simulate confirmation
7KYC: submit BVN (async, result via webhook)

Prerequisites


Setup

cd samples/typescript
npm install

Run the quickstart

export PAYKORE_API_KEY=sk_test_YOUR_KEY_HERE
npm run quickstart

You'll see a line printed for each step. The full run takes under 10 seconds.

═══════════════════════════════════════
PayKore TypeScript Quickstart
Environment: sandbox
═══════════════════════════════════════

── Step 1: Create wallets ──

✅ Wallet A created
{
"id": "wlt_9f3kA2mXpQ",
"status": "pending",
"nuban": "0123456789"
}
...
✅ P2P transfer completed
✅ Bank transfer accepted (202)
✅ QR payment completed (payer)
✅ USSD simulation: confirm sent
✅ BVN submitted

═══════════════════════════════════════
All steps completed successfully.
Run webhook-server.ts to test async event delivery.
═══════════════════════════════════════

Run the webhook server

Steps 4 (bank transfer) and 7 (KYC) produce async results. The webhook server captures and prints them.

Terminal 1 — start the server:

export PAYKORE_WEBHOOK_SECRET=whsec_YOUR_SECRET_HERE
npm run webhook-server

Terminal 2 — expose it via ngrok:

npx ngrok http 3000

Register the ngrok URL with PayKore:

curl -X POST https://sandbox.paykore.com/v1/webhooks \
-H "Authorization: Bearer $PAYKORE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://YOUR_NGROK_URL/webhooks",
"events": ["transaction.completed","transaction.failed","wallet.activated","kyc.verified","kyc.failed"]
}'

Save the secret from the response and export it as PAYKORE_WEBHOOK_SECRET.

Terminal 3 — run the quickstart again:

npm run quickstart

You'll see events arrive in Terminal 1:

── 2025-06-01T10:03:24Z ──
Event: transaction.completed
✅ Transaction completed
ID: tx_8wXyZ1aBcD
Type: bank_transfer
Reference: py_bank_f47ac10b-...
Amount: ₦1000.00

── 2025-06-01T10:03:26Z ──
Event: kyc.verified
✅ KYC verified
User ref: py_user_a_1717200000
Type: bvn
Verified at: 2025-06-01T10:03:25Z

Key files

FileWhat it is
quickstart.tsThe runnable script — one function per flow
webhook-server.tsThe HTTP server — signature verification + event handlers
package.jsonnpm scripts: quickstart and webhook-server
tsconfig.jsonTypeScript config

Next steps