From 920595aa3864615c07aba0ecfc233acf05f3e3e6 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 6 Jun 2024 09:24:50 -0300 Subject: update bank api with card fee --- .../taler-util/src/http-client/bank-integration.ts | 4 + packages/taler-util/src/http-client/types.ts | 35 +++++- packages/taler-util/src/taler-error-codes.ts | 124 ++++++++++++++++++++- packages/taler-util/src/wallet-types.ts | 1 + packages/taler-wallet-core/src/withdraw.ts | 5 + 5 files changed, 165 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/taler-util/src/http-client/bank-integration.ts b/packages/taler-util/src/http-client/bank-integration.ts index 75e6a627a..08dab58e2 100644 --- a/packages/taler-util/src/http-client/bank-integration.ts +++ b/packages/taler-util/src/http-client/bank-integration.ts @@ -147,6 +147,10 @@ export class TalerBankIntegrationHttpClient { return opKnownTalerFailure(details.code, details); case TalerErrorCode.BANK_ACCOUNT_IS_NOT_EXCHANGE: return opKnownTalerFailure(details.code, details); + case TalerErrorCode.BANK_AMOUNT_DIFFERS: + return opKnownTalerFailure(details.code, details); + case TalerErrorCode.BANK_AMOUNT_REQUIRED: + return opKnownTalerFailure(details.code, details); default: return opUnknownFailure(resp, details); } diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts index 9268f6387..94f2c7518 100644 --- a/packages/taler-util/src/http-client/types.ts +++ b/packages/taler-util/src/http-client/types.ts @@ -1312,6 +1312,7 @@ export const codecForBankWithdrawalOperationStatus = ), ) .property("amount", codecOptional(codecForAmountString())) + .property("card_fees", codecOptional(codecForAmountString())) .property("sender_wire", codecOptional(codecForPaytoString())) .property("suggested_exchange", codecOptional(codecForString())) .property("confirm_transfer_url", codecOptional(codecForURL())) @@ -2029,16 +2030,41 @@ export namespace TalerBankIntegrationApi { status: WithdrawalOperationStatus; // Amount that will be withdrawn with this operation - // (raw amount without fee considerations). - amount: AmountString | undefined; + // (raw amount without fee considerations). Only + // given once the amount is fixed and cannot be changed. + // Optional since **vC2EC**. + amount?: AmountString | undefined; + + // Maximum amount that the wallet can choose to withdraw. + // Only applicable when the amount is not fixed. + // @since **vC2EC**. + max_amount?: AmountString | undefined; + + // The non-Taler card fees the customer will have + // to pay to the bank / payment service provider + // they are using to make the withdrawal. + // @since **vC2EC** + card_fees?: AmountString | undefined; // Bank account of the customer that is withdrawing, as a // payto URI. sender_wire?: PaytoString; + // Suggestion for the amount to be withdrawn with this + // operation. Given if a suggestion was made but the + // user may still change the amount. + // Optional since **vC2EC**. + suggested_amount?: AmountString | undefined; + // Suggestion for an exchange given by the bank. suggested_exchange?: string; + // Base URL of an exchange that must be used. Optional, + // not given *unless* a particular exchange is mandatory. + // This value is typically set in the bank's configuration. + // @since **vC2EC** + required_exchange?: string; + // URL that the user needs to navigate to in order to // complete some final confirmation (e.g. 2FA). // It may contain withdrawal operation id @@ -2062,6 +2088,11 @@ export namespace TalerBankIntegrationApi { // Payto address of the exchange selected for the withdrawal. selected_exchange: PaytoString; + + // Selected amount to be transferred. Optional if the + // backend already knows the amount. + // @since **vC2EC** + amount?: AmountString | undefined; } export interface BankWithdrawalOperationPostResponse { diff --git a/packages/taler-util/src/taler-error-codes.ts b/packages/taler-util/src/taler-error-codes.ts index 9985e74b3..c463d94a0 100644 --- a/packages/taler-util/src/taler-error-codes.ts +++ b/packages/taler-util/src/taler-error-codes.ts @@ -354,7 +354,7 @@ export enum TalerErrorCode { /** * The backend could not locate a required template to generate an HTML reply. The system administrator should check if the resource files are installed in the correct location and are readable to the service. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). + * Returned with an HTTP status code of #MHD_HTTP_NOT_ACCEPTABLE (406). * (A value of 0 indicates that the error is generated client-side). */ GENERIC_FAILED_TO_LOAD_TEMPLATE = 74, @@ -1945,7 +1945,7 @@ export enum TalerErrorCode { /** - * The payto-URI hash did not match. Hence the request was denied. + * The KYC authorization signature was invalid. Hence the request was denied. * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). * (A value of 0 indicates that the error is generated client-side). */ @@ -2016,6 +2016,22 @@ export enum TalerErrorCode { EXCHANGE_KYC_WEBHOOK_UNAUTHORIZED = 1938, + /** + * The exchange is unaware of the given requirement row. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_KYC_CHECK_REQUEST_UNKNOWN = 1939, + + + /** + * The exchange has no account public key to check the KYC authorization signature against. Hence the request was denied. The user should do a wire transfer to the exchange with the KYC authorization key in the subject. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_KYC_CHECK_AUTHORIZATION_KEY_UNKNOWN = 1940, + + /** * The exchange does not know a contract under the given contract public key. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). @@ -2104,6 +2120,14 @@ export enum TalerErrorCode { MERCHANT_GENERIC_EXCHANGE_WIRE_REQUEST_FAILED = 2002, + /** + * The product category is not known to the backend. + * 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_GENERIC_CATEGORY_UNKNOWN = 2003, + + /** * The proposal is not known to the backend. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). @@ -3056,6 +3080,14 @@ export enum TalerErrorCode { MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS = 2650, + /** + * A category with the same name exists already. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + MERCHANT_PRIVATE_POST_CATEGORIES_CONFLICT_CATEGORY_EXISTS = 2651, + + /** * The update would have reduced the total amount of product lost, which is not allowed. * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). @@ -3232,6 +3264,22 @@ export enum TalerErrorCode { MERCHANT_PRIVATE_POST_PENDING_WEBHOOKS_CONFLICT_PENDING_WEBHOOK_EXISTS = 2910, + /** + * The auditor refused the connection due to a lack of authorization. + * Returned with an HTTP status code of #MHD_HTTP_UNAUTHORIZED (401). + * (A value of 0 indicates that the error is generated client-side). + */ + AUDITOR_GENERIC_UNAUTHORIZED = 3001, + + + /** + * This method is not allowed here. + * Returned with an HTTP status code of #MHD_HTTP_METHOD_NOT_ALLOWED (405). + * (A value of 0 indicates that the error is generated client-side). + */ + AUDITOR_GENERIC_METHOD_NOT_ALLOWED = 3002, + + /** * The signature from the exchange on the deposit confirmation is invalid. * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). @@ -3632,6 +3680,22 @@ export enum TalerErrorCode { BANK_CONVERSION_AMOUNT_TO_SMALL = 5147, + /** + * Specified amount will not work for this withdrawal. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + BANK_AMOUNT_DIFFERS = 5148, + + + /** + * The backend requires an amount to be specified. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + BANK_AMOUNT_REQUIRED = 5149, + + /** * The sync service failed find the account in its database. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). @@ -4608,6 +4672,62 @@ export enum TalerErrorCode { DONAU_EXCEEDING_DONATION_LIMIT = 8610, + /** + * The Donau is not aware of the donation unit requested for the operation. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_GENERIC_DONATION_UNIT_UNKNOWN = 8611, + + + /** + * The Donau failed to talk to the process responsible for its private donation unit keys or the helpers had no donation units (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). + */ + DONAU_DONATION_UNIT_HELPER_UNAVAILABLE = 8612, + + + /** + * The Donau failed to talk to the process responsible for its private signing keys. + * Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_SIGNKEY_HELPER_UNAVAILABLE = 8613, + + + /** + * The response from the online signing key helper process was malformed. + * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_SIGNKEY_HELPER_BUG = 8614, + + + /** + * The number of segments included in the URI does not match the number of segments expected by the endpoint. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_GENERIC_WRONG_NUMBER_OF_SEGMENTS = 8615, + + + /** + * The signature of the donation receipt is not valid. + * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_DONATION_RECEIPT_SIGNATURE_INVALID = 8616, + + + /** + * The client re-used a unique donor identifier nonce, which 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). + */ + DONAU_DONOR_IDENTIFIER_NONCE_REUSE = 8617, + + /** * 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). diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 24a48b415..a7cd65fa2 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -988,6 +988,7 @@ export interface BankWithdrawDetails { status: WithdrawalOperationStatus; currency: string; amount: AmountJson | undefined; + wireFee: AmountJson | undefined; senderWire?: string; suggestedExchange?: string; confirmTransferUrl?: string; diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts index b2cecea16..24e2861e1 100644 --- a/packages/taler-wallet-core/src/withdraw.ts +++ b/packages/taler-wallet-core/src/withdraw.ts @@ -862,12 +862,17 @@ export async function getBankWithdrawalInfo( if (status.amount) { amount = Amounts.parseOrThrow(status.amount); } + let wireFee: AmountJson | undefined; + if (status.card_fees) { + wireFee = Amounts.parseOrThrow(status.card_fees); + } return { operationId: uriResult.withdrawalOperationId, apiBaseUrl: uriResult.bankIntegrationApiBaseUrl, currency: config.currency, amount, + wireFee, confirmTransferUrl: status.confirm_transfer_url, senderWire: status.sender_wire, suggestedExchange: status.suggested_exchange, -- cgit v1.2.3