From 67dd0eb06e04466ca01a03955ff8f75d40429c79 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 12 May 2020 15:44:48 +0530 Subject: new transactions API: purchases and refunds --- src/operations/pay.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/operations/pay.ts') diff --git a/src/operations/pay.ts b/src/operations/pay.ts index a75284393..30ccb56c1 100644 --- a/src/operations/pay.ts +++ b/src/operations/pay.ts @@ -122,6 +122,10 @@ export interface AvailableCoinInfo { feeDeposit: AmountJson; } +export interface PayCostInfo { + totalCost: AmountJson; +} + /** * Compute the total cost of a payment to the customer. * @@ -132,7 +136,7 @@ export interface AvailableCoinInfo { export async function getTotalPaymentCost( ws: InternalWalletState, pcs: PayCoinSelection, -): Promise { +): Promise { const costs = [ pcs.paymentAmount, pcs.customerDepositFees, @@ -163,7 +167,9 @@ export async function getTotalPaymentCost( const refreshCost = getTotalRefreshCost(allDenoms, denom, amountLeft); costs.push(refreshCost); } - return Amounts.sum(costs).amount; + return { + totalCost: Amounts.sum(costs).amount + }; } /** @@ -434,6 +440,7 @@ async function recordConfirmPay( contractTermsRaw: d.contractTermsRaw, contractData: d.contractData, lastSessionId: sessionId, + payCoinSelection: coinSelection, payReq, timestampAccept: getTimestampNow(), timestampLastRefundStatus: undefined, @@ -903,8 +910,8 @@ export async function preparePayForUri( }; } - const totalCost = await getTotalPaymentCost(ws, res); - const totalFees = Amounts.sub(totalCost, res.paymentAmount).amount; + const costInfo = await getTotalPaymentCost(ws, res); + const totalFees = Amounts.sub(costInfo.totalCost, res.paymentAmount).amount; return { status: "payment-possible", -- cgit v1.2.3