diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-05-12 15:44:48 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-05-12 15:44:48 +0530 |
commit | 67dd0eb06e04466ca01a03955ff8f75d40429c79 (patch) | |
tree | 5b4fe00a91d41a5cb758c4983575ec65e4331f76 /src/operations/pay.ts | |
parent | 6206b418ff88a238762a18e7b6eeaceafc5de294 (diff) | |
download | wallet-core-67dd0eb06e04466ca01a03955ff8f75d40429c79.tar.xz |
new transactions API: purchases and refunds
Diffstat (limited to 'src/operations/pay.ts')
-rw-r--r-- | src/operations/pay.ts | 15 |
1 files changed, 11 insertions, 4 deletions
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<AmountJson> { +): Promise<PayCostInfo> { 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", |