aboutsummaryrefslogtreecommitdiff
path: root/src/types/dbTypes.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-15 19:04:14 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-15 19:04:14 +0100
commit857c0ab4cd2253a0e1d53e3372a1ff1565cb4150 (patch)
tree1284cef3d992ce767baee0a4788214b7f474a3ba /src/types/dbTypes.ts
parent7cc3b10824683c601a9051ef98e7c1478a801db8 (diff)
downloadwallet-core-857c0ab4cd2253a0e1d53e3372a1ff1565cb4150.tar.xz
introduce refund groups, react correctly to 410 Gone for /refund
Diffstat (limited to 'src/types/dbTypes.ts')
-rw-r--r--src/types/dbTypes.ts81
1 files changed, 72 insertions, 9 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index c05aa68d7..9d2f6fe5d 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -1003,6 +1003,63 @@ export interface WireFee {
}
/**
+ * Record to store information about a refund event.
+ *
+ * All information about a refund is stored with the purchase,
+ * this event is just for the history.
+ *
+ * The event is only present for completed refunds.
+ */
+export interface RefundEventRecord {
+ timestamp: Timestamp;
+ refundGroupId: string;
+ proposalId: string;
+}
+
+export interface RefundInfo {
+ refundGroupId: string;
+ perm: MerchantRefundPermission;
+}
+
+export const enum RefundReason {
+ /**
+ * Normal refund given by the merchant.
+ */
+ NormalRefund = "normal-refund",
+ /**
+ * Refund from an aborted payment.
+ */
+ AbortRefund = "abort-refund",
+}
+
+export interface RefundGroupInfo {
+ timestampQueried: Timestamp;
+ reason: RefundReason;
+}
+
+export interface PurchaseRefundState {
+ /**
+ * Information regarding each group of refunds we receive at once.
+ */
+ refundGroups: RefundGroupInfo[];
+
+ /**
+ * Pending refunds for the purchase.
+ */
+ refundsPending: { [refundSig: string]: RefundInfo };
+
+ /**
+ * Applied refunds for the purchase.
+ */
+ refundsDone: { [refundSig: string]: RefundInfo };
+
+ /**
+ * Submitted refunds for the purchase.
+ */
+ refundsFailed: { [refundSig: string]: RefundInfo };
+}
+
+/**
* Record that stores status information about one purchase, starting from when
* the customer accepts a proposal. Includes refund status if applicable.
*/
@@ -1034,17 +1091,11 @@ export interface PurchaseRecord {
*/
merchantSig: string;
- firstSuccessfulPayTimestamp: Timestamp | undefined;
-
/**
- * Pending refunds for the purchase.
+ * Timestamp of the first time that sending a payment to the merchant
+ * for this purchase was successful.
*/
- refundsPending: { [refundSig: string]: MerchantRefundPermission };
-
- /**
- * Submitted refunds for the purchase.
- */
- refundsDone: { [refundSig: string]: MerchantRefundPermission };
+ firstSuccessfulPayTimestamp: Timestamp | undefined;
/**
* When was the purchase made?
@@ -1053,6 +1104,11 @@ export interface PurchaseRecord {
acceptTimestamp: Timestamp;
/**
+ * State of refunds for this proposal.
+ */
+ refundState: PurchaseRefundState;
+
+ /**
* When was the last refund made?
* Set to 0 if no refund was made on the purchase.
*/
@@ -1370,6 +1426,12 @@ export namespace Stores {
}
}
+ class RefundEventsStore extends Store<RefundEventRecord> {
+ constructor() {
+ super("refundEvents", { keyPath: "refundGroupId" });
+ }
+ }
+
class BankWithdrawUrisStore extends Store<BankWithdrawUriRecord> {
constructor() {
super("bankWithdrawUris", { keyPath: "talerWithdrawUri" });
@@ -1394,6 +1456,7 @@ export namespace Stores {
export const senderWires = new SenderWiresStore();
export const withdrawalSession = new WithdrawalSessionsStore();
export const bankWithdrawUris = new BankWithdrawUrisStore();
+ export const refundEvents = new RefundEventsStore();
}
/* tslint:enable:completed-docs */