atomic_transact_flutter 3.18.0
atomic_transact_flutter: ^3.18.0 copied to clipboard
A Flutter plugin that provides a native implementation for the Atomic Transact SDK.
Atomic Transact for Flutter #
A Flutter plugin that wraps the native Atomic Transact SDKs
Installation #
Add atomic_transact_flutter as a dependency in your pubspec.yaml file:
dependencies:
...
atomic_transact_flutter: <version>
iOS Requirements #
- Xcode 12.0 or greater
- iOS 14.0 or greater
Android Requirements #
Set the minSdkVersion in android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 21 // or greater
}
}
Responding to data requests #
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.
Running more than one Transact flow #
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.
Upgrading #
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.