createRegistrationLink method

Future<Response<RazorpayRegistrationLink>> createRegistrationLink({
  1. required RazorpayRegistrationLinkBaseRequestBody params,
  2. void callback(
    1. RazorpayApiException?,
    2. Response<RazorpayRegistrationLink>?
    )?,
})

Creates a Registration Link This is equivalent to calling create() with RazorpayRegistrationLinkBaseRequestBody

Implementation

Future<Response<RazorpayRegistrationLink>> createRegistrationLink({
  required RazorpayRegistrationLinkBaseRequestBody params,
  void Function(RazorpayApiException?, Response<RazorpayRegistrationLink>?)?
      callback,
}) async {
  final response =
      await create(params: params); // Call the dynamic create method
  // Cast the dynamic response data if successful
  if (response.data is RazorpayRegistrationLink) {
    final typedResponse = Response<RazorpayRegistrationLink>(
      data: response.data as RazorpayRegistrationLink,
      headers: response.headers,
      requestOptions: response.requestOptions,
      isRedirect: response.isRedirect,
      statusCode: response.statusCode,
      statusMessage: response.statusMessage,
      redirects: response.redirects,
      extra: response.extra,
    );
    callback?.call(null, typedResponse);
    return typedResponse;
  } else {
    final error = RazorpayApiException(
      message:
          'Failed to create registration link or unexpected response type',
    );
    callback?.call(error, null);
    throw error;
  }
}