add delivery info in the parse contract terms and a function to get info from a proposalId
This commit is contained in:
parent
88bdcae030
commit
4409d8384b
@ -43,6 +43,7 @@ import {
|
||||
AgeCommitmentProof,
|
||||
PayCoinSelection,
|
||||
PeerContractTerms,
|
||||
Location,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { RetryInfo } from "./util/retries.js";
|
||||
import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
|
||||
@ -1170,6 +1171,8 @@ export interface WalletContractData {
|
||||
wireInfoHash: string;
|
||||
maxDepositFee: AmountJson;
|
||||
minimumAge?: number;
|
||||
deliveryDate: TalerProtocolTimestamp | undefined;
|
||||
deliveryLocation: Location | undefined;
|
||||
}
|
||||
|
||||
export enum AbortStatus {
|
||||
|
@ -600,6 +600,8 @@ export async function importBackup(
|
||||
merchant: parsedContractTerms.merchant,
|
||||
products: parsedContractTerms.products,
|
||||
summaryI18n: parsedContractTerms.summary_i18n,
|
||||
deliveryDate: parsedContractTerms.delivery_date,
|
||||
deliveryLocation: parsedContractTerms.delivery_location,
|
||||
},
|
||||
contractTermsRaw: backupProposal.contract_terms_raw,
|
||||
};
|
||||
@ -740,6 +742,8 @@ export async function importBackup(
|
||||
merchant: parsedContractTerms.merchant,
|
||||
products: parsedContractTerms.products,
|
||||
summaryI18n: parsedContractTerms.summary_i18n,
|
||||
deliveryDate: parsedContractTerms.delivery_date,
|
||||
deliveryLocation: parsedContractTerms.delivery_location,
|
||||
},
|
||||
contractTermsRaw: backupPurchase.contract_terms_raw,
|
||||
};
|
||||
|
@ -662,6 +662,8 @@ export function extractContractData(
|
||||
products: parsedContractTerms.products,
|
||||
summaryI18n: parsedContractTerms.summary_i18n,
|
||||
minimumAge: parsedContractTerms.minimum_age,
|
||||
deliveryDate: parsedContractTerms.delivery_date,
|
||||
deliveryLocation: parsedContractTerms.delivery_location,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1318,6 +1320,27 @@ export async function checkPaymentByProposalId(
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContractTermsDetails(
|
||||
ws: InternalWalletState,
|
||||
proposalId: string,
|
||||
): Promise<WalletContractData> {
|
||||
const proposal = await ws.db
|
||||
.mktx((x) => ({ proposals: x.proposals }))
|
||||
.runReadOnly(async (tx) => {
|
||||
return tx.proposals.get(proposalId);
|
||||
});
|
||||
|
||||
if (!proposal) {
|
||||
throw Error(`proposal with id ${proposalId} not found`);
|
||||
}
|
||||
|
||||
if (!proposal.download || !proposal.download.contractData) {
|
||||
throw Error("proposal is in invalid state");
|
||||
}
|
||||
|
||||
return proposal.download.contractData
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a payment for the given taler://pay/ URI is possible.
|
||||
*
|
||||
|
@ -448,6 +448,9 @@ export async function getTransactions(
|
||||
tipRecord.walletTipId,
|
||||
),
|
||||
merchantBaseUrl: tipRecord.merchantBaseUrl,
|
||||
// merchant: {
|
||||
// name: tipRecord.merchantBaseUrl,
|
||||
// },
|
||||
error: tipRecord.lastError,
|
||||
});
|
||||
});
|
||||
|
@ -43,6 +43,7 @@ import {
|
||||
codecForCreateDepositGroupRequest,
|
||||
codecForDeleteTransactionRequest,
|
||||
codecForForceRefreshRequest,
|
||||
codecForGetContractTermsDetails,
|
||||
codecForGetExchangeTosRequest,
|
||||
codecForGetExchangeWithdrawalInfo,
|
||||
codecForGetFeeForDeposit,
|
||||
@ -142,6 +143,7 @@ import {
|
||||
import { getMerchantInfo } from "./operations/merchants.js";
|
||||
import {
|
||||
confirmPay,
|
||||
getContractTermsDetails,
|
||||
preparePayForUri,
|
||||
processDownloadProposal,
|
||||
processPurchasePay,
|
||||
@ -868,6 +870,10 @@ async function dispatchRequestInternal(
|
||||
const req = codecForGetExchangeTosRequest().decode(payload);
|
||||
return getExchangeTos(ws, req.exchangeBaseUrl, req.acceptedFormat);
|
||||
}
|
||||
case "getContractTermsDetails": {
|
||||
const req = codecForGetContractTermsDetails().decode(payload);
|
||||
return getContractTermsDetails(ws, req.proposalId);
|
||||
}
|
||||
case "retryPendingNow": {
|
||||
await runPending(ws, true);
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user