initializeDirectPayment method

Future<NetworkResponse> initializeDirectPayment({
  1. required DirectChargeRequest request,
  2. required String publicKey,
})

Initializes a direct payment request. This method sends a request to the API to initialize a direct payment. Returns a NetworkResponse containing the result of the payment initiation.

Implementation

Future<NetworkResponse> initializeDirectPayment({
  /// [request]: The [DirectChargeRequest] object that contains the payment details.
  required DirectChargeRequest request,

  /// [publicKey]: The public key required for the API request.
  required String publicKey,
}) async {
  return apiClient.request(
    requestType: RequestType.post,
    path: ChapaUrl.directCharge,
    requiresAuth: true,
    data: request.toJson(),
    fromJsonSuccess: DirectChargeSuccessResponse.fromJson,
    fromJsonError: DirectChargeApiError.fromJson,
    publicKey: publicKey,
  );
}