From f47b5bd783def7481233f94275e333365d50b08b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 3 Jul 2023 12:40:35 -0300 Subject: #7741 share payment add shared flag in db new state purchase dialogShared new error WALLET_ORDER_ALREADY_PAID removing nonce from normal operation new operation: sharePayment which returns payUri with nonce --- packages/taler-util/src/backup-types.ts | 13 ++++++++++++- packages/taler-util/src/errors.ts | 7 +++++-- packages/taler-util/src/taler-error-codes.ts | 24 ++++++++++++++++++++++++ packages/taler-util/src/wallet-types.ts | 26 ++++++++++++++++++++------ 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts index 2bfe6b886..2920838dd 100644 --- a/packages/taler-util/src/backup-types.ts +++ b/packages/taler-util/src/backup-types.ts @@ -63,7 +63,11 @@ * Imports. */ import { DenominationPubKey, UnblindedSignature } from "./taler-types.js"; -import { TalerProtocolDuration, TalerProtocolTimestamp, TalerPreciseTimestamp } from "./time.js"; +import { + TalerProtocolDuration, + TalerProtocolTimestamp, + TalerPreciseTimestamp, +} from "./time.js"; export const BACKUP_TAG = "gnu-taler-wallet-backup-content" as const; /** @@ -970,6 +974,8 @@ export interface BackupPurchase { * Continue querying the refund status until this deadline has expired. */ auto_refund_deadline: TalerProtocolTimestamp | undefined; + + shared: boolean; } /** @@ -1268,6 +1274,11 @@ export enum BackupProposalStatus { * but the user needs to accept/reject it. */ Proposed = "proposed", + /** + * Proposed, other wallet may also have + * the purchase + */ + Shared = "shared", /** * The user has rejected the proposal. */ diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts index 8476b63fc..06e338a25 100644 --- a/packages/taler-util/src/errors.ts +++ b/packages/taler-util/src/errors.ts @@ -52,6 +52,9 @@ export interface DetailsMap { orderId: string; claimUrl: string; }; + [TalerErrorCode.WALLET_ORDER_ALREADY_PAID]: { + orderId: string; + }; [TalerErrorCode.WALLET_CONTRACT_TERMS_MALFORMED]: empty; [TalerErrorCode.WALLET_CONTRACT_TERMS_SIGNATURE_INVALID]: { merchantPub: string; @@ -98,7 +101,7 @@ export interface DetailsMap { }; [TalerErrorCode.WALLET_EXCHANGE_COIN_SIGNATURE_INVALID]: empty; [TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE]: { - numErrors: number, + numErrors: number; errorsPerCoin: Record; }; [TalerErrorCode.WALLET_CORE_NOT_AVAILABLE]: empty; @@ -133,7 +136,7 @@ export interface DetailsMap { [TalerErrorCode.WALLET_EXCHANGE_BASE_URL_MISMATCH]: { urlWallet: string; urlExchange: string; - } + }; } type ErrBody = Y extends keyof DetailsMap ? DetailsMap[Y] : empty; diff --git a/packages/taler-util/src/taler-error-codes.ts b/packages/taler-util/src/taler-error-codes.ts index 019129c20..fa1f4a86a 100644 --- a/packages/taler-util/src/taler-error-codes.ts +++ b/packages/taler-util/src/taler-error-codes.ts @@ -776,6 +776,14 @@ export enum TalerErrorCode { EXCHANGE_AGE_WITHDRAW_REVEAL_INVALID_HASH = 1164, + /** + * The maximum age in the commitment is too large for the reserve + * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_AGE_WITHDRAW_MAXIMUM_AGE_TOO_LARGE = 1165, + + /** * The batch withdraw included a planchet that was already withdrawn. This is not allowed. * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). @@ -1328,6 +1336,14 @@ export enum TalerErrorCode { EXCHANGE_PURSE_DELETE_SIGNATURE_INVALID = 1680, + /** + * Withdrawal from the reserve requires age restriction to be set. + * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED = 1681, + + /** * The exchange failed to talk to the process responsible for its private denomination keys or the helpers had no denominations (properly) configured. * Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502). @@ -3568,6 +3584,14 @@ export enum TalerErrorCode { WALLET_EXCHANGE_BASE_URL_MISMATCH = 7030, + /** + * The order has already been paid by another wallet. + * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). + * (A value of 0 indicates that the error is generated client-side). + */ + WALLET_ORDER_ALREADY_PAID = 7031, + + /** * We encountered a timeout with our payment backend. * Returned with an HTTP status code of #MHD_HTTP_GATEWAY_TIMEOUT (504). diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 66b5e7262..7926cdd4f 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -684,7 +684,6 @@ export const codecForPreparePayResultPaymentPossible = .property("proposalId", codecForString()) .property("contractTermsHash", codecForString()) .property("talerUri", codecForString()) - .property("noncePriv", codecForString()) .property( "status", codecForConstString(PreparePayResultType.PaymentPossible), @@ -757,7 +756,6 @@ export const codecForPreparePayResultInsufficientBalance = .property("talerUri", codecForString()) .property("proposalId", codecForString()) .property("transactionId", codecForTransactionIdStr()) - .property("noncePriv", codecForString()) .property( "status", codecForConstString(PreparePayResultType.InsufficientBalance), @@ -775,7 +773,7 @@ export const codecForPreparePayResultAlreadyConfirmed = "status", codecForConstString(PreparePayResultType.AlreadyConfirmed), ) - .property("amountEffective", codecForAmountString()) + .property("amountEffective", codecOptional(codecForAmountString())) .property("amountRaw", codecForAmountString()) .property("paid", codecForBoolean()) .property("talerUri", codecOptional(codecForString())) @@ -824,7 +822,6 @@ export interface PreparePayResultPaymentPossible { contractTermsHash: string; amountRaw: string; amountEffective: string; - noncePriv: string; talerUri: string; } @@ -834,7 +831,6 @@ export interface PreparePayResultInsufficientBalance { proposalId: string; contractTerms: MerchantContractTerms; amountRaw: string; - noncePriv: string; talerUri: string; balanceDetails: PayMerchantInsufficientBalanceDetails; } @@ -845,7 +841,7 @@ export interface PreparePayResultAlreadyConfirmed { contractTerms: MerchantContractTerms; paid: boolean; amountRaw: string; - amountEffective: string; + amountEffective: string | undefined; contractTermsHash: string; proposalId: string; talerUri?: string; @@ -1724,6 +1720,24 @@ export const codecForPreparePayRequest = (): Codec => .property("talerPayUri", codecForString()) .build("PreparePay"); +export interface SharePaymentRequest { + merchantBaseUrl: string; + orderId: string; +} +export const codecForSharePaymentRequest = (): Codec => + buildCodecForObject() + .property("merchantBaseUrl", codecForString()) + .property("orderId", codecForString()) + .build("SharePaymentRequest"); + +export interface SharePaymentResult { + privatePayUri: string; +} +export const codecForSharePaymentResult = (): Codec => + buildCodecForObject() + .property("privatePayUri", codecForString()) + .build("SharePaymentResult"); + export interface PreparePayTemplateRequest { talerPayTemplateUri: string; templateParams: Record; -- cgit v1.2.3