feat: create payment
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class PaymentRequestModel {
|
||||
final String? orderId;
|
||||
final String? paymentMethodId;
|
||||
final int? amount;
|
||||
final String? transactionId;
|
||||
final int? splitNumber;
|
||||
final int? splitTotal;
|
||||
final String? splitDescription;
|
||||
final List<PaymentOrderItemModel>? paymentOrderItems;
|
||||
|
||||
PaymentRequestModel({
|
||||
this.orderId,
|
||||
this.paymentMethodId,
|
||||
this.amount,
|
||||
this.transactionId,
|
||||
this.splitNumber,
|
||||
this.splitTotal,
|
||||
this.splitDescription,
|
||||
this.paymentOrderItems,
|
||||
});
|
||||
|
||||
factory PaymentRequestModel.fromJson(String str) =>
|
||||
PaymentRequestModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory PaymentRequestModel.fromMap(Map<String, dynamic> json) =>
|
||||
PaymentRequestModel(
|
||||
orderId: json["order_id"],
|
||||
paymentMethodId: json["payment_method_id"],
|
||||
amount: json["amount"]?.toDouble(),
|
||||
transactionId: json["transaction_id"],
|
||||
splitNumber: json["split_number"],
|
||||
splitTotal: json["split_total"],
|
||||
splitDescription: json["split_description"],
|
||||
paymentOrderItems: json["payment_order_items"] == null
|
||||
? []
|
||||
: List<PaymentOrderItemModel>.from(json["payment_order_items"]
|
||||
.map((x) => PaymentOrderItemModel.fromMap(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"order_id": orderId,
|
||||
"payment_method_id": paymentMethodId,
|
||||
"amount": amount,
|
||||
"transaction_id": transactionId,
|
||||
"split_number": splitNumber,
|
||||
"split_total": splitTotal,
|
||||
"split_description": splitDescription,
|
||||
"payment_order_items": paymentOrderItems == null
|
||||
? []
|
||||
: List<dynamic>.from(paymentOrderItems!.map((x) => x.toMap())),
|
||||
};
|
||||
}
|
||||
|
||||
class PaymentOrderItemModel {
|
||||
final String? orderItemId;
|
||||
final int? amount;
|
||||
|
||||
PaymentOrderItemModel({
|
||||
this.orderItemId,
|
||||
this.amount,
|
||||
});
|
||||
|
||||
factory PaymentOrderItemModel.fromJson(String str) =>
|
||||
PaymentOrderItemModel.fromMap(json.decode(str));
|
||||
|
||||
factory PaymentOrderItemModel.fromMap(Map<String, dynamic> json) =>
|
||||
PaymentOrderItemModel(
|
||||
orderItemId: json["order_item_id"],
|
||||
amount: json["amount"]?.toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"order_item_id": orderItemId,
|
||||
"amount": amount,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class PaymentSuccessResponseModel {
|
||||
final bool? success;
|
||||
final PaymentData? data;
|
||||
final dynamic errors;
|
||||
|
||||
PaymentSuccessResponseModel({
|
||||
this.success,
|
||||
this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
factory PaymentSuccessResponseModel.fromJson(String str) =>
|
||||
PaymentSuccessResponseModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory PaymentSuccessResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
PaymentSuccessResponseModel(
|
||||
success: json["success"],
|
||||
data: json["data"] == null ? null : PaymentData.fromMap(json["data"]),
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"success": success,
|
||||
"data": data?.toMap(),
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
|
||||
class PaymentData {
|
||||
final String? id;
|
||||
final String? orderId;
|
||||
final String? paymentMethodId;
|
||||
final int? amount;
|
||||
final String? status;
|
||||
final String? transactionId;
|
||||
final int? splitNumber;
|
||||
final int? splitTotal;
|
||||
final String? splitDescription;
|
||||
final int? refundAmount;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
PaymentData({
|
||||
this.id,
|
||||
this.orderId,
|
||||
this.paymentMethodId,
|
||||
this.amount,
|
||||
this.status,
|
||||
this.transactionId,
|
||||
this.splitNumber,
|
||||
this.splitTotal,
|
||||
this.splitDescription,
|
||||
this.refundAmount,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory PaymentData.fromMap(Map<String, dynamic> json) => PaymentData(
|
||||
id: json["id"],
|
||||
orderId: json["order_id"],
|
||||
paymentMethodId: json["payment_method_id"],
|
||||
amount: json["amount"],
|
||||
status: json["status"],
|
||||
transactionId: json["transaction_id"],
|
||||
splitNumber: json["split_number"],
|
||||
splitTotal: json["split_total"],
|
||||
splitDescription: json["split_description"],
|
||||
refundAmount: json["refund_amount"],
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"order_id": orderId,
|
||||
"payment_method_id": paymentMethodId,
|
||||
"amount": amount,
|
||||
"status": status,
|
||||
"transaction_id": transactionId,
|
||||
"split_number": splitNumber,
|
||||
"split_total": splitTotal,
|
||||
"split_description": splitDescription,
|
||||
"refund_amount": refundAmount,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user