Payumoney iOS SDK测试报错“key is not valid”求排查解决
Hey, let's break down this frustrating key is not valid error (Code 7025) you're hitting with PayUmoney's iOS checkout. I've tackled similar issues before, so here are the most common fixes to walk through:
1. Validate Your Test Credentials
First things first—double-check that you're using the correct test environment credentials:
- Ensure your Key, Merchant ID, and Salt are pulled directly from PayUmoney's test console (not production credentials). Mixing these up is a super common culprit.
- Watch out for accidental typos, extra spaces, or missing characters when copying these values. Even a single trailing space in your merchant key will trigger this error.
2. Verify Signature Generation (Critical!)
More often than not, this error is a red herring—it actually points to an invalid signature, not an incorrect key. PayUmoney requires a specific SHA-512 signature format for mobile checkout:
- Use this exact formula to generate your signature:
sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt) - Confirm you're using SHA-512 hashing (not SHA-256 or MD5).
- Every parameter included in the signature must exactly match what you pass to the SDK. For example:
- If your
amountis "100.00" in the signature, don't pass "100" to the SDK. - Ensure
txnidis a unique, alphanumeric string with no special characters.
- If your
3. Check SDK Parameter Setup
In your PaymentTestViewController, verify that you're passing credentials correctly to the SDK:
- When initializing
PaymentParam(or the equivalent object for your SDK version), confirm:merchantKeyis set to your test key (not empty or overwritten elsewhere)merchantIdmatches your test merchant ID- The generated signature is assigned to the
signaturefield without modifications
- Avoid hardcoding credentials in your app long-term, but for testing, make sure they're not being altered by other parts of your code.
4. Confirm Test Environment Endpoint
If you've manually configured the SDK's API endpoint, ensure it's pointing to PayUmoney's test server:
- The test base URL should be
https://test.payumoney.com/(some SDK versions require explicit setup of this value). Using the production endpoint with test credentials will throw this error.
5. Test with a Minimal Flow
Create a stripped-down version of your payment code with only the required parameters:
- Use a simple
txnid, fixedamount, basicproductinfo, and dummy user details (firstname, email) - Generate the signature strictly per the formula above
- If this minimal flow works, you'll know the issue is in a non-required parameter or edge case in your original code.
6. Update to the Latest SDK Version
Older versions of the PayUmoney iOS SDK might have bugs related to credential validation. Update to the latest version via CocoaPods or by downloading the framework directly from their developer portal.
If you still run into issues after these checks, enable debug logging in the SDK (if supported) to see the exact payload being sent to the server. This will often reveal a subtle parameter mismatch that's breaking the signature validation.
内容的提问来源于stack exchange,提问作者Abhishek Biswas

