feat: payment split
This commit is contained in:
@@ -78,3 +78,57 @@ class PaymentOrderItemModel {
|
||||
"amount": amount,
|
||||
};
|
||||
}
|
||||
|
||||
class PaymentSplitBillRequest {
|
||||
final String orderId;
|
||||
final String paymentMethodId;
|
||||
final String customerId;
|
||||
final String type; // e.g., "AMOUNT" or "ITEM"
|
||||
final int amount;
|
||||
final List<SplitItem> items;
|
||||
|
||||
PaymentSplitBillRequest({
|
||||
required this.orderId,
|
||||
required this.paymentMethodId,
|
||||
required this.customerId,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required this.items,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
Map<String, dynamic> data = {
|
||||
'order_id': orderId,
|
||||
'payment_method_id': paymentMethodId,
|
||||
'customer_id': customerId,
|
||||
'type': type,
|
||||
};
|
||||
|
||||
if (type == "AMOUNT") {
|
||||
data['amount'] = amount;
|
||||
}
|
||||
|
||||
if (type == "ITEM") {
|
||||
data['items'] = items.map((e) => e.toJson()).toList();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class SplitItem {
|
||||
final String orderItemId;
|
||||
final int quantity;
|
||||
|
||||
SplitItem({
|
||||
required this.orderItemId,
|
||||
required this.quantity,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'order_item_id': orderItemId,
|
||||
'quantity': quantity,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user