createPaymentMethod method

Future<PaymentMethod> createPaymentMethod({
  1. required PaymentMethodParams params,
  2. PaymentMethodOptions? options,
})

Converts payment information defined in params into a PaymentMethod object that can be passed to your server.

params specificies the parameters associated with the specific paymentmethod. See PaymentMethodParams for more details.

Throws an StripeException in case creating the payment method fails.

Implementation

Future<PaymentMethod> createPaymentMethod({
  required PaymentMethodParams params,
  PaymentMethodOptions? options,
}) async {
  await _awaitForSettings();
  try {
    final paymentMethod =
        await _platform.createPaymentMethod(params, options);
    return paymentMethod;
  } on StripeError catch (error) {
    throw StripeError(message: error.message, code: error.message);
  }
}