From 92f1b5928c764b3af12a29b97bbc3e434a82b1b0 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 5 Jan 2023 18:45:49 +0100 Subject: wallet-core: implement insufficient balance details For now, only for merchant payments --- packages/taler-util/src/wallet-types.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'packages/taler-util') diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index d7685fa6e..6b3e39794 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -419,6 +419,7 @@ export const codecForPreparePayResultInsufficientBalance = "status", codecForConstString(PreparePayResultType.InsufficientBalance), ) + .property("balanceDetails", codecForPayMerchantInsufficientBalanceDetails()) .build("PreparePayResultInsufficientBalance"); export const codecForPreparePayResultAlreadyConfirmed = @@ -483,6 +484,7 @@ export interface PreparePayResultInsufficientBalance { amountRaw: string; noncePriv: string; talerUri: string; + balanceDetails: PayMerchantInsufficientBalanceDetails; } export interface PreparePayResultAlreadyConfirmed { @@ -2090,32 +2092,32 @@ export interface PayMerchantInsufficientBalanceDetails { /** * Amount requested by the merchant. */ - amountRequested: AmountJson; + amountRequested: AmountString; /** * Balance of type "available" (see balance.ts for definition). */ - balanceAvailable: AmountJson; + balanceAvailable: AmountString; /** * Balance of type "material" (see balance.ts for definition). */ - balanceMaterial: AmountJson; + balanceMaterial: AmountString; /** * Balance of type "age-acceptable" (see balance.ts for definition). */ - balanceAgeAcceptable: AmountJson; + balanceAgeAcceptable: AmountString; /** * Balance of type "merchant-acceptable" (see balance.ts for definition). */ - balanceMechantAcceptable: AmountJson; + balanceMerchantAcceptable: AmountString; /** * Balance of type "merchant-depositable" (see balance.ts for definition). */ - balanceMechantDepositable: AmountJson; + balanceMerchantDepositable: AmountString; /** * If the payment would succeed without fees @@ -2126,5 +2128,17 @@ export interface PayMerchantInsufficientBalanceDetails { * It is not possible to give an exact value here, since it depends * on the coin selection for the amount that would be additionally withdrawn. */ - feeGapEstimate: AmountJson; -} \ No newline at end of file + feeGapEstimate: AmountString; +} + +const codecForPayMerchantInsufficientBalanceDetails = +(): Codec => + buildCodecForObject() + .property("amountRequested", codecForAmountString()) + .property("balanceAgeAcceptable", codecForAmountString()) + .property("balanceAvailable", codecForAmountString()) + .property("balanceMaterial", codecForAmountString()) + .property("balanceMerchantAcceptable", codecForAmountString()) + .property("balanceMerchantDepositable", codecForAmountString()) + .property("feeGapEstimate", codecForAmountString()) + .build("PayMerchantInsufficientBalanceDetails"); \ No newline at end of file -- cgit v1.2.3