pay method
Implementation
@override
Future<GetnetPaymentResponse> pay({required GetnetPaymentPayload paymentPayload}) async {
try {
final response = await methodChannel.invokeMethod<Map>('pay', paymentPayload.toJson());
if (response is Map) {
if ((response['code'] == GetnetStatusDeeplink.SUCCESS.name || response['code'] == GetnetStatusDeeplink.PENDING.name) && response['data'] is Map) {
if (response['code'] == GetnetStatusDeeplink.SUCCESS.name) {
final jsonData = response['data'];
return GetnetPaymentResponse.fromJson(jsonData);
} else {
return GetnetPaymentResponse(
result: response['result'] ?? '5',
resultDetails: 'Operação ainda pendente cancelada pelo lojista, realize consulta do status',
printMerchantPreference: response['printMerchantPreference'] ?? false,
amount: paymentPayload.amount,
callerId: paymentPayload.callerId,
receiptAlreadyPrinted: false,
type: '',
inputType: '',
);
}
} else {
throw GetnetPaymentException(message: response['message']);
}
} else {
throw GetnetPaymentException(message: 'invalid response');
}
} on GetnetPaymentException catch (e) {
throw GetnetPaymentException(message: e.message);
} on PlatformException catch (e) {
throw GetnetPaymentException(message: e.message ?? 'PlatformException');
} catch (e) {
throw GetnetPaymentException(message: "Pay Error: $e");
}
}