///Initialize IvorypayFlutter account for the diffrent states of the transactions
///Error,Success and Loading
final ivoryService = IvorypayFlutter(
context: context,
data: InitiateIvorypayTransaction(
baseFiat: "NGN",
amount: 4000,
crypto: "USDC",
email: 'EMAIL',
authorization: 'PUBLIC_API_KEY',
),
onError: (value, e) {},
onSuccess: (res) {},
onLoading: (valueLoading) {
setState(() {
isLoading = valueLoading;
});
},
);
///After initializing IvorypayFlutter you can call the run method to trigger the transactions
///NB: The loading state is triggered when run() is called.
ivoryService.run();
///Initialize IvorypayFlutterWeb account for the diffrent states of the transactions
///Error,Success and Loading
final ivorypayWebService = IvorypayFlutterWeb();
//Call the ivorypayWebService.run, using the ivorypay button an example would look like this
IvorypayButton(
option: IvorypayButtonOption.two,
onTap: () async {
///Flutter Web only implementation
ivorypayWebService.run(
isDev: true,
context: context,
data: InitiateIvorypayTransaction(
baseFiat: "NGN",
amount: int.tryParse(amountCtrl.text.trim()),
crypto: crypto.text,
email: email.text,
authorization: authCtrl.text,
),
onError: (value, e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString())));
},
onSuccess: (res) {
// Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(res.toString())));
},
onLoading: (valueLoading) {
setState(() {
isLoading = valueLoading;
});
},
);
},
),
//Calling run will open a new teb with the wallet address for the user to perform the tranasaction
//You may show a dialog on your web app for the user to confirm paymnet on return, when a user clicks on the dialog you an then call verify which will
//return the transaction details if it was successful or an error message if the action failed
ivorypayWebService.verifyStatus(
isDev: true,
onError: (value, e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString())));
},
onSuccess: (res) {
// Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(res.toString())));
},
);