[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/04: fix #8781: min cashout api
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/04: fix #8781: min cashout api |
Date: |
Tue, 07 May 2024 17:14:33 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit c224e1998fa565f3d4440ec41dd3bbc76168ba80
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Tue May 7 10:41:04 2024 -0300
fix #8781: min cashout api
---
packages/taler-util/src/http-client/bank-core.ts | 11 ++-
packages/taler-util/src/http-client/types.ts | 69 ++++++++++++++-
packages/taler-util/src/taler-error-codes.ts | 104 +++++++++++++++++++++++
3 files changed, 178 insertions(+), 6 deletions(-)
diff --git a/packages/taler-util/src/http-client/bank-core.ts
b/packages/taler-util/src/http-client/bank-core.ts
index 97c1727ff..50a5cbc5b 100644
--- a/packages/taler-util/src/http-client/bank-core.ts
+++ b/packages/taler-util/src/http-client/bank-core.ts
@@ -27,7 +27,7 @@ import {
codecForTanTransmission,
opKnownAlternativeFailure,
opKnownHttpFailure,
- opKnownTalerFailure
+ opKnownTalerFailure,
} from "@gnu-taler/taler-util";
import {
HttpRequestLibrary,
@@ -184,6 +184,8 @@ export class TalerCoreBankHttpClient {
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_NON_ADMIN_PATCH_DEBT_LIMIT:
return opKnownTalerFailure(details.code, details);
+ case TalerErrorCode.BANK_NON_ADMIN_SET_MIN_CASHOUT:
+ return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_NON_ADMIN_SET_TAN_CHANNEL:
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_TAN_CHANNEL_NOT_SUPPORTED:
@@ -280,6 +282,8 @@ export class TalerCoreBankHttpClient {
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_NON_ADMIN_PATCH_DEBT_LIMIT:
return opKnownTalerFailure(details.code, details);
+ case TalerErrorCode.BANK_NON_ADMIN_SET_MIN_CASHOUT:
+ return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_TAN_CHANNEL_NOT_SUPPORTED:
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_MISSING_TAN_INFO:
@@ -507,13 +511,14 @@ export class TalerCoreBankHttpClient {
| OperationFail<HttpStatusCode.Unauthorized>
| OperationFail<TalerErrorCode.BANK_UNALLOWED_DEBIT>
| OperationFail<TalerErrorCode.BANK_ADMIN_CREDITOR>
+ | OperationFail<TalerErrorCode.BANK_CONVERSION_AMOUNT_TO_SMALL>
| OperationFail<TalerErrorCode.BANK_SAME_ACCOUNT>
| OperationFail<TalerErrorCode.BANK_UNKNOWN_CREDITOR>
| OperationFail<TalerErrorCode.BANK_TRANSFER_REQUEST_UID_REUSED>
> {
const url = new URL(`accounts/${auth.username}/transactions`,
this.baseUrl);
if (idempotencyCheck) {
- body.request_uid = idempotencyCheck.uid
+ body.request_uid = idempotencyCheck.uid;
}
const resp = await this.httpLib.fetch(url.href, {
method: "POST",
@@ -547,6 +552,8 @@ export class TalerCoreBankHttpClient {
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_UNKNOWN_CREDITOR:
return opKnownTalerFailure(details.code, details);
+ case TalerErrorCode.BANK_CONVERSION_AMOUNT_TO_SMALL:
+ return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_UNALLOWED_DEBIT:
return opKnownTalerFailure(details.code, details);
case TalerErrorCode.BANK_TRANSFER_REQUEST_UID_REUSED:
diff --git a/packages/taler-util/src/http-client/types.ts
b/packages/taler-util/src/http-client/types.ts
index 614a386e1..3b1fff9f1 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -193,7 +193,6 @@ export type AccessToken = string & {
[__ac_token]: true;
};
-
/**
* Create a rfc8959 access token.
* Adds secret-token: prefix if there is none.
@@ -204,7 +203,9 @@ export type AccessToken = string & {
*/
export function createRFC8959AccessTokenEncoded(token: string): AccessToken {
return (
- token.startsWith("secret-token:") ? token :
`secret-token:${encodeURIComponent(token)}`
+ token.startsWith("secret-token:")
+ ? token
+ : `secret-token:${encodeURIComponent(token)}`
) as AccessToken;
}
@@ -339,6 +340,7 @@ export const codecForCoreBankConfig = ():
Codec<TalerCorebankApi.Config> =>
.property("name", codecForConstString("libeufin-bank"))
.property("version", codecForString())
.property("bank_name", codecForString())
+ .property("base_url", codecForString())
.property("allow_conversion", codecForBoolean())
.property("allow_registrations", codecForBoolean())
.property("allow_deletions", codecForBoolean())
@@ -1037,9 +1039,18 @@ export const codecForAccountMinimalData =
.property("payto_uri", codecForPaytoString())
.property("balance", codecForBalance())
.property("debit_threshold", codecForAmountString())
+ .property("min_cashout", codecOptional(codecForAmountString()))
.property("is_public", codecForBoolean())
.property("is_taler_exchange", codecForBoolean())
- .property("row_id", codecOptional(codecForNumber()))
+ .property(
+ "status",
+ codecOptional(
+ codecForEither(
+ codecForConstString("active"),
+ codecForConstString("deleted"),
+ ),
+ ),
+ )
.build("TalerCorebankApi.AccountMinimalData");
export const codecForListBankAccountsResponse =
@@ -1054,6 +1065,7 @@ export const codecForAccountData = ():
Codec<TalerCorebankApi.AccountData> =>
.property("balance", codecForBalance())
.property("payto_uri", codecForPaytoString())
.property("debit_threshold", codecForAmountString())
+ .property("min_cashout", codecOptional(codecForAmountString()))
.property("contact_data", codecOptional(codecForChallengeContactData()))
.property("cashout_payto_uri", codecOptional(codecForPaytoString()))
.property("is_public", codecForBoolean())
@@ -1067,6 +1079,15 @@ export const codecForAccountData = ():
Codec<TalerCorebankApi.AccountData> =>
),
),
)
+ .property(
+ "status",
+ codecOptional(
+ codecForEither(
+ codecForConstString("active"),
+ codecForConstString("deleted"),
+ ),
+ ),
+ )
.build("TalerCorebankApi.AccountData");
export const codecForChallengeContactData =
@@ -2042,6 +2063,11 @@ export namespace TalerCorebankApi {
// @since v4, will become mandatory in the next version.
bank_name: string;
+ // Advertised base URL to use when you sharing an URL with another
+ // program.
+ // @since v4.
+ base_url?: string;
+
// If 'true' the server provides local currency conversion support
// If 'false' some parts of the API are not supported and return 501
allow_conversion: boolean;
@@ -2200,6 +2226,11 @@ export namespace TalerCorebankApi {
// Only admin can set this property.
debit_threshold?: AmountString;
+ // If present, set a custom minimum cashout amount for this account.
+ // Only admin can set this property
+ // @since v4
+ min_cashout?: AmountString;
+
// If present, enables 2FA and set the TAN channel used for challenges
// Only admin can set this property, other user can reconfig their account
// after creation.
@@ -2241,7 +2272,11 @@ export namespace TalerCorebankApi {
// Only admin can change this property.
debit_threshold?: AmountString;
- //FIX: missing in SPEC
+ // If present, change the custom minimum cashout amount for this account.
+ // Only admin can set this property
+ // @since v4
+ min_cashout?: AmountString;
+
// If present, enables 2FA and set the TAN channel used for challenges
tan_channel?: TanChannel | null;
}
@@ -2298,6 +2333,11 @@ export namespace TalerCorebankApi {
// Number indicating the max debit allowed for the requesting user.
debit_threshold: AmountString;
+ // Custom minimum cashout amount for this account.
+ // If null or absent, the global conversion fee is used.
+ // @since v4
+ min_cashout?: AmountString;
+
// Is this account visible to anyone?
is_public: boolean;
@@ -2307,6 +2347,14 @@ export namespace TalerCorebankApi {
// Opaque unique ID used for pagination.
// @since v4, will become mandatory in the future.
row_id?: Integer;
+
+ // Current status of the account
+ // active: the account can be used
+ // deleted: the account has been deleted but is retained for compliance
+ // reasons, only the administrator can access it
+ // Default to 'active' is missing
+ // @since v4, will become mandatory in the next version.
+ status?: "active" | "deleted";
}
export interface AccountData {
@@ -2322,6 +2370,11 @@ export namespace TalerCorebankApi {
// Number indicating the max debit allowed for the requesting user.
debit_threshold: AmountString;
+ // Custom minimum cashout amount for this account.
+ // If null or absent, the global conversion fee is used.
+ // @since v4
+ min_cashout?: AmountString;
+
contact_data?: ChallengeContactData;
// 'payto' address pointing the bank account
@@ -2340,6 +2393,14 @@ export namespace TalerCorebankApi {
// Is 2FA enabled and what channel is used for challenges?
tan_channel?: TanChannel;
+
+ // Current status of the account
+ // active: the account can be used
+ // deleted: the account has been deleted but is retained for compliance
+ // reasons, only the administrator can access it
+ // Default to 'active' is missing
+ // @since v4, will become mandatory in the next version.
+ status?: "active" | "deleted";
}
export interface CashoutRequest {
diff --git a/packages/taler-util/src/taler-error-codes.ts
b/packages/taler-util/src/taler-error-codes.ts
index c3c008a1c..9985e74b3 100644
--- a/packages/taler-util/src/taler-error-codes.ts
+++ b/packages/taler-util/src/taler-error-codes.ts
@@ -2504,6 +2504,62 @@ export enum TalerErrorCode {
MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED = 2175,
+ /**
+ * The payment requires the wallet to select a choice from the choices array
and pass it in the 'choice_index' field of the request.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_MISSING = 2176,
+
+
+ /**
+ * The 'choice_index' field is invalid.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_CHOICE_INDEX_OUT_OF_BOUNDS = 2177,
+
+
+ /**
+ * The provided 'tokens' array does not match with the required input tokens
of the order.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_INPUT_TOKENS_MISMATCH = 2178,
+
+
+ /**
+ * Invalid token issue signature (blindly signed by merchant) for provided
token.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ISSUE_SIG_INVALID = 2179,
+
+
+ /**
+ * Invalid token use signature (EdDSA, signed by wallet) for provided token.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_TOKEN_USE_SIG_INVALID = 2180,
+
+
+ /**
+ * The provided number of tokens does not match the required number.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_TOKEN_COUNT_MISMATCH = 2181,
+
+
+ /**
+ * The provided number of token envelopes does not match the specified
number.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_POST_ORDERS_ID_PAY_TOKEN_ENVELOPE_COUNT_MISMATCH = 2182,
+
+
/**
* The contract hash does not match the given order ID.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
@@ -2856,6 +2912,14 @@ export enum TalerErrorCode {
MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_NOT_ALLOWED_BY_CONTRACT = 2532,
+ /**
+ * The token family slug provided in this order could not be found in the
merchant database.
+ * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_SLUG_UNKNOWN = 2533,
+
+
/**
* The exchange says it does not know this transfer.
* Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502).
@@ -3184,6 +3248,22 @@ export enum TalerErrorCode {
AUDITOR_EXCHANGE_SIGNING_KEY_REVOKED = 3101,
+ /**
+ * The requested resource could not be found.
+ * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ AUDITOR_RESOURCE_NOT_FOUND = 3102,
+
+
+ /**
+ * The URI is missing a path component.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ AUDITOR_URI_MISSING_PATH_COMPONENT = 3103,
+
+
/**
* Wire transfer attempted with credit and debit party being the same bank
account.
* Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
@@ -3536,6 +3616,22 @@ export enum TalerErrorCode {
BANK_NON_ADMIN_SET_TAN_CHANNEL = 5145,
+ /**
+ * A non-admin user has tried to set their minimum cashout amount.
+ * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ BANK_NON_ADMIN_SET_MIN_CASHOUT = 5146,
+
+
+ /**
+ * Amount of currency conversion it less than the minimum allowed.
+ * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ BANK_CONVERSION_AMOUNT_TO_SMALL = 5147,
+
+
/**
* The sync service failed find the account in its database.
* Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
@@ -4504,6 +4600,14 @@ export enum TalerErrorCode {
DONAU_CHARITY_NOT_FOUND = 8609,
+ /**
+ * The donation amount specified in the request exceeds the limit of the
charity.
+ * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
+ * (A value of 0 indicates that the error is generated client-side).
+ */
+ DONAU_EXCEEDING_DONATION_LIMIT = 8610,
+
+
/**
* A generic error happened in the LibEuFin nexus. See the enclose details
JSON for more information.
* Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0).
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.