create method
dynamic
create(
- dynamic apiKey, {
- required int amount,
- required String returnLink,
- required bool testMode,
- required String cardID,
- required String clientID,
- Map<
String, dynamic> ? metadata, - required void onDone(
- ConformPaymentModel data,
- CreatePaymentModel pData
- required void onError(),
Implementation
create(apiKey,
{required int amount,
required String returnLink,
required bool testMode,
required String cardID,
required String clientID,
Map<String, dynamic>? metadata,
required void Function(ConformPaymentModel data, CreatePaymentModel pData)
onDone,
required void Function(Map<String, dynamic> data) onError}) {
// https://uatcheckout.thawani.om/api/v1/payment_intents
String url = testMode
? "https://uatcheckout.thawani.om/api/v1/payment_intents"
: 'https://checkout.thawani.om/api/v1/payment_intents';
Request.post(url: url, data: {
"payment_method_id": cardID,
"amount": amount,
"client_reference_id": clientID,
"return_url": returnLink,
if (metadata != null) "metadata": metadata
}, headers: {
'Content-Type': "application/json",
'thawani-api-key': apiKey
}).then((value) {
if (value['status'] == 200) {
CreatePaymentModel model = CreatePaymentModel.fromJson(value['data']);
conform(
id: model.data!.id!,
apiKey: apiKey,
testMode: testMode,
onDone: (data) {
onDone(data, model);
},
onError: (error) {
onError(error);
});
} else {
onError(value['data']);
}
});
}