From 857c0ab4cd2253a0e1d53e3372a1ff1565cb4150 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 15 Dec 2019 19:04:14 +0100 Subject: introduce refund groups, react correctly to 410 Gone for /refund --- src/types/dbTypes.ts | 81 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 9 deletions(-) (limited to 'src/types') 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 @@ -1002,6 +1002,63 @@ export interface WireFee { sig: string; } +/** + * 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? @@ -1052,6 +1103,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 { + constructor() { + super("refundEvents", { keyPath: "refundGroupId" }); + } + } + class BankWithdrawUrisStore extends Store { 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 */ -- cgit v1.2.3