diff options
author | Sebastian <sebasjm@gmail.com> | 2023-07-03 12:40:35 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-07-03 12:40:35 -0300 |
commit | f47b5bd783def7481233f94275e333365d50b08b (patch) | |
tree | 26fda24f36c02cce2c2aed6a937ec315e1a47615 /packages | |
parent | 15a15942d2160e7742ccb415554c87057da7afc2 (diff) |
#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
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/src/backup-types.ts | 13 | ||||
-rw-r--r-- | packages/taler-util/src/errors.ts | 7 | ||||
-rw-r--r-- | packages/taler-util/src/taler-error-codes.ts | 24 | ||||
-rw-r--r-- | 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; } /** @@ -1269,6 +1275,11 @@ export enum BackupProposalStatus { */ Proposed = "proposed", /** + * Proposed, other wallet may also have + * the purchase + */ + Shared = "shared", + /** * The user has rejected the proposal. */ Refused = "refused", 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<number, TalerErrorDetail>; }; [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> = 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 @@ -777,6 +777,14 @@ export enum TalerErrorCode { /** + * 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). * (A value of 0 indicates that the error is generated client-side). @@ -1329,6 +1337,14 @@ export enum TalerErrorCode { /** + * 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). * (A value of 0 indicates that the error is generated client-side). @@ -3569,6 +3585,14 @@ export enum TalerErrorCode { /** + * 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). * (A value of 0 indicates that the error is generated client-side). 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<PreparePayRequest> => .property("talerPayUri", codecForString()) .build("PreparePay"); +export interface SharePaymentRequest { + merchantBaseUrl: string; + orderId: string; +} +export const codecForSharePaymentRequest = (): Codec<SharePaymentRequest> => + buildCodecForObject<SharePaymentRequest>() + .property("merchantBaseUrl", codecForString()) + .property("orderId", codecForString()) + .build("SharePaymentRequest"); + +export interface SharePaymentResult { + privatePayUri: string; +} +export const codecForSharePaymentResult = (): Codec<SharePaymentResult> => + buildCodecForObject<SharePaymentResult>() + .property("privatePayUri", codecForString()) + .build("SharePaymentResult"); + export interface PreparePayTemplateRequest { talerPayTemplateUri: string; templateParams: Record<string, string>; |