confirmPaymentWithGooglePay method
Future<Map<String, dynamic> >
confirmPaymentWithGooglePay(
- BuildContext context, {
- required String paymentIntentClientSecret,
- required Map<
String, dynamic> paymentResult,
Confirm and authenticate a payment with Google Pay.
/// paymentResult
must be the result of requesting a Google Pay payment with the pay
library.
Returns the PaymentIntent.
Implementation
Future<Map<String, dynamic>> confirmPaymentWithGooglePay(BuildContext context,
{required String paymentIntentClientSecret, required Map<String, dynamic> paymentResult}) async {
final data = <String, dynamic>{'return_url': getReturnUrlForSca()};
final String token = paymentResult['paymentMethodData']['tokenizationData']['token'] as String;
final tokenJson = jsonDecode(token) as Map<String, dynamic>;
final tokenId = tokenJson['id'] as String;
data['payment_method_data'] = {
'type': 'card',
"card": {"token": tokenId}
};
final Map<String, dynamic> paymentIntent = await api.confirmPaymentIntent(
paymentIntentClientSecret,
data: data,
);
return _handlePaymentIntent(paymentIntent, context);
}