
This topic explains the difference between the Sandbox and Production environments in Mpesa API integration. The Sandbox is a testing environment where you can simulate transactions without involving real money, while the Production environment is used for live transactions. Learners will understand how to transition from testing to live deployment, including how to switch API credentials and what to expect in both environments.
-
What is the Sandbox Environment?
- Purpose:
The Sandbox environment is a simulation platform provided by Mpesa for developers to test their integrations. It allows you to simulate transactions without involving real money, ensuring that the integration works correctly before going live. - Features:
- Test payment requests (STK Push), transaction status, and other Mpesa features.
- Use sandbox-specific API credentials (Consumer Key and Secret).
- Use simulated phone numbers, shortcodes, and amounts for testing.
- Environment URL:
The Sandbox environment is available at:https://sandbox.safaricom.co.ke
- Testing Scenarios:
- STK Push Simulation: You can simulate payment requests and responses.
- C2B and B2C Transactions: Simulate customer-to-business and business-to-customer payments.
- Transaction Status API: Verify the status of a transaction using simulated data.
- Purpose:
-
What is the Production Environment?
- Purpose:
The Production environment is used to process real transactions. After testing and ensuring everything works in the Sandbox environment, you will switch to Production for live operations. - Features:
- Actual money transactions are processed.
- You use live credentials provided by Mpesa after your application is approved.
- You will need to configure the callback URL and handle actual payment requests and responses.
- Environment URL:
The Production environment URL is:https://api.safaricom.co.ke
- Live Transactions:
- All transactions (e.g., payments, refunds) are real and involve actual money.
- Your Consumer Key and Consumer Secret are changed from the Sandbox credentials to live credentials after approval.
- Purpose:
-
Difference Between Sandbox and Production Environments
- Key Differences:
Feature Sandbox Production Transactions Simulated transactions (no real money) Real money transactions API Credentials Sandbox credentials (for testing) Live credentials (after approval) Environment URL https://sandbox.safaricom.co.ke https://api.safaricom.co.ke Testing Scope Test API endpoints and flows Process real payments and data Callback URL Simulated response URLs Real callback URL for live responses Approval Process No approval required Application needs to be approved by Mpesa
- Key Differences:
-
Transitioning from Sandbox to Production
- Steps for Transitioning:
- After successfully testing in the Sandbox environment, submit your application for Production approval.
- Mpesa will review your integration, and if approved, you will receive live Consumer Key and Consumer Secret credentials.
- Replace your Sandbox credentials with live credentials in your application’s settings.
- Update your callback URL to reflect the live environment’s server.
- Test again in the Production environment using real transactions.
- Go live with your Mpesa integration!
- Steps for Transitioning:
Summary
In this topic, you learned about the Sandbox and Production environments for Mpesa integration. The Sandbox environment is used for testing, with simulated transactions and fake data, while the Production environment is where real transactions happen, involving actual money. You also learned about the transition process from the Sandbox to Production and the steps involved, such as obtaining live credentials and configuring real callbacks.