Flutter sdk
The Atoa Flutter SDK enables your mobile app to accept payments through Atoa. Specifically designed for Flutter, it is currently not compatible with native Android or iOS platforms. You can find the Flutter SDK on pub.dev, where contributions and feedback from the developer community are welcome.
0. Prerequisites
First, you must create an Atoa account and generate the access secret. See the Getting Started guide for more information.
1. Installation
Run the following to add Atoa SDK to your Flutter project
flutter pub add atoa_flutter_sdk
2. Import package
import 'package:atoa_flutter_sdk/atoa_flutter_sdk.dart';
3. Create a Payment Request in Server
https://api.atoa.me/api/payments/process-payment
curl --location --request POST 'https://api.atoa.me/api/payments/process-payment' \
--header 'Authorization: Bearer {access-secret}' \
--header 'Content-Type: application/json' \
--data-raw '{
"customerId": "<Your Unique Customer Id>",
"orderId": "<Order Id>",
"amount": "<Total Amount >",
"currency": "GBP",
"paymentType": "<DOMESTIC>",
"autoRedirect": "<true or false>",
"consumerDetails": {
"phoneCountryCode": "<Country Code>",
"phoneNumber": "<Phone Number>"
}
}'
access-secret
here.Check the process-payment for further information.
4. Initiate Payment
Pass the paymentRequestId
, which you got by calling the process-payment API.
final transactionDetails = await AtoaSdk.show(
context,
paymentId: '<payment-request-id>',
env: AtoaEnv.prod,
);
env
should be passed as AtoaEnv.dev
5. Handle Payment Status
Two ways to handle payment status are Polling and Webhook.
Polling
Polling is handled out of the box by the package. Once the status is changed from PENDING
to SUCCESS
, the dialog with TransactionDetails
, including paymentIdempotencyId
and other values, is closed.
if (transactionDetails != null) {
if(transactionDetails.isCompleted) {
// handle success
} else {
// handle failure / pending statuses
}
} else {
// Bottom sheet was dismissed
}
Redirection
Redirection back to your app can be achieved by including redirectUrl
in API and setting up Deep Links in your app.
A few resources are given below
That’s how the redirection link will look like
https://<yourRedirectUrl>?status=<SUCCESS/FAILURE/PENDING>&paymenRequestId=<paymenRequestId>&paymentIdempotencyId=<paymentIdempotencyId>&orderId=<atoaOrderId>&atoaSignature=<atoaSignature>
Subscribe to webhook (Recommended)
Atoa uses webhooks to notify your application whenever an event happens in your account. Webhooks are particularly useful for events such as changes in payment status, such as completion, failure, or pending.
To get started, you must Register your webhook endpoint so Atoa knows where to deliver events.
After registration, your endpoint will start receiving detailed webhook payloads. These will inform you of payment status updates, such as COMPLETED
, PENDING
, or FAILED
.
6. Store Fields in Server
Store the following in your backend once the transaction is complete.
"signatureHash": string
"paymentIdempotencyId": string
atoaSignature
in redirectUrl
is same as the signatureHash
here.
7. Verify Payment Signature
This is a mandatory step to confirm the authenticity of the details returned to the Checkout form for successful payments.
You can verify the signature by doing this.
For any issues or inquiries, please get in touch with us by writing to hello@paywithatoa.co.uk or by clicking help.