addPaymentMethod method

  1. @override
Future<PaymentMethod> addPaymentMethod({
  1. required String customerId,
  2. required AddPaymentMethodType paymentMethodType,
  3. String? idempotencyKey,
})
override

Implementation

@override
Future<PaymentMethod> addPaymentMethod({
  required String customerId,
  required AddPaymentMethodType paymentMethodType,
  String? idempotencyKey,
}) async {
  try {
    final result = await methodChannel.invokeMethod(
      'addPaymentMethod',
      {
        'customerId': customerId,
        'paymentMethodType': paymentMethodType.toMap(),
        'idempotencyKey': idempotencyKey,
      },
    );
    if (result != null) {
      final paymentMethodMap = Map<String, dynamic>.from(result);
      final paymentMethod = PaymentMethod.fromMap(paymentMethodMap);
      return paymentMethod;
    } else {
      throw PlatformException(
        code: 'NULL_RESULT',
        message: 'addPaymentMethod returned null',
      );
    }
  } on PlatformException {
    rethrow;
  }
}