wallet-core: return txid when starting refund via URI

This commit is contained in:
Florian Dold 2023-05-10 17:30:38 +02:00
parent cb53546035
commit 6308c7ea6b
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
4 changed files with 18 additions and 5 deletions

View File

@ -1645,6 +1645,10 @@ export interface PrepareRefundRequest {
talerRefundUri: string;
}
export interface StartRefundQueryForUriResponse {
transactionId: string;
}
export const codecForPrepareRefundRequest = (): Codec<PrepareRefundRequest> =>
buildCodecForObject<PrepareRefundRequest>()
.property("talerRefundUri", codecForString())

View File

@ -69,6 +69,7 @@ import {
PrepareRefundResult,
randomBytes,
RefreshReason,
StartRefundQueryForUriResponse,
TalerError,
TalerErrorCode,
TalerErrorDetail,
@ -2051,7 +2052,7 @@ async function processPurchaseAcceptRefund(
export async function startRefundQueryForUri(
ws: InternalWalletState,
talerUri: string,
): Promise<void> {
): Promise<StartRefundQueryForUriResponse> {
const parsedUri = parseTalerUri(talerUri);
if (!parsedUri) {
throw Error("invalid taler:// URI");
@ -2070,7 +2071,15 @@ export async function startRefundQueryForUri(
if (!purchaseRecord) {
throw Error("no purchase found, can't refund");
}
return startQueryRefund(ws, purchaseRecord.proposalId);
const proposalId = purchaseRecord.proposalId;
const transactionId = constructTransactionIdentifier({
tag: TransactionType.Payment,
proposalId,
});
await startQueryRefund(ws, proposalId);
return {
transactionId,
}
}
export async function startQueryRefund(

View File

@ -110,6 +110,7 @@ import {
WithdrawFakebankRequest,
WithdrawTestBalanceRequest,
WithdrawUriInfoResponse,
StartRefundQueryForUriResponse,
} from "@gnu-taler/taler-util";
import { AuditorTrustRecord, WalletContractData } from "./db.js";
import {
@ -438,7 +439,7 @@ export type ConfirmPayOp = {
export type StartRefundQueryForUriOp = {
op: WalletApiOperation.StartRefundQueryForUri;
request: PrepareRefundRequest;
response: EmptyObject;
response: StartRefundQueryForUriResponse;
};
export type StartRefundQueryOp = {

View File

@ -1288,8 +1288,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
}
case WalletApiOperation.StartRefundQueryForUri: {
const req = codecForPrepareRefundRequest().decode(payload);
await startRefundQueryForUri(ws, req.talerRefundUri);
return {};
return await startRefundQueryForUri(ws, req.talerRefundUri);
}
case WalletApiOperation.StartRefundQuery: {
const req = codecForStartRefundQueryRequest().decode(payload);