pay method
Future<LaranjinhaPaymentResponse>
pay({
- required LaranjinhaPaymentPayload paymentPayload,
override
Implementation
@override
Future<LaranjinhaPaymentResponse> pay({required LaranjinhaPaymentPayload paymentPayload}) async {
try {
final response = await methodChannel.invokeMethod<Map>('pay', paymentPayload.toJson());
if (response is Map) {
if (response['code'] == LaranjinhaStatusDeeplink.SUCCESS.name) {
final jsonData = Map.from(response['data']);
return LaranjinhaPaymentResponse.fromJson(json: jsonData.cast());
} else {
throw LaranjinhaPaymentException(message: response['message']);
}
} else {
throw LaranjinhaRefundException(message: 'invalid response');
}
} on LaranjinhaPaymentException catch (e) {
throw LaranjinhaPaymentException(message: e.message);
} on PlatformException catch (e) {
throw LaranjinhaPaymentException(message: e.message ?? 'PlatformException');
} catch (e) {
throw LaranjinhaPaymentException(message: "Pay Error: $e");
}
}