Skip to content

Commit 60c652b

Browse files
committed
Document how to use RaveVerificationUtils class
1 parent 9fbe942 commit 60c652b

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

ChargeVerificationUtils.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Charge Verification Utils
2+
This module helps you handle charge verification when not using the default drop-in UI provided by Flutterwave's android SDK.
3+
4+
**Step 1.** Add this in your root build.gradle at the end of repositories:
5+
6+
allprojects {
7+
repositories {
8+
...
9+
maven { url 'https://jitpack.io' }
10+
}
11+
}
12+
13+
**Step 2.** Add the dependency for the utils library
14+
15+
dependencies {
16+
implementation 'com.github.Flutterwave.rave-android:rave_utils:2.0.3'
17+
}
18+
19+
**Step 2.** In your payment activity or fragment, create and instance of the `RaveVerificationUtils` class
20+
21+
RaveVerificationUtils verificationUtils = new RaveVerificationUtils(contextProvider, isStaging, publicKey, theme);
22+
23+
##### Parameter definitions
24+
| Parameter Name | Description | Type | Required |
25+
| ------------- |:-------------:| -----:| -----:|
26+
| contextProvider | This is the application or fragment class where you're handling the charge verification. | `Activity` or `Fragment` | Required
27+
| isStaging | Specifies whether it's the staging or live environment. | `Boolean` | Required
28+
| publicKey | Your Flutterwave account's public key. | `String` | Required
29+
| theme | Reference to your custom style. | `int` | Not required
30+
31+
**Step 3** You can call the verification class for these scenarios:
32+
33+
```
34+
// For PIN collection:
35+
verificationUtils.showPinScreen();
36+
37+
// For OTP collection
38+
verificationUtils.showOtpScreen(instructionToBeDisplayed); // instruction parameter is optional
39+
40+
// For Address collection
41+
verificationUtils.showAddressScreen();
42+
43+
// For Authentication webpage display
44+
verificationUtils.showWebpageVerificationScreen(authUrl);
45+
```
46+
47+
**Step 4** Handle the result in `onActivityResult`:
48+
49+
```
50+
@Override
51+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
52+
53+
if (resultCode == RaveConstants.RESULT_SUCCESS) {
54+
switch (requestCode) {
55+
case RaveConstants.PIN_REQUEST_CODE:
56+
String pin = data.getStringExtra(PinFragment.EXTRA_PIN);
57+
// Use the collected PIN
58+
cardPayManager.submitPin(pin);
59+
break;
60+
case RaveConstants.ADDRESS_DETAILS_REQUEST_CODE:
61+
String streetAddress = data.getStringExtra(AVSVBVFragment.EXTRA_ADDRESS);
62+
String state = data.getStringExtra(AVSVBVFragment.EXTRA_STATE);
63+
String city = data.getStringExtra(AVSVBVFragment.EXTRA_CITY);
64+
String zipCode = data.getStringExtra(AVSVBVFragment.EXTRA_ZIPCODE);
65+
String country = data.getStringExtra(AVSVBVFragment.EXTRA_COUNTRY);
66+
AddressDetails address = new AddressDetails(streetAddress, city, state, zipCode, country);
67+
68+
// Use the address details
69+
cardPayManager.submitAddress(address);
70+
break;
71+
case RaveConstants.WEB_VERIFICATION_REQUEST_CODE:
72+
// Web authentication complete, proceed
73+
cardPayManager.onWebpageAuthenticationComplete();
74+
break;
75+
case RaveConstants.OTP_REQUEST_CODE:
76+
String otp = data.getStringExtra(OTPFragment.EXTRA_OTP);
77+
// Use OTP
78+
cardPayManager.submitOtp(otp);
79+
break;
80+
}
81+
} else {
82+
super.onActivityResult(requestCode, resultCode, data);
83+
}
84+
}
85+
```

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ For example to charge cards, use the `CardPaymentManager`
186186

187187
cardPayManager.chargeCard(card);
188188

189+
> We worked on a module to simplify charge verification when using the No-UI approach. You can read about using it [here](ChargeVerificationUtils.md)
190+
189191
> To see a more practical way of using the sdk, head to our sample app in the repository [here](https://github.com/Flutterwave/rave-android/tree/master/app)
190192
## Functions definition
191193
| function | parameter | type | required |

0 commit comments

Comments
 (0)