aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-05-23 19:50:59 +0200
committerFlorian Dold <florian@dold.me>2024-05-23 19:50:59 +0200
commitcdcedf65595393fc186eb2012d3ae6cd55540f59 (patch)
tree88c4eecce4673c1c2b7b3b6eaadfb4b7f8df0ce8 /packages/taler-util/src
parent527716758f154eb863acb0052f004dd23313f765 (diff)
downloadwallet-core-cdcedf65595393fc186eb2012d3ae6cd55540f59.tar.xz
wallet-core: support bank-integrated withdrawal with amount selection by wallet
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/bank-api-client.ts2
-rw-r--r--packages/taler-util/src/http-client/types.ts4
-rw-r--r--packages/taler-util/src/taler-types.ts4
-rw-r--r--packages/taler-util/src/wallet-types.ts31
4 files changed, 26 insertions, 15 deletions
diff --git a/packages/taler-util/src/bank-api-client.ts b/packages/taler-util/src/bank-api-client.ts
index e9f442af6..e1409087f 100644
--- a/packages/taler-util/src/bank-api-client.ts
+++ b/packages/taler-util/src/bank-api-client.ts
@@ -385,7 +385,7 @@ export class TalerCorebankApiClient {
async createWithdrawalOperation(
user: string,
- amount: string,
+ amount: string | undefined,
): Promise<WithdrawalOperationInfo> {
const url = new URL(`accounts/${user}/withdrawals`, this.baseUrl);
const resp = await this.httpLib.fetch(url.href, {
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index edddf7d94..9268f6387 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -1311,7 +1311,7 @@ export const codecForBankWithdrawalOperationStatus =
codecForConstString("confirmed"),
),
)
- .property("amount", codecForAmountString())
+ .property("amount", codecOptional(codecForAmountString()))
.property("sender_wire", codecOptional(codecForPaytoString()))
.property("suggested_exchange", codecOptional(codecForString()))
.property("confirm_transfer_url", codecOptional(codecForURL()))
@@ -2030,7 +2030,7 @@ export namespace TalerBankIntegrationApi {
// Amount that will be withdrawn with this operation
// (raw amount without fee considerations).
- amount: AmountString;
+ amount: AmountString | undefined;
// Bank account of the customer that is withdrawing, as a
// payto URI.
diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts
index e2536b74a..66f98ea9a 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -978,7 +978,7 @@ export class WithdrawOperationStatusResponse {
aborted: boolean;
- amount: string;
+ amount: string | undefined;
sender_wire?: string;
@@ -1557,7 +1557,7 @@ export const codecForWithdrawOperationStatusResponse =
.property("selection_done", codecForBoolean())
.property("transfer_done", codecForBoolean())
.property("aborted", codecForBoolean())
- .property("amount", codecForString())
+ .property("amount", codecOptional(codecForString()))
.property("sender_wire", codecOptional(codecForString()))
.property("suggested_exchange", codecOptional(codecForString()))
.property("confirm_transfer_url", codecOptional(codecForString()))
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index d472af187..9301a9723 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -663,11 +663,11 @@ export interface CoinDumpJson {
withdrawal_reserve_pub: string | undefined;
coin_status: CoinStatus;
spend_allocation:
- | {
- id: string;
- amount: AmountString;
- }
- | undefined;
+ | {
+ id: string;
+ amount: AmountString;
+ }
+ | undefined;
/**
* Information about the age restriction
*/
@@ -801,7 +801,7 @@ export const codecForPreparePayResultPaymentPossible =
)
.build("PreparePayResultPaymentPossible");
-export interface BalanceDetails { }
+export interface BalanceDetails {}
/**
* Detailed reason for why the wallet's balance is insufficient.
@@ -984,7 +984,8 @@ export interface PreparePayResultAlreadyConfirmed {
export interface BankWithdrawDetails {
status: WithdrawalOperationStatus;
- amount: AmountJson;
+ currency: string;
+ amount: AmountJson | undefined;
senderWire?: string;
suggestedExchange?: string;
confirmTransferUrl?: string;
@@ -1883,6 +1884,13 @@ export interface AcceptBankIntegratedWithdrawalRequest {
talerWithdrawUri: string;
exchangeBaseUrl: string;
forcedDenomSel?: ForcedDenomSel;
+ /**
+ * Amount to withdraw.
+ * If the bank's withdrawal operation uses a fixed amount,
+ * this field must either be left undefined or its value must match
+ * the amount from the withdrawal operation.
+ */
+ amount?: AmountString;
restrictAge?: number;
}
@@ -1892,6 +1900,7 @@ export const codecForAcceptBankIntegratedWithdrawalRequest =
.property("exchangeBaseUrl", codecForCanonBaseUrl())
.property("talerWithdrawUri", codecForString())
.property("forcedDenomSel", codecForAny())
+ .property("amount", codecOptional(codecForAmountString()))
.property("restrictAge", codecOptional(codecForNumber()))
.build("AcceptBankIntegratedWithdrawalRequest");
@@ -2047,7 +2056,7 @@ export interface CheckPayTemplateRequest {
export type CheckPayTemplateReponse = {
templateDetails: TalerMerchantApi.WalletTemplateDetails;
supportedCurrencies: string[];
-}
+};
export const codecForCheckPayTemplateRequest =
(): Codec<CheckPayTemplateRequest> =>
@@ -2352,7 +2361,8 @@ export interface WithdrawUriInfoResponse {
operationId: string;
status: WithdrawalOperationStatus;
confirmTransferUrl?: string;
- amount: AmountString;
+ currency: string;
+ amount: AmountString | undefined;
defaultExchangeBaseUrl?: string;
possibleExchanges: ExchangeListItem[];
}
@@ -2371,7 +2381,8 @@ export const codecForWithdrawUriInfoResponse =
codecForConstString("confirmed"),
),
)
- .property("amount", codecForAmountString())
+ .property("amount", codecOptional(codecForAmountString()))
+ .property("currency", codecForString())
.property("defaultExchangeBaseUrl", codecOptional(codecForCanonBaseUrl()))
.property("possibleExchanges", codecForList(codecForExchangeListItem()))
.build("WithdrawUriInfoResponse");