Sample Apps

Minimal single-file demos showing how third-party apps integrate with the PayUs API using OAuth app credentials. Same five steps on every platform — pick the language you're integrating from and copy the file.

Full sample apps

Complete Android modules for each integration path — a reference to drop into your project. For the language-by-language single-file API demos, see the steps below.

Before you start

  1. Ask your PayUs admin to create an OAuth App (Admin → OAuth Apps).
  2. Save your App ID and App Secret — the secret is shown once.
  3. Note your Branch ID (Admin → Users).
  4. Replace YOUR_APP_ID, YOUR_APP_SECRET, and BRANCH_ID at the top of your chosen demo file.

What each demo does

  1. 1
    Authenticate
    Exchange your appId + appSecret for a bearer token.
  2. 2
    List terminals
    Discover the terminals assigned to your branch.
  3. 3
    Send a print trigger
    Push a command to the first terminal you find.
  4. 4
    Process a payment
    Kick off a $0.01 test payment through that terminal.
  5. 5
    Query transactions
    Read today's transaction history back out.

Run

Web (TypeScript)

View source ↗
cd examples/web && npx tsx integrator-demo.ts

Requires Node 18+ (native fetch).

Android (Kotlin)

View source ↗
cd examples/android && kotlin IntegratorDemo.kt

Or compile: kotlinc IntegratorDemo.kt -include-runtime -d demo.jar && java -jar demo.jar

iOS (Swift)

View source ↗
cd examples/ios && swift IntegratorDemo.swift

What to expect

  • Steps that succeed print ✅.
  • Steps that fail because of a missing scope print ⚠️ with a clear message — e.g. 403: Insufficient scope — requires payments:direct.
  • If no terminals are found, steps 3 and 4 are skipped.

Scopes needed for the full demo

StepRequired scope
List terminalsterminals:read
Send triggerterminals:trigger
Process paymentpayments:direct
Query transactionstransactions:read

Ask your admin to grant all four scopes on the OAuth app for the full demo. Without payments:direct, step 4 returns 403 — this is expected and correct. See OAuth Scopes for the full scope reference.

Terminal WebSocket note

Terminal triggers (step 3) are delivered via WebSocket. If the target terminal is offline, the trigger is accepted by the API but won’t be delivered until the terminal reconnects. Admins can control terminal connectivity via deactivation, SESSION_KICK, and FORCE_REFRESH commands.