From c2dcad8efeb7948a98997053a8e26087b40bacf8 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Aug 2020 20:05:41 +0530 Subject: [PATCH] fix preparePay API response --- packages/taler-wallet-core/src/operations/pay.ts | 7 +++++++ packages/taler-wallet-core/src/types/walletTypes.ts | 3 +++ 2 files changed, 10 insertions(+) diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index 0fa9e0a61..fd997fb14 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -927,6 +927,7 @@ export async function preparePayForUri( status: PreparePayResultType.InsufficientBalance, contractTerms: JSON.parse(d.contractTermsRaw), proposalId: proposal.proposalId, + amountRaw: Amounts.stringify(d.contractData.amount), }; } @@ -961,18 +962,24 @@ export async function preparePayForUri( contractTerms: JSON.parse(purchase.contractTermsRaw), paid: true, nextUrl: r.nextUrl, + amountRaw: Amounts.stringify(purchase.contractData.amount), + amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost), }; } else if (!purchase.timestampFirstSuccessfulPay) { return { status: PreparePayResultType.AlreadyConfirmed, contractTerms: JSON.parse(purchase.contractTermsRaw), paid: false, + amountRaw: Amounts.stringify(purchase.contractData.amount), + amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost), }; } else if (purchase.paymentSubmitPending) { return { status: PreparePayResultType.AlreadyConfirmed, contractTerms: JSON.parse(purchase.contractTermsRaw), paid: false, + amountRaw: Amounts.stringify(purchase.contractData.amount), + amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost), }; } // FIXME: we don't handle aborted payments correctly here. diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 83275a0cc..6175c40eb 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -353,12 +353,15 @@ export interface PreparePayResultInsufficientBalance { status: PreparePayResultType.InsufficientBalance; proposalId: string; contractTerms: Record; + amountRaw: string; } export interface PreparePayResultAlreadyConfirmed { status: PreparePayResultType.AlreadyConfirmed; contractTerms: Record; paid: boolean; + amountRaw: string; + amountEffective: string; // Only specified if paid. nextUrl?: string; }