PaymentResponse class

Standardized payment response model

Constructors

PaymentResponse.new({required PaymentStatus status, required String message, String? transactionId, String? orderId, PaymentProvider? provider, String? errorCode, Map<String, dynamic>? rawResponse, DateTime? timestamp, double? amount, String? currency, Map<String, dynamic>? metadata})
PaymentResponse.cancelled({required String message, String? orderId, PaymentProvider? provider, Map<String, dynamic>? rawResponse})
Create a cancelled payment response
factory
PaymentResponse.failure({required String message, String? errorCode, String? orderId, PaymentProvider? provider, Map<String, dynamic>? rawResponse, Map<String, dynamic>? metadata})
Create a failed payment response
factory
PaymentResponse.fromJson(Map<String, dynamic> json)
Create from JSON
factory
PaymentResponse.pending({required String message, String? transactionId, String? orderId, PaymentProvider? provider, Map<String, dynamic>? rawResponse})
Create a pending payment response
factory
PaymentResponse.success({required String transactionId, required String message, String? orderId, PaymentProvider? provider, double? amount, String? currency, Map<String, dynamic>? rawResponse, Map<String, dynamic>? metadata})
Create a successful payment response
factory
PaymentResponse.timeout({required String message, String? orderId, PaymentProvider? provider})
Create a timeout payment response
factory
PaymentResponse.unknown({required String message, String? orderId, PaymentProvider? provider, Map<String, dynamic>? rawResponse})
Create an unknown status payment response
factory

Properties

amount double?
Amount that was processed (if available)
final
currency String?
Currency used for the payment
final
errorCode String?
Error code if payment failed
final
hashCode int
The hash code for this object.
no setterinherited
isCancelled bool
Check if payment was cancelled
no setter
isFailure bool
Check if payment failed
no setter
isPending bool
Check if payment is pending
no setter
isSuccess bool
Check if payment was successful
no setter
isTimeout bool
Check if payment timed out
no setter
message String
Human-readable message describing the result
final
metadata Map<String, dynamic>?
Additional metadata from the payment provider
final
orderId String?
Order ID from the original request
final
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
provider PaymentProvider?
Payment provider that processed the payment
final
rawResponse Map<String, dynamic>?
Raw response from the payment provider (for debugging)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status PaymentStatus
Status of the payment
final
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
timestamp DateTime
Timestamp when the response was created
final
transactionId String?
Unique transaction ID from the payment provider
final

Methods

copyWith({PaymentStatus? status, String? transactionId, String? orderId, PaymentProvider? provider, String? message, String? errorCode, Map<String, dynamic>? rawResponse, DateTime? timestamp, double? amount, String? currency, Map<String, dynamic>? metadata}) PaymentResponse
Create a copy of this response with updated values
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Convert to JSON
toString() String
A string representation of this object.

Operators

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