Skip to content

Commit a634fc7

Browse files
committed
docs(readme.md): meta prop expects to recieve an object, not an array
Meta prop expects a single object that contains additional payment information fix #33
1 parent f618fa9 commit a634fc7

File tree

1 file changed

+73
-39
lines changed

1 file changed

+73
-39
lines changed

README.md

Lines changed: 73 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<img title="Flutterwave" height="200" src="https://flutterwave.com/images/logo-colored.svg" width="50%"/>
33
</p>
44

5-
65
# React Native Flutterwave
7-
Easily implement Flutterwave for payments in your React Native appliction. This library supports both Android and iOS, and use the Flutterwave's V3 API.
6+
7+
Easily implement Flutterwave for payments in your React Native appliction. This library supports both Android and iOS, and use the Flutterwave's V3 API.
88

99
[![V2 API](https://img.shields.io/badge/API-V3-brightgreen)](https://developer.flutterwave.com/docs) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
1010

@@ -14,6 +14,7 @@ Easily implement Flutterwave for payments in your React Native appliction. This
1414
</p>
1515

1616
## Table Of Content
17+
1718
- Getting Started
1819
- [V2 API](#warning-if-using-version-2-api-warning)
1920
- [Installation](#installation)
@@ -45,51 +46,61 @@ Easily implement Flutterwave for payments in your React Native appliction. This
4546
- [Contributing](./CONTRIBUTING.md)
4647

4748
## What's Inside?
49+
4850
- Pay with Flutterwave button and checkout dialog.
4951
- Standard payment initialization function.
5052
- Flutterwave designed button.
5153

5254
## :warning: If Using Version 2 API :warning:
55+
5356
This version of the library's docs focuses on use cases with the Version 3 of Flutterwaves API, if you are still using the Version 2 API please use [this documentation](./README.v2.md) instead.
5457

5558
## Installation
59+
5660
This library is available on npm, you can install it by running `npm install --save flutterwave-react-native` or `yarn add flutterwave-react-native`
5761

5862
### Dependencies
63+
5964
In order to render the Flutterwave checkout screen this library depends on [react-native-webview](https://github.com/react-native-community/react-native-webview) ensure you properly install this library before continuing.
6065

6166
### Activity Indicator (only needed for android)
67+
6268
To display the Flutterwave styled activity indicator when the checkout screen is being loaded on Android you will need to add some modules in `android/app/build.gradle`.
63-
***Skip this if you already have setup your app to support gif images.***
64-
````javascript
69+
**_Skip this if you already have setup your app to support gif images._**
70+
71+
```javascript
6572
dependencies {
6673
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
6774
implementation 'com.facebook.fresco:animated-base-support:1.3.0'
6875

6976
// For animated GIF support
7077
implementation 'com.facebook.fresco:animated-gif:2.0.0'
7178
}
72-
````
79+
```
7380

7481
### :fire: MERCHANT PUBLIC KEY :fire:
82+
7583
In order to use this library you are required to use your merchant public key and not the secret key. See how to get your API Keys [here](https://developer.flutterwave.com/v3.0/docs/api-keys)
7684

7785
### :fire: IMPORTANT INFORMATION :fire:
86+
7887
If the `options` property on [PayWithFlutterwave](#paywithflutterwaveprops-interface) changes, when next the user taps on the button a new payment will be initialized whether the last one was successful or not.
7988

8089
Remember you cannot use the same transaction reference for two different payments, also remember to recreate the transaction reference before allowing the user initiate a new payment.
8190

82-
8391
## Usage
92+
8493
Below are a few examples showcasing how you can use the library to implement payment in your React Native app.
8594

86-
### PayWithFlutterwave
95+
### PayWithFlutterwave
96+
8797
<img src=".github/images/pay-with-flutterwave.png" alt="preview" width="350"/>
8898

8999
[View All Props](#flutterwavebuttonprops)
90100

91101
Import `PayWithFlutterwave` from `flutterwave-react-native` and use it like so.
92-
````tsx
102+
103+
```tsx
93104
import {PayWithFlutterwave} from 'flutterwave-react-native';
94105
// or import PayWithFlutterwave from 'flutterwave-react-native';
95106

@@ -120,7 +131,7 @@ interface RedirectParams {
120131
...
121132
onRedirect={handleOnRedirect}
122133
options={{
123-
tx_ref: generateTransactionRef(10)
134+
tx_ref: generateTransactionRef(10)
124135
authorization: '[merchant public key]',
125136
customer: {
126137
email: 'customer-email@example.com'
@@ -130,15 +141,17 @@ interface RedirectParams {
130141
payment_options: 'card'
131142
}}
132143
/>
133-
````
144+
```
134145

135146
### PayWithFlutterwave (with custom render)
147+
136148
<img src=".github/images/pay-with-flutterwave-custom.png" alt="preview" width="350"/>
137149

138150
[View All Props](#flutterwavebuttonprops)
139151

140152
Import `PayWithFlutterwave` from `flutterwave-react-native` and use it like so.
141-
````tsx
153+
154+
```tsx
142155
import {PayWithFlutterwave} from 'flutterwave-react-native';
143156
// or import PayWithFlutterwave from 'flutterwave-react-native';
144157

@@ -167,30 +180,34 @@ interface RedirectParams {
167180
</TouchableOpacity>
168181
)}
169182
/>
170-
````
183+
```
171184

172185
### FlutterwaveButton (Flutterwave styled button)
186+
173187
<img src=".github/images/flutterwave-styled-button.png" alt="preview" width="350"/>
174188

175189
[View All Props](#flutterwavebuttonprops)
176190

177191
Import `FlutterwaveButton` from `flutterwave-react-native` and use it like so.
178-
````jsx
192+
193+
```jsx
179194
import {FlutterwaveButton} from 'flutterwave-react-native';
180195

181196
<FlutterwaveButton
182197
style={styles.paymentButton}
183198
onPress={onPress}
184199
disabled={disabled}>
185-
<Text style={styles.paymentButtonText}>Pay $500</Text>
186-
</FlutterwaveButton>
187-
````
200+
<Text style={styles.paymentButtonText}>Pay $500</Text>
201+
</FlutterwaveButton>;
202+
```
188203

189204
### FlutterwaveInit
205+
190206
When called, this function returns a Promise which resolves to a string on success and rejects if an error occurs. [See all config options](#flutterwaveinitoptions)
191207

192208
Import `FlutterwaveInit` from `flutterwave-react-native` and use it like so.
193-
````javascript
209+
210+
```javascript
194211
import {FlutterwaveInit} from 'flutterwave-react-native';
195212

196213
try {
@@ -201,25 +218,28 @@ try {
201218
amount: 100,
202219
currency: 'USD',
203220
customer: {
204-
email: 'customer-email@example.com'
221+
email: 'customer-email@example.com',
205222
},
206-
payment_options: 'card'
223+
payment_options: 'card',
207224
});
208225
// use payment link
209226
usePaymentLink(paymentLink);
210227
} catch (error) {
211228
// handle payment error
212229
displayError(error.message);
213230
}
214-
````
231+
```
232+
215233
### Aborting Payment Initialization
234+
216235
:wave: Hi, so there are cases where you have already initialized a payment with `FlutterwaveInit` but might also want to be able to cancel the payment initialization should in case your component is being unmounted or you want to allow users cancel the action before the payment is initialized, we have provided a way for you to do this... [continue reading](./docs/AbortingPaymentInitialization.md)
217236

218237
## Props
219238

220239
### FlutterwaveInitOptions
240+
221241
[See Interface](#flutterwaveinitoptions-interface)
222-
| Name | Required | Type | Default | Description |
242+
| Name | Required | Type | Default | Description |
223243
| --------- | --------- | ---- | ------- | ----------- |
224244
| authorization | Yes | string | **REQUIRED** | Your merchant public key, see how to get your [API Keys](https://developer.flutterwave.com/v3.0/docs/api-keys)|
225245
| tx_ref | Yes | string | **REQUIRED** | Your transaction reference. This MUST be unique for every transaction.|
@@ -235,8 +255,9 @@ try {
235255
| customizations | No | [FlutterwaveInitCustomizations](#flutterwaveinitcustomizations) | undefined | This is an object that contains title, logo, and description you want to display on the modal `E.g. {'title': 'Pied Piper Payments', 'description': 'Middleout isn't free. Pay the price', 'logo': 'https://assets.piedpiper.com/logo.png'}` |
236256

237257
### PayWithFlutterwaveProps
258+
238259
[See Interface](#paywithflutterwaveprops-interface)
239-
| Name | Required | Type | Default | Description |
260+
| Name | Required | Type | Default | Description |
240261
| --------- | --------- | ---- | ------- | ----------- |
241262
| style | No | object | undefined | Used to apply styling to the button.|
242263
| onRedirect | Yes | function | **REQUIRED** | Called when a payment is completed successfully or is canceled. The function will receive [redirect params](#redirectparams) as an argument.|
@@ -249,51 +270,58 @@ try {
249270
| alignLeft | No | boolean | undefined | This aligns the content of the button to the left. |
250271

251272
### FlutterwaveButton Props
273+
252274
[See Interface](#flutterwavebuttonprops-interface)
253-
| Name | Required | Type | Default | Description |
275+
| Name | Required | Type | Default | Description |
254276
| --------- | --------- | ---- | ------- | ----------- |
255277
| style | No | ViewStyle | undefined | This component uses the same style properties that are applicable to react-native's View component style.|
256278
| onPress | Yes | function | undefined | This property receive a function that is called on button press. |
257279
| disabled | No | boolean | undefined | This disables button, and causes onPress not to be fired.|
258280
| alignLeft | No | boolean | undefined | This aligns the content of the button to the left. |
259281

260282
## Types
283+
261284
#### CustomButtonProps
262-
````typescript
285+
286+
```typescript
263287
interface CustomButtonProps {
264288
disabled: boolean;
265289
isInitializing: boolean;
266290
onPress: () => void;
267291
}
268-
````
292+
```
269293

270294
#### RedirectParams
271-
````typescript
295+
296+
```typescript
272297
interface RedirectParams {
273-
status: 'successful' | 'cancelled',
298+
status: 'successful' | 'cancelled';
274299
transaction_id?: string;
275300
tx_ref: string;
276301
}
277-
````
302+
```
278303

279304
#### FlutterwaveInitError
280-
````typescript
305+
306+
```typescript
281307
interface FlutterwaveInitError {
282308
code: string;
283309
message: string;
284310
errorId?: string;
285311
errors?: Array<string>;
286312
}
287-
````
313+
```
288314

289315
#### FlutterwavePaymentMeta
290-
````typescript
316+
317+
```typescript
291318
interface FlutterwavePaymentMeta {
292319
[k: string]: any;
293320
}
294-
````
321+
```
295322

296323
### FlutterwaveInitCustomer
324+
297325
```typescript
298326
interface FlutterwaveInitCustomer {
299327
email: string;
@@ -303,6 +331,7 @@ interface FlutterwaveInitCustomer {
303331
```
304332

305333
### FlutterwaveInitCustomizations
334+
306335
```typescript
307336
interface FlutterwaveInitCustomizations {
308337
title?: string;
@@ -312,6 +341,7 @@ interface FlutterwaveInitCustomizations {
312341
```
313342

314343
### FlutterwaveInitSubAccount
344+
315345
```typescript
316346
interface FlutterwaveInitSubAccount {
317347
id: string;
@@ -322,7 +352,8 @@ interface FlutterwaveInitSubAccount {
322352
```
323353

324354
#### FlutterwaveInitOptions Interface
325-
````typescript
355+
356+
```typescript
326357
export interface FlutterwaveInitOptions {
327358
authorization: string;
328359
tx_ref: string;
@@ -334,13 +365,14 @@ export interface FlutterwaveInitOptions {
334365
redirect_url: string;
335366
customer: FlutterwaveInitCustomer;
336367
subaccounts?: Array<FlutterwaveInitSubAccount>;
337-
meta?: Array<FlutterwavePaymentMeta>;
368+
meta?: FlutterwavePaymentMeta;
338369
customizations?: FlutterwaveInitCustomizations;
339370
}
340-
````
371+
```
341372

342373
#### PayWithFlutterwaveProps Interface
343-
````typescript
374+
375+
```typescript
344376
interface PayWithFlutterwaveProps {
345377
style?: ViewStyle;
346378
onRedirect: (data: RedirectParams) => void;
@@ -352,19 +384,21 @@ interface PayWithFlutterwaveProps {
352384
customButton?: (props: CustomButtonProps) => React.ReactNode;
353385
alignLeft?: 'alignLeft' | boolean;
354386
}
355-
````
387+
```
356388

357389
#### FlutterwaveButtonProps Interface
358-
````typescript
390+
391+
```typescript
359392
interface FlutterwaveButtonProps {
360393
style?: StyleProp<ViewStyle>;
361394
disabled?: boolean;
362395
alignLeft?: boolean;
363396
onPress?: () => void;
364397
}
365-
````
398+
```
366399

367400
## Contributing
401+
368402
For information on how you can contribute to this repo, simply [go here](./CONTRIBUTING.md), all contributions are greatly appreciated.
369403

370404
With love from Flutterwave. :yellow_heart:

0 commit comments

Comments
 (0)