A Flutter plugin that wraps the native Atomic Transact SDKs
Add atomic_transact_flutter as a dependency in your pubspec.yaml file:
dependencies:
...
atomic_transact_flutter: <version>- Xcode 12.0 or greater
- iOS 14.0 or greater
Set the minSdkVersion in android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 21 // or greater
}
}Each platform has its own presentation style, and each one ignores the other's.
iOS presents Transact as a form sheet by default, and Android presents it full
screen. Pass presentationStyleIOS or presentationStyleAndroid to change
that:
await Atomic.transact(
config: config,
presentationStyleIOS: AtomicPresentationStyleIOS.fullScreen,
presentationStyleAndroid: AtomicPresentationStyleAndroid.formSheet,
);On Android, the form sheet is a bottom sheet over your dimmed app on phones, and a centered card on screens of at least 600×480dp. It's modal, so users close it with Transact's close button or the back button, not by swiping it down or tapping outside it.
Transact emits a data request when it needs information that only your app can
supply, such as card or identity details for a deferred payment method. Return
an AtomicTransactDataResponse from onDataRequest and it is sent back to
Transact. The handler may be asynchronous, so you can prompt the user or call
your backend before responding.
await Atomic.transact(
config: config,
onDataRequest: (request) async {
// request.fields lists what Transact is asking for, e.g. ['card']
final card = await promptForCard();
return AtomicTransactDataResponse(
card: AtomicTransactCardData(
number: card.number,
expiry: card.expiry, // MM/YY
cvv: card.cvv,
cardType: AtomicTransactCardType.debit,
),
identity: const AtomicTransactIdentity(
firstName: 'Ada',
lastName: 'Lovelace',
postalCode: '84043',
),
);
},
);Returning null sends nothing back, and Transact keeps waiting for data.
Every Atomic.transact call gets its own callbacks, so launching Transact again
never replaces the callbacks of a flow that's still running. A task can keep
sending onTaskStatusUpdate after onCompletion, while its work finishes in
the background. onCleanup is the last callback a flow sends. After it, the
flow sends nothing more.
final task = await Atomic.transact(
config: config,
onTaskStatusUpdate: (update) => print('${update.taskId}: ${update.status}'),
onCompletion: (type, response, error) => print('UI closed: ${type.name}'),
onCleanup: () => print('done'),
);
// Stop receiving this flow's callbacks without closing Transact.
task.remove();Atomic.close() closes every flow that hasn't finished or closed yet,
including hidden and paused ones. Those flows get onCleanup but not
onCompletion, so reset any "Transact is open" state there too.
Atomic.hide() hides every Transact on screen, and those flows keep running.
Atomic.transactno longer ignores calls while Transact is open. Every call launches Transact, so disable your launch button untilonCompletionif you only want one flow at a time.Atomic.transactnow returns aFuture<AtomicTransactTask>instead ofFuture<void>. It throws aPlatformExceptionif Transact can't be presented, so await it or catch the error.
More info at https://docs.atomicfi.com.