调用Paytm initiateTransaction API遇resultCode=2006(Mid无效)问题求助
Here are the key fixes to resolve the "Mid is invalid" error:
1. Replace Placeholder MID with Actual Test Value
Your code uses <TEST_ENV_MID> as a placeholder. Replace this with the real test MID provided in your Paytm Business Dashboard. Failing to do this is the most common cause of this error.
2. URL-Encode MID and Order ID in Request URL
If your MID contains special characters, they need proper URL encoding to be recognized by the API. Update your URL construction code:
import java.net.URLEncoder; // ... String encodedMid = URLEncoder.encode(mid, "UTF-8"); String encodedOrderId = URLEncoder.encode(orderId, "UTF-8"); String postUrl = String.format("/theia/api/v1/initiateTransaction?mid=%s&orderId=%s", encodedMid, encodedOrderId);
3. Confirm API Key and MID Match
Ensure the API key you're using is associated with the test MID you provided. A mismatch between these two values will trigger the invalid MID error. Double-check both credentials in your Paytm dashboard.
4. Validate Checksum Generation
Your code generates the checksum using the same body object sent in the request, which is correct. However, ensure no unintended changes are made to the body after generating the checksum (e.g., adding/removing fields).
5. Verify Test Environment Configuration
- You’re already using the correct test base URL (
https://securegw-stage.paytm.in). - The
websiteNameis set to"WEBSTAGING", which matches Paytm’s test environment requirements.
After applying these fixes, re-run your code to test the API call again.
Content of the question is sourced from Stack Exchange, asked by Shashi Ranjan

