diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-merchant.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index 63bef3add..1039ac95e 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -640,7 +640,8 @@ async function processDownloadProposal( if (proposal.purchaseStatus != PurchaseStatus.PendingDownloadingProposal) { logger.error( - `unexpected state ${proposal.purchaseStatus}/${PurchaseStatus[proposal.purchaseStatus] + `unexpected state ${proposal.purchaseStatus}/${ + PurchaseStatus[proposal.purchaseStatus] } for ${ctx.transactionId} in processDownloadProposal`, ); return TaskRunResult.finished(); @@ -899,7 +900,8 @@ async function createOrReusePurchase( oldProposal.claimToken === claimToken ) { logger.info( - `Found old proposal (status=${PurchaseStatus[oldProposal.purchaseStatus] + `Found old proposal (status=${ + PurchaseStatus[oldProposal.purchaseStatus] }) for order ${orderId} at ${merchantBaseUrl}`, ); if (oldProposal.purchaseStatus === PurchaseStatus.DialogShared) { @@ -1567,12 +1569,21 @@ export async function preparePayForTemplate( throw Error("invalid taler-template URI"); } logger.trace(`parsed URI: ${j2s(parsedUri)}`); - if ( - parsedUri.templateParams.amount !== undefined && - typeof parsedUri.templateParams.amount === "string" - ) { - templateDetails.amount = (req.templateParams?.amount ?? - parsedUri.templateParams.amount) as AmountString | undefined; + + const amountFromUri = parsedUri.templateParams.amount; + if (amountFromUri != null) { + const templateParamsAmount = req.templateParams?.amount; + if (templateParamsAmount != null) { + templateDetails.amount = templateParamsAmount as AmountString; + } else { + if (Amounts.isCurrency(amountFromUri)) { + throw Error( + "Amount from template URI only has a currency without value. The value must be provided in the templateParams.", + ); + } else { + templateDetails.amount = amountFromUri as AmountString; + } + } } if ( parsedUri.templateParams.summary !== undefined && |