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
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.11.9"
def transact_version = "3.12.0"

android {
namespace "com.atomicfi.transactreactnative"
Expand Down
4 changes: 2 additions & 2 deletions atomicfi-transact-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Pod::Spec.new do |s|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
if respond_to?(:install_modules_dependencies, true)
install_modules_dependencies(s)
s.dependency "AtomicSDK", "3.20.7"
s.dependency "AtomicSDK", "3.22.0"
s.pod_target_xcconfig = {
"DEFINES_MODULE" => "YES",
}
else
s.dependency "React-Core"
s.dependency "AtomicSDK", "3.20.7"
s.dependency "AtomicSDK", "3.22.0"

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
Expand Down
68 changes: 67 additions & 1 deletion example/screens/TransactScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const TransactScreen: React.FC<Props> = () => {
const [isLoading, setIsLoading] = useState(false);
const [presentationStyleIOS, setPresentationStyleIOS] =
useState<PresentationStyleIOS>(PresentationStyles.formSheet);
const [useDeeplink, setUseDeeplink] = useState(false);
const [deeplinkCompanyId, setDeeplinkCompanyId] = useState('');
const [singleSwitch, setSingleSwitch] = useState(false);

const products = [
{ key: Product.DEPOSIT, label: 'Deposit' },
Expand Down Expand Up @@ -95,9 +98,14 @@ const TransactScreen: React.FC<Props> = () => {
return;
}

if (useDeeplink && !deeplinkCompanyId.trim()) {
Alert.alert('Error', 'Please enter a Company ID when using deeplink');
return;
}

setIsLoading(true);

const config = {
const config: any = {
publicToken: publicToken.trim(),
scope: getScope(),
tasks: [
Expand All @@ -107,6 +115,15 @@ const TransactScreen: React.FC<Props> = () => {
],
};

// Add deeplink configuration if enabled and company ID is provided
if (useDeeplink && deeplinkCompanyId.trim()) {
config.deeplink = {
step: 'login-company',
companyId: deeplinkCompanyId.trim(),
singleSwitch: singleSwitch,
};
}

Atomic.transact({
config,
environment: getEnvironment(),
Expand Down Expand Up @@ -263,6 +280,55 @@ const TransactScreen: React.FC<Props> = () => {
</View>
)}

<View style={styles.section}>
<Text style={styles.sectionTitle}>Deeplink Options (Optional)</Text>

<View style={styles.switchGroup}>
<Text style={styles.label}>Use Deeplink</Text>
<View style={styles.switchContainer}>
<Text style={styles.switchLabel}>Off</Text>
<Switch
value={useDeeplink}
onValueChange={setUseDeeplink}
trackColor={{ false: '#d1d5db', true: '#3b82f6' }}
thumbColor="#fff"
/>
<Text style={styles.switchLabel}>On</Text>
</View>
</View>

{useDeeplink && (
<>
<View style={styles.inputGroup}>
<Text style={styles.label}>Company ID</Text>
<TextInput
style={styles.input}
value={deeplinkCompanyId}
onChangeText={setDeeplinkCompanyId}
placeholder="Enter company ID for deeplink"
placeholderTextColor="#9ca3af"
/>
</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>

<View style={styles.buttonContainer}>
<TouchableOpacity
style={[styles.launchButton, isLoading && styles.disabledButton]}
Expand Down
37 changes: 13 additions & 24 deletions ios/TransactReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TransactReactNative: RCTEventEmitter {
platform["sdkVersion"] = platform["sdkVersion"] as! String + "-react"
json["platform"] = platform
}

guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else { return }

let config = try decoder.decode(AtomicConfig.self, from: data)
Expand All @@ -70,29 +70,18 @@ class TransactReactNative: RCTEventEmitter {
// Store the completion handler
self.dataResponseHandler = { responseData in
if let responseDict = responseData as? [String: Any] {
let identityDict = responseDict["identity"] as! [String: Any]
let cardDict = responseDict["card"] as! [String: Any]

let identity = TransactDataResponse.Identity(
firstName: identityDict["firstName"] as? String,
lastName: identityDict["lastName"] as? String,
postalCode: identityDict["postalCode"] as? String,
address: identityDict["address"] as? String,
city: identityDict["city"] as? String,
state: identityDict["state"] as? String,
phone: identityDict["phone"] as? String,
email: identityDict["email"] as? String
)

let card = TransactDataResponse.CardData(
number: cardDict["number"] as! String,
expiry: cardDict["expiry"] as! String,
cvv: cardDict["cvv"] as! String
)

let response = TransactDataResponse(card: card, identity: identity)

continuation.resume(returning: response)
// The SDK expects the response data to be passed directly
// Let the SDK handle the parsing internally
do {
let jsonData = try JSONSerialization.data(withJSONObject: responseDict, options: [])
let decoder = JSONDecoder()
let response = try decoder.decode(TransactDataResponse.self, from: jsonData)
continuation.resume(returning: response)
} catch {
// If decoding fails, return nil
print("Failed to decode TransactDataResponse: \(error)")
continuation.resume(returning: nil)
}
} else {
// If response isn't a dictionary or is nil
continuation.resume(returning: nil)
Expand Down
11 changes: 10 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ interface Customer {
name: String;
}

interface DeeplinkOptions {
step?: 'loginCompany' | 'loginPayroll' | 'addCard' | string;
companyId?: string;
connectorId?: string;
companyName?: string;
singleSwitch?: boolean;
}

interface Config {
publicToken: String;
scope: String;
Expand All @@ -52,7 +60,7 @@ interface Config {
theme?: Theme;
distribution?: Object;
language?: String;
deeplink?: Object;
deeplink?: DeeplinkOptions;
metadata?: Object;
search?: Object;
handoff?: String;
Expand All @@ -70,6 +78,7 @@ export const {
PresentationStyles,
} = CONSTANTS;
export type { TransactEnvironment, PresentationStyleIOS } from './constants';
export type { DeeplinkOptions };

export const Atomic = {
transact({
Expand Down