ApiPaymentDetailsProvider class

An API-based implementation of PaymentDetailsProvider that fetches payment details from the CoFee payment API.

This implementation:

  • Makes authenticated HTTP requests to the CoFee API
  • Handles different environments (sandbox/production)
  • Provides comprehensive error handling
  • Supports request timeouts
  • Parses and validates API responses

Example usage:

final provider = ApiPaymentDetailsProvider(
  clientId: 'your-client-id',
);

try {
  final details = await provider.getPaymentDetails(
    'order-123',
    PaymentEnvironment.sandbox,
  );
  print('Payment URL: ${details.getWebUrl}');
} on PaymentException catch (e) {
  print('Error: ${e.message}');
}
Inheritance

Constructors

ApiPaymentDetailsProvider({required String clientId, Client? httpClient})
Creates an ApiPaymentDetailsProvider with the specified clientId.

Properties

clientId String
The client ID used for authenticating API requests.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generateEndpoint(PaymentEnvironment paymentEnvironment) String
Determines the appropriate API base URL based on the payment environment.
getPaymentDetails(String orderId, PaymentEnvironment paymentEnvironment) Future<PaymentDetailsEntity>
Returns an entity containing the necessary payment details for processing a payment.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited