Skip to content

Commit 84f6187

Browse files
committed
feat: add pay-now deeplink option
1 parent 35fc7ab commit 84f6187

2 files changed

Lines changed: 62 additions & 21 deletions

File tree

example/screens/TransactScreen.tsx

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const TransactScreen: React.FC<Props> = () => {
3939
const [useDeeplink, setUseDeeplink] = useState(false);
4040
const [deeplinkCompanyId, setDeeplinkCompanyId] = useState('');
4141
const [singleSwitch, setSingleSwitch] = useState(false);
42+
const [paymentsInput, setPaymentsInput] = useState('');
4243

4344
const products = [
4445
{ key: Product.DEPOSIT, label: 'Deposit' },
@@ -98,8 +99,11 @@ const TransactScreen: React.FC<Props> = () => {
9899
return;
99100
}
100101

101-
if (useDeeplink && !deeplinkCompanyId.trim()) {
102-
Alert.alert('Error', 'Please enter a Company ID when using deeplink');
102+
if (useDeeplink && !deeplinkCompanyId.trim() && !paymentsInput.trim()) {
103+
Alert.alert(
104+
'Error',
105+
'Please enter a Company ID or Payments when using deeplink'
106+
);
103107
return;
104108
}
105109

@@ -115,13 +119,27 @@ const TransactScreen: React.FC<Props> = () => {
115119
],
116120
};
117121

118-
// Add deeplink configuration if enabled and company ID is provided
119-
if (useDeeplink && deeplinkCompanyId.trim()) {
120-
config.deeplink = {
121-
step: 'login-company',
122-
companyId: deeplinkCompanyId.trim(),
123-
singleSwitch: singleSwitch,
124-
};
122+
// Add deeplink configuration if enabled
123+
if (useDeeplink) {
124+
if (paymentsInput.trim()) {
125+
// If payments input is provided, use pay-now step
126+
const paymentsArray = paymentsInput
127+
.split(',')
128+
.map((p) => p.trim())
129+
.filter((p) => p.length > 0);
130+
131+
config.deeplink = {
132+
step: 'pay-now',
133+
payments: paymentsArray,
134+
};
135+
} else if (deeplinkCompanyId.trim()) {
136+
// Otherwise use login-company step if company ID is provided
137+
config.deeplink = {
138+
step: 'login-company',
139+
companyId: deeplinkCompanyId.trim(),
140+
singleSwitch: singleSwitch,
141+
};
142+
}
125143
}
126144

127145
Atomic.transact({
@@ -311,19 +329,36 @@ const TransactScreen: React.FC<Props> = () => {
311329
</View>
312330

313331
{selectedProduct === Product.SWITCH && (
314-
<View style={styles.switchGroup}>
315-
<Text style={styles.label}>Single Switch</Text>
316-
<View style={styles.switchContainer}>
317-
<Text style={styles.switchLabel}>Off</Text>
318-
<Switch
319-
value={singleSwitch}
320-
onValueChange={setSingleSwitch}
321-
trackColor={{ false: '#d1d5db', true: '#3b82f6' }}
322-
thumbColor="#fff"
332+
<>
333+
<View style={styles.switchGroup}>
334+
<Text style={styles.label}>Single Switch</Text>
335+
<View style={styles.switchContainer}>
336+
<Text style={styles.switchLabel}>Off</Text>
337+
<Switch
338+
value={singleSwitch}
339+
onValueChange={setSingleSwitch}
340+
trackColor={{ false: '#d1d5db', true: '#3b82f6' }}
341+
thumbColor="#fff"
342+
/>
343+
<Text style={styles.switchLabel}>On</Text>
344+
</View>
345+
</View>
346+
<View style={styles.inputGroup}>
347+
<Text style={styles.label}>Payments (pay-now step)</Text>
348+
<TextInput
349+
style={styles.input}
350+
value={paymentsInput}
351+
onChangeText={setPaymentsInput}
352+
placeholder="Enter payments (e.g. telecom)"
353+
placeholderTextColor="#9ca3af"
354+
autoCapitalize="none"
323355
/>
324-
<Text style={styles.switchLabel}>On</Text>
356+
<Text style={styles.helperText}>
357+
Comma-separated values. If provided, uses pay-now step
358+
instead of login-company.
359+
</Text>
325360
</View>
326-
</View>
361+
</>
327362
)}
328363
</>
329364
)}
@@ -384,6 +419,11 @@ const styles = StyleSheet.create({
384419
color: '#1f2937',
385420
backgroundColor: '#ffffff',
386421
},
422+
helperText: {
423+
fontSize: 12,
424+
color: '#6b7280',
425+
marginTop: 4,
426+
},
387427
customUrlInput: {
388428
marginTop: 12,
389429
},

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ interface Customer {
4444
}
4545

4646
interface DeeplinkOptions {
47-
step?: 'loginCompany' | 'loginPayroll' | 'addCard' | string;
47+
step?: 'loginCompany' | 'loginPayroll' | 'addCard' | 'pay-now' | string;
4848
companyId?: string;
4949
connectorId?: string;
5050
companyName?: string;
5151
singleSwitch?: boolean;
52+
payments?: string[];
5253
}
5354

5455
interface Config {

0 commit comments

Comments
 (0)