Flutterwave Rave Android支付集成测试异常及回调问题求助
Hey there, let's walk through the problems you're facing and get your Rave payment flow working as expected!
Issue 1: Test Card Payment Errors ("unable to retrieve transaction fees" + "only test cards are allowed")
Looking at your code, I spotted a critical mismatch between your environment setting and testing workflow:
You’re using test cards but have staging mode disabled: In your
makePaymentmethod, you set.onStagingEnv(false)— this switches the SDK to production mode, where test cards are explicitly blocked (which explains the Logcat message, despite the typo). Enable staging mode for testing:.onStagingEnv(true) // Set this to true for test environmentTransaction reference (
txRef) contains spaces: Your currenttxRefincludes a space between the email and UUID:txRef = email + " " + UUID.randomUUID().toString();. Spaces can cause unexpected parsing issues with payment gateways. Replace it with a non-space separator like underscores:txRef = email.replace(" ", "_") + "_" + UUID.randomUUID().toString();Double-check test credentials: Ensure your
PublicKeyandEncryptionKeyare the test versions (not production keys) from your Rave dashboard. Using production keys in staging mode will trigger validation errors.
Issue 2: Bank Payment Errors & Missing Success Callback
For the bank payment flow, here’s what to investigate:
Fix SDK version to resolve "parents_limit not defined": This error is often tied to outdated versions of the Rave Android SDK. Update your dependency to the latest stable version to patch this bug.
Don’t rely solely on
onActivityResultfor bank payments: Bank transfers are typically asynchronous — the user might complete the payment outside your app, so theonActivityResultcallback might not fire even if the transaction succeeds in the dashboard. You need to:- Set up a webhook URL in your Rave dashboard to receive real-time transaction status updates.
- Add a server-side check to verify the transaction status via Rave’s API when your app resumes, to confirm if the payment went through.
JSON format error: This is likely a side effect of the outdated SDK version mentioned above. Upgrading should resolve this parsing issue.
Final Revised makePayment Method
Here’s how your corrected method should look (with staging mode enabled and fixed txRef):
private void makePayment(int amount) { // Generate a valid, space-free transaction reference txRef = email.replace(" ", "_") + "_" + UUID.randomUUID().toString(); try { fullname = mUsername.split(" "); fName = fullname[0]; lName = fullname[1]; } catch (NullPointerException ex) { ex.printStackTrace(); // Fallback in case username doesn't have a space fName = mUsername; lName = ""; } /* Create instance of RavePayManager */ new RavePayManager(this).setAmount(amount) .setCountry(country) .setCurrency(currency) .setEmail(email) .setfName(fName) .setlName(lName) .setNarration(narration) .setPublicKey(RiiditUtilTool.getPublicKey()) .setEncryptionKey(RiiditUtilTool.getEncryptionKey()) .setTxRef(txRef) .acceptAccountPayments(true) .acceptCardPayments(true) .acceptMpesaPayments(false) .acceptGHMobileMoneyPayments(false) .onStagingEnv(true) // Enabled staging mode for testing .allowSaveCardFeature(true) .withTheme(R.style.DefaultTheme) .initialize(); }
Additional Checks
- Verify that your test card matches your selected country (NG) and currency (NGN) — use test cards specified for Nigerian NGN transactions.
- Ensure your app has proper internet permissions to communicate with Rave's servers.
内容的提问来源于stack exchange,提问作者philipsniche

