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
- Ask your PayUs admin to create an OAuth App (Admin → OAuth Apps).
- Save your App ID and App Secret — the secret is shown once.
- Note your Branch ID (Admin → Users).
- Replace
YOUR_APP_ID,YOUR_APP_SECRET, andBRANCH_IDat the top of your chosen demo file.
What each demo does
- 1AuthenticateExchange your appId + appSecret for a bearer token.
- 2List terminalsDiscover the terminals assigned to your branch.
- 3Send a print triggerPush a command to the first terminal you find.
- 4Process a paymentKick off a $0.01 test payment through that terminal.
- 5Query transactionsRead today's transaction history back out.
Run
Web (TypeScript)
View source ↗cd examples/web && npx tsx integrator-demo.tsRequires Node 18+ (native fetch).
Android (Kotlin)
View source ↗cd examples/android && kotlin IntegratorDemo.ktOr compile: kotlinc IntegratorDemo.kt -include-runtime -d demo.jar && java -jar demo.jar
iOS (Swift)
View source ↗cd examples/ios && swift IntegratorDemo.swiftWhat 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
| Step | Required scope |
|---|---|
| List terminals | terminals:read |
| Send trigger | terminals:trigger |
| Process payment | payments:direct |
| Query transactions | transactions: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.