Skip to content

Commit b08ac80

Browse files
authored
expose metadata props (#185)
1 parent 59cef7e commit b08ac80

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

development/paystack.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
3030
onSuccess,
3131
activityIndicatorColor = 'green',
3232
modalProps,
33+
metadata
3334
},
3435
ref,
3536
) => {
@@ -77,6 +78,8 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
7778

7879
const invoiceLimitString = invoice_limit? `invoice_limit: ${invoice_limit},` : ''; // should only send invoice limit as integer when plan subscription is specified
7980

81+
const metaDataString = metadata ? `metadata: ${metadata},` : `metadata: { custom_fields: [{ display_name: '${firstName + ' ' + lastName}', variable_name: '${billingName}', value:'' }]},`;
82+
8083
const Paystackcontent = `
8184
<!DOCTYPE html>
8285
<html lang="en">
@@ -107,14 +110,7 @@ const Paystack: React.ForwardRefRenderFunction<React.ReactNode, PayStackProps> =
107110
${subAccountString}
108111
${splitCodeString}
109112
${dynamicSplitString}
110-
metadata: {
111-
custom_fields: [
112-
{
113-
display_name: '${firstName + ' ' + lastName}',
114-
variable_name: '${billingName}',
115-
value:''
116-
}
117-
]},
113+
${metaDataString}
118114
onSuccess: function(response){
119115
var resp = {event:'successful', transactionRef:response};
120116
window.ReactNativeWebView.postMessage(JSON.stringify(resp))

development/types/index.ts

+21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ export interface DynamicMultiSplitProps {
2828
reference?: string;
2929
}
3030

31+
type CustomField = {
32+
display_name: string;
33+
variable_name: string;
34+
value: string | number;
35+
};
36+
37+
type CustomFilters = {
38+
recurring?: boolean;
39+
banks?: string[];
40+
card_brands?: ('verve' | 'visa' | 'mastercard')[];
41+
supported_mobile_money_providers?: ('mtn' | 'atl' | 'vod')[];
42+
};
43+
44+
type Metadata = {
45+
cart_id?: string | number;
46+
custom_fields?: CustomField[];
47+
cancel_action?: string;
48+
custom_filters?: CustomFilters;
49+
};
50+
3151
export interface PayStackProps {
3252
paystackKey: string;
3353
billingEmail: string;
@@ -51,6 +71,7 @@ export interface PayStackProps {
5171
activityIndicatorColor?: string;
5272
ref: React.ReactElement;
5373
modalProps?: ModalProps;
74+
metadata?: Metadata;
5475
}
5576

5677
export interface PayStackRef {

0 commit comments

Comments
 (0)