PaymentService class
A service that handles the complete payment flow in the CoFee Payment SDK.
This service orchestrates the entire payment process by:
- Fetching payment details from the API using a PaymentDetailsProvider
- Opening a secure in-app browser for payment processing
- Monitoring the payment process and handling callbacks
- Managing error handling and user notifications
Example usage:
final service = PaymentService(
paymentDetailsProvider: ApiPaymentDetailsProvider(clientId: 'your-client-id'),
paymentEnvironment: PaymentEnvironment.sandbox,
);
await service.pay(
'order-123',
onFinish: () => print('Payment completed'),
onError: (error) => print('Payment failed: $error'),
);
Constructors
- PaymentService.new({required PaymentDetailsProvider paymentDetailsProvider, required PaymentEnvironment paymentEnvironment})
- Creates a new PaymentService instance with the required dependencies.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- paymentDetailsProvider → PaymentDetailsProvider
-
Provider that fetches the necessary payment details from the API.
final
- paymentEnvironment → PaymentEnvironment
-
The environment in which payments should be processed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pay(
String orderId, {required PaymentCompletionCallback onFinish, required PaymentErrorCallback onError}) → Future< void> - Initiates and manages the complete payment flow for a specific order.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited