Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ on:

jobs:
notify:
uses: atomicfi/mobile-conformance-tests/.github/workflows/notify_releases.yml@main
uses: atomicfi/sdk-release-notifications/.github/workflows/notify_releases.yml@main
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASES_WEBHOOK_URL }}
NOTION_API_KEY: ${{ secrets.NOTION_RELEASES_API_KEY }}
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
GITHUB_DEPLOY_KEY: ${{ secrets.CONFORMANCE_REPO_PULL_KEY }}
GITHUB_DEPLOY_KEY: ${{ secrets.NOTIFICATIONS_REPO_PULL_KEY }}
GITHUB_RELEASE_PULL_TOKEN: ${{ github.token }}
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def getExtOrIntegerDefault(name) {
}

// Update this value to the latest Android SDK version published on Maven
def transact_version = "3.13.0"
def transact_version = "3.15.1"

android {
namespace "com.atomicfi.transactreactnative"
Expand Down
126 changes: 73 additions & 53 deletions example/screens/TransactScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ import {
Scope,
Environment,
PresentationStyles,
Step,
} from '@atomicfi/transact-react-native';
import type {
PresentationStyleIOS,
StepType,
} from '@atomicfi/transact-react-native';
import type { PresentationStyleIOS } from '@atomicfi/transact-react-native';

type Props = NativeStackScreenProps<RootStackParamList, 'Transact'>;

Expand All @@ -39,7 +43,9 @@ const TransactScreen: React.FC<Props> = () => {
const [useDeeplink, setUseDeeplink] = useState(false);
const [deeplinkCompanyId, setDeeplinkCompanyId] = useState('');
const [singleSwitch, setSingleSwitch] = useState(false);
const [paymentsInput, setPaymentsInput] = useState('');
const [deeplinkStep, setDeeplinkStep] = useState<StepType>(
Step.LOGIN_COMPANY
);

const products = [
{ key: Product.DEPOSIT, label: 'Deposit' },
Expand Down Expand Up @@ -99,11 +105,12 @@ const TransactScreen: React.FC<Props> = () => {
return;
}

if (useDeeplink && !deeplinkCompanyId.trim() && !paymentsInput.trim()) {
Alert.alert(
'Error',
'Please enter a Company ID or Payments when using deeplink'
);
// Company ID is only required for steps that target a specific company (not search)
const requiresCompanyId =
deeplinkStep !== Step.SEARCH_COMPANY &&
deeplinkStep !== Step.SEARCH_PAYROLL;
if (useDeeplink && requiresCompanyId && !deeplinkCompanyId.trim()) {
Alert.alert('Error', 'Please enter a Company ID when using deeplink');
return;
}

Expand All @@ -121,25 +128,13 @@ const TransactScreen: React.FC<Props> = () => {

// Add deeplink configuration if enabled
if (useDeeplink) {
if (paymentsInput.trim()) {
// If payments input is provided, use pay-now step
const paymentsArray = paymentsInput
.split(',')
.map((p) => p.trim())
.filter((p) => p.length > 0);

config.deeplink = {
step: 'pay-now',
payments: paymentsArray,
};
} else if (deeplinkCompanyId.trim()) {
// Otherwise use login-company step if company ID is provided
config.deeplink = {
step: 'login-company',
config.deeplink = {
step: deeplinkStep,
...(deeplinkCompanyId.trim() && {
companyId: deeplinkCompanyId.trim(),
singleSwitch: singleSwitch,
};
}
}),
singleSwitch: singleSwitch,
};
}

Atomic.transact({
Expand Down Expand Up @@ -317,6 +312,48 @@ const TransactScreen: React.FC<Props> = () => {

{useDeeplink && (
<>
<View style={styles.inputGroup}>
<Text style={styles.label}>Step</Text>
<View style={styles.optionGrid}>
<TouchableOpacity
style={[
styles.optionButton,
deeplinkStep === Step.LOGIN_COMPANY &&
styles.selectedOption,
]}
onPress={() => setDeeplinkStep(Step.LOGIN_COMPANY)}
>
<Text
style={[
styles.optionText,
deeplinkStep === Step.LOGIN_COMPANY &&
styles.selectedOptionText,
]}
>
Login Company
</Text>
</TouchableOpacity>
<TouchableOpacity
style={[
styles.optionButton,
deeplinkStep === Step.SEARCH_COMPANY &&
styles.selectedOption,
]}
onPress={() => setDeeplinkStep(Step.SEARCH_COMPANY)}
>
<Text
style={[
styles.optionText,
deeplinkStep === Step.SEARCH_COMPANY &&
styles.selectedOptionText,
]}
>
Search Company
</Text>
</TouchableOpacity>
</View>
</View>

<View style={styles.inputGroup}>
<Text style={styles.label}>Company ID</Text>
<TextInput
Expand All @@ -329,36 +366,19 @@ const TransactScreen: React.FC<Props> = () => {
</View>

{selectedProduct === Product.SWITCH && (
<>
<View style={styles.switchGroup}>
<Text style={styles.label}>Single Switch</Text>
<View style={styles.switchContainer}>
<Text style={styles.switchLabel}>Off</Text>
<Switch
value={singleSwitch}
onValueChange={setSingleSwitch}
trackColor={{ false: '#d1d5db', true: '#3b82f6' }}
thumbColor="#fff"
/>
<Text style={styles.switchLabel}>On</Text>
</View>
</View>
<View style={styles.inputGroup}>
<Text style={styles.label}>Payments (pay-now step)</Text>
<TextInput
style={styles.input}
value={paymentsInput}
onChangeText={setPaymentsInput}
placeholder="Enter payments (e.g. telecom)"
placeholderTextColor="#9ca3af"
autoCapitalize="none"
<View style={styles.switchGroup}>
<Text style={styles.label}>Single Switch</Text>
<View style={styles.switchContainer}>
<Text style={styles.switchLabel}>Off</Text>
<Switch
value={singleSwitch}
onValueChange={setSingleSwitch}
trackColor={{ false: '#d1d5db', true: '#3b82f6' }}
thumbColor="#fff"
/>
<Text style={styles.helperText}>
Comma-separated values. If provided, uses pay-now step
instead of login-company.
</Text>
<Text style={styles.switchLabel}>On</Text>
</View>
</>
</View>
)}
</>
)}
Expand Down
19 changes: 19 additions & 0 deletions src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@ export const DeferredPaymentMethodStrategy = {
SDK: 'sdk',
API: 'api',
};

export const App = {
PAY_NOW: 'pay-now',
TRANSACTIONS: 'transactions',
ORDERS: 'orders',
SUGGESTIONS: 'suggestions',
} as const;

export type AppType = (typeof App)[keyof typeof App] | (string & {});

export const Step = {
ADD_CARD: 'add-card',
LOGIN_COMPANY: 'login-company',
LOGIN_PAYROLL: 'login-payroll',
SEARCH_COMPANY: 'search-company',
SEARCH_PAYROLL: 'search-payroll',
} as const;

export type StepType = (typeof Step)[keyof typeof Step] | (string & {});
16 changes: 13 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Appearance, NativeModules, Platform } from 'react-native';
import { AtomicIOS } from './ios';
import { AtomicAndroid } from './android';
import * as CONSTANTS from './constants';
import type { PresentationStyleIOS } from './constants';
import type { PresentationStyleIOS, AppType, StepType } from './constants';

const LINKING_ERROR =
`The package '@atomicfi/transact-react-native' doesn't seem to be linked. Make sure: \n\n` +
Expand Down Expand Up @@ -37,19 +37,22 @@ interface Task {
operation: String;
distribution?: Object;
navigationOptions?: Object;
apps?: AppType[];
}

interface Customer {
name: String;
}

interface DeeplinkOptions {
step?: 'loginCompany' | 'loginPayroll' | 'addCard' | 'pay-now' | string;
step?: StepType;
app?: AppType;
companyId?: string;
connectorId?: string;
companyName?: string;
singleSwitch?: boolean;
payments?: string[];
accountId?: string;
}

interface Config {
Expand Down Expand Up @@ -77,8 +80,15 @@ export const {
Environment,
DeferredPaymentMethodStrategy,
PresentationStyles,
App,
Step,
} = CONSTANTS;
export type { TransactEnvironment, PresentationStyleIOS } from './constants';
export type {
TransactEnvironment,
PresentationStyleIOS,
AppType,
StepType,
} from './constants';
export type { DeeplinkOptions };

export const Atomic = {
Expand Down