summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-02-07 18:41:28 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-02-07 18:41:28 +0800
commit47986845bac62f7558579fa7e7c688e37f8f9865 (patch)
tree05e85e431ddbdc9cce7f7cffbaa75cdef671794a
parentabea689a5be4955dac8ab28e5df1522c1bfe0bcb (diff)
Transaction structure
and its free-er, so the order free-er has to be renamed, and completed too.
-rw-r--r--interchange/ord.h10
-rw-r--r--ord.c17
2 files changed, 23 insertions, 4 deletions
diff --git a/interchange/ord.h b/interchange/ord.h
index d605ca7..fda873a 100644
--- a/interchange/ord.h
+++ b/interchange/ord.h
@@ -17,6 +17,11 @@ struct interchange_ord_order {
struct interchange_ord_item *items[];
};
+struct interchange_ord_transaction {
+ char *order_number;
+ char *payment_method;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -41,7 +46,10 @@ void interchange_ord_checkout(const struct interchange_ord_order *order,
const struct interchange_member *member,
void (*handler)(interchange_response *));
-void interchange_ord_free(struct interchange_ord_order *order);
+void interchange_ord_free_order(struct interchange_ord_order *order);
+
+void interchange_ord_free_transaction(struct interchange_ord_transaction
+ *transaction);
#ifdef __cplusplus
}
diff --git a/ord.c b/ord.c
index 615aedb..83b8012 100644
--- a/ord.c
+++ b/ord.c
@@ -83,10 +83,21 @@ void interchange_ord_checkout(const struct interchange_ord_order *order,
}}, "%s", "ord/checkout");
}
-void interchange_ord_free(struct interchange_ord_order *order)
+void interchange_ord_free_order(struct interchange_ord_order *order)
{
- if (order->profile)
- free(order->profile);
for (size_t i = 0; i < order->nitems; i++)
interchange_free_product(order->items[i]->product);
+ if (order->profile)
+ free(order->profile);
+ free(order);
+}
+
+void interchange_ord_free_transaction(struct interchange_ord_transaction
+ *transaction)
+{
+ if (transaction->order_number)
+ free(transaction->order_number);
+ if (transaction->payment_method)
+ free(transaction->payment_method);
+ free(transaction);
}