aboutsummaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-04-27 21:11:20 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-04-27 21:11:20 +0530
commit5be0708a10874be939e63ca82082cd665165823c (patch)
treed67531e204513905ffe90b7874baead3afe50305 /src/types
parente404f5e6d3001906c11b82a532db518720caebfd (diff)
downloadwallet-core-5be0708a10874be939e63ca82082cd665165823c.tar.xz
adopt new merchant refund API
Diffstat (limited to 'src/types')
-rw-r--r--src/types/dbTypes.ts58
-rw-r--r--src/types/pending.ts16
-rw-r--r--src/types/talerTypes.ts60
3 files changed, 42 insertions, 92 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index a9344c045..158d438cf 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -27,7 +27,7 @@ import { AmountJson } from "../util/amounts";
import {
Auditor,
CoinDepositPermission,
- MerchantRefundPermission,
+ MerchantRefundDetails,
PayReq,
TipResponse,
ExchangeSignKeyJson,
@@ -1091,7 +1091,7 @@ export interface RefundEventRecord {
export interface RefundInfo {
refundGroupId: string;
- perm: MerchantRefundPermission;
+ perm: MerchantRefundDetails;
}
export const enum RefundReason {
@@ -1102,7 +1102,7 @@ export const enum RefundReason {
/**
* Refund from an aborted payment.
*/
- AbortRefund = "abort-refund",
+ AbortRefund = "abort-pay-refund",
}
export interface RefundGroupInfo {
@@ -1110,28 +1110,6 @@ export interface RefundGroupInfo {
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 stored for every time we successfully submitted
* a payment to the merchant (both first time and re-play).
@@ -1230,9 +1208,25 @@ export interface PurchaseRecord {
timestampAccept: Timestamp;
/**
- * State of refunds for this proposal.
+ * Information regarding each group of refunds we receive at once.
+ */
+ refundGroups: RefundGroupInfo[];
+
+ /**
+ * Pending refunds for the purchase. A refund is pending
+ * when the merchant reports a transient error from the exchange.
+ */
+ refundsPending: { [refundKey: string]: RefundInfo };
+
+ /**
+ * Applied refunds for the purchase.
+ */
+ refundsDone: { [refundKey: string]: RefundInfo };
+
+ /**
+ * Refunds that permanently failed.
*/
- refundState: PurchaseRefundState;
+ refundsFailed: { [refundKey: string]: RefundInfo };
/**
* When was the last refund made?
@@ -1281,16 +1275,6 @@ export interface PurchaseRecord {
lastRefundStatusError: OperationError | undefined;
/**
- * Retry information for querying the refund status with the merchant.
- */
- refundApplyRetryInfo: RetryInfo;
-
- /**
- * Last error (or undefined) for querying the refund status with the merchant.
- */
- lastRefundApplyError: OperationError | undefined;
-
- /**
* Continue querying the refund status until this deadline has expired.
*/
autoRefundDeadline: Timestamp | undefined;
diff --git a/src/types/pending.ts b/src/types/pending.ts
index 4ff82f55e..f949b7c16 100644
--- a/src/types/pending.ts
+++ b/src/types/pending.ts
@@ -35,7 +35,6 @@ export const enum PendingOperationType {
Refresh = "refresh",
Reserve = "reserve",
Recoup = "recoup",
- RefundApply = "refund-apply",
RefundQuery = "refund-query",
TipChoice = "tip-choice",
TipPickup = "tip-pickup",
@@ -53,7 +52,6 @@ export type PendingOperationInfo = PendingOperationInfoCommon &
| PendingProposalChoiceOperation
| PendingProposalDownloadOperation
| PendingRefreshOperation
- | PendingRefundApplyOperation
| PendingRefundQueryOperation
| PendingReserveOperation
| PendingTipChoiceOperation
@@ -188,20 +186,6 @@ export interface PendingRefundQueryOperation {
lastError: OperationError | undefined;
}
-/**
- * The wallet is processing refunds that it received from a merchant.
- * During this operation, the wallet checks the refund permissions and sends
- * them to the exchange to obtain a refund on a coin.
- */
-export interface PendingRefundApplyOperation {
- type: PendingOperationType.RefundApply;
- proposalId: string;
- retryInfo: RetryInfo;
- lastError: OperationError | undefined;
- numRefundsPending: number;
- numRefundsDone: number;
-}
-
export interface PendingRecoupOperation {
type: PendingOperationType.Recoup;
recoupGroupId: string;
diff --git a/src/types/talerTypes.ts b/src/types/talerTypes.ts
index 799c84dc5..17d11eea8 100644
--- a/src/types/talerTypes.ts
+++ b/src/types/talerTypes.ts
@@ -411,7 +411,7 @@ export interface PayReq {
/**
* Refund permission in the format that the merchant gives it to us.
*/
-export class MerchantRefundPermission {
+export class MerchantRefundDetails {
/**
* Amount to be refunded.
*/
@@ -433,52 +433,30 @@ export class MerchantRefundPermission {
rtransaction_id: number;
/**
- * Signature made by the merchant over the refund permission.
+ * Exchange's key used for the signature.
*/
- merchant_sig: string;
-}
-
-/**
- * Refund request sent to the exchange.
- */
-export interface RefundRequest {
- /**
- * Amount to be refunded, can be a fraction of the
- * coin's total deposit value (including deposit fee);
- * must be larger than the refund fee.
- */
- refund_amount: string;
-
- /**
- * Refund fee associated with the given coin.
- * must be smaller than the refund amount.
- */
- refund_fee: string;
+ exchange_pub?: string;
/**
- * SHA-512 hash of the contact of the merchant with the customer.
+ * Exchange's signature to confirm the refund.
*/
- h_contract_terms: string;
+ exchange_sig?: string;
/**
- * coin's public key, both ECDHE and EdDSA.
+ * Error replay from the exchange (if any).
*/
- coin_pub: string;
+ exchange_reply?: any;
/**
- * 64-bit transaction id of the refund transaction between merchant and customer
+ * Error code from the exchange (if any).
*/
- rtransaction_id: number;
-
- /**
- * EdDSA public key of the merchant.
- */
- merchant_pub: string;
+ exchange_code?: number;
/**
- * EdDSA signature of the merchant affirming the refund.
+ * HTTP status code of the exchange's response
+ * to the merchant's refund request.
*/
- merchant_sig: string;
+ exchange_http_status: number;
}
/**
@@ -499,7 +477,7 @@ export class MerchantRefundResponse {
/**
* The signed refund permissions, to be sent to the exchange.
*/
- refund_permissions: MerchantRefundPermission[];
+ refunds: MerchantRefundDetails[];
}
/**
@@ -854,14 +832,18 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.build("ContractTerms");
export const codecForMerchantRefundPermission = (): Codec<
- MerchantRefundPermission
+ MerchantRefundDetails
> =>
- makeCodecForObject<MerchantRefundPermission>()
+ makeCodecForObject<MerchantRefundDetails>()
.property("refund_amount", codecForString)
.property("refund_fee", codecForString)
.property("coin_pub", codecForString)
.property("rtransaction_id", codecForNumber)
- .property("merchant_sig", codecForString)
+ .property("exchange_http_status", codecForNumber)
+ .property("exchange_code", makeCodecOptional(codecForNumber))
+ .property("exchange_reply", makeCodecOptional(codecForAny))
+ .property("exchange_sig", makeCodecOptional(codecForString))
+ .property("exchange_pub", makeCodecOptional(codecForString))
.build("MerchantRefundPermission");
export const codecForMerchantRefundResponse = (): Codec<
@@ -871,7 +853,7 @@ export const codecForMerchantRefundResponse = (): Codec<
.property("merchant_pub", codecForString)
.property("h_contract_terms", codecForString)
.property(
- "refund_permissions",
+ "refunds",
makeCodecForList(codecForMerchantRefundPermission()),
)
.build("MerchantRefundResponse");