Prerequisites
- Terminal API key from Xendit In-Person Payment team
- Node.js or your preferred development environment
For Physical Terminal Testing
- Terminal Gateway set up (desktop app or Android/iOS SDK)
- Physical terminal device connected and showing “Ready” status
- Terminal registered with Xendit for test mode (contact support if needed)
- Valid
terminal_idfrom your registered device
For Simulation Testing (No Terminal Required)
- Any
terminal_idvalue (e.g.,SIM001) - no registration needed - Special test amounts to trigger different payment scenarios
- Use
4040404as terminal_id to test invalid terminal error handling
Don’t have a physical terminal yet? No problem! You can start integration immediately using our simulation capabilities. Use special test amounts and terminal IDs to simulate different payment scenarios without needing physical hardware.
1. Configure your environment
Set up your local development environment with the necessary credentials and base URLs.1
Create environment file
Create a
.env file in your project root:.env
2
Install dependencies
Install required packages for your development environment:
3
Set up webhook server
Create a local Express server to receive callbacks:
webhook.js
2. Choose your testing approach
- Simulation Testing (Recommended for getting started)
- Physical Terminal Testing
Perfect for merchants waiting on terminal delivery or initial integrationTest payment flows without physical hardware using special test amounts and scenarios.
1
Use any terminal ID
For simulation testing, you can use any
terminal_id value. The system will automatically simulate payment responses..env
2
Test different scenarios
Use these special amounts to simulate various payment outcomes:
| Amount | Scenario | Expected Result |
|---|---|---|
400508 | Payment declined | Session created, transaction fails |
400509 | Channel unavailable | Session creation fails |
400711 | User cancellation | Session created, then canceled |
4040404 (as terminal_id) | Invalid terminal | Session creation fails |
| Any other amount | Success flow | Payment completes successfully |
3
Run simulation test
test-simulation.js
You receive different responses based on the test amounts, simulating real payment scenarios without physical hardware.
Simulation Benefits: Start integration immediately, test error handling, validate webhook flows, and prepare for production - all without waiting for terminal delivery.
3. Create your first payment session
Now create a payment session and process it. Choose the approach that matches your setup:- Simulation Payment
- Physical Terminal Payment
Perfect for testing without physical terminals
Success: Session created with
Decline: Session created with
ACTIVE status, then automatically transitions to COMPLETEDDecline: Session created with
ACTIVE status, then transitions to FAILED4. Monitor callbacks
Your webhook server (started in step 1) will receive real-time payment updates. Monitor the console output to see callback events.Callback events include
PAYMENT_CREATED, PAYMENT_SUCCEEDED, PAYMENT_FAILED, and others. See the Callbacks documentation for complete event types.5. Verify payment details
Query payment details after receiving a success callback.Confirm status is
SUCCEEDED and amounts match your session.6. Optional: Void a payment
If needed, you can void a payment transaction:Troubleshooting
401 Unauthorized
401 Unauthorized
Simulation not working as expected
Simulation not working as expected
- Verify you’re using the correct special amounts:
400508(decline),400509(channel unavailable),400711(cancellation) - Check that you’re in test mode (using development base URL)
- Any
terminal_idworks for simulation - you don’t need a real terminal registered - Normal amounts (not special test amounts) will always succeed in simulation mode
Terminal not prompting (Physical terminals only)
Terminal not prompting (Physical terminals only)
- Confirm Terminal Gateway shows device as Connected/Ready
- Verify
terminal_idmatches your device configuration exactly - Check network connectivity on the device
- Ensure device has correct time settings
- For simulation testing: You don’t need a physical terminal - any terminal_id will work
Webhook not receiving callbacks
Webhook not receiving callbacks
- Use ngrok to expose your local server publicly
- Ensure your webhook endpoint returns HTTP 200
- Check server logs and firewall settings
- Verify the webhook URL is configured correctly
- For simulation: Callbacks work the same way as physical terminals
Environment variables not loading
Environment variables not loading
- Verify
.envfile is in the correct location - Check that you’re calling
dotenv.config()before using environment variables - Ensure
.envfile is not committed to version control
Ready to transition from simulation to physical terminal
Ready to transition from simulation to physical terminal
- Install and configure Terminal Gateway app or SDK
- Register your physical terminal devices with actual Terminal IDs and IP addresses
- Update your environment variables to use real terminal IDs
- Test with small amounts on the physical device
- All your existing integration code will work without changes!
Next steps
Now that you have a working integration, explore these advanced features:Terminal API Introduction
Complete Terminal API documentation and reference
Terminal Gateway
Learn about Terminal Gateway SDKs for Android and iOS
Payment Callbacks
Handle real-time payment notifications and status updates
Gateway App Configuration
Configure Terminal Gateway app for your devices
Production deployment
When ready for production:- Switch to live API keys - Use production Terminal API key and base URL
https://terminal.xendit.co - Update webhook URLs - Configure production webhook endpoints that are publicly accessible
- Test thoroughly - Start with small amounts and verify all payment flows work correctly
- Monitor and log - Set up proper logging and monitoring for payment events