aboutsummaryrefslogtreecommitdiff
path: root/src/operations
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations')
-rw-r--r--src/operations/balance.ts2
-rw-r--r--src/operations/errors.ts2
-rw-r--r--src/operations/history.ts6
-rw-r--r--src/operations/pay.ts44
4 files changed, 21 insertions, 33 deletions
diff --git a/src/operations/balance.ts b/src/operations/balance.ts
index 36971c395..81b4da6e0 100644
--- a/src/operations/balance.ts
+++ b/src/operations/balance.ts
@@ -130,7 +130,7 @@ export async function getBalancesInsideTransaction(
if (t.timestampFirstSuccessfulPay) {
return;
}
- for (const c of t.payReq.coins) {
+ for (const c of t.coinDepositPermissions) {
addTo(
balanceStore,
"pendingPayment",
diff --git a/src/operations/errors.ts b/src/operations/errors.ts
index 9def02b0e..01a8283cb 100644
--- a/src/operations/errors.ts
+++ b/src/operations/errors.ts
@@ -24,8 +24,6 @@
* Imports.
*/
import { OperationError } from "../types/walletTypes";
-import { HttpResponse } from "../util/http";
-import { Codec } from "../util/codec";
/**
* This exception is there to let the caller know that an error happened,
diff --git a/src/operations/history.ts b/src/operations/history.ts
index f04dad113..9cbbd5163 100644
--- a/src/operations/history.ts
+++ b/src/operations/history.ts
@@ -246,7 +246,7 @@ export async function getHistory(
contribution: string;
denomPub: string;
}[] = [];
- for (const x of purchase.payReq.coins) {
+ for (const x of purchase.coinDepositPermissions) {
const c = await tx.get(Stores.coins, x.coin_pub);
if (!c) {
// FIXME: what to do here??
@@ -269,7 +269,7 @@ export async function getHistory(
verboseDetails = { coins };
}
const amountPaidWithFees = Amounts.sum(
- purchase.payReq.coins.map((x) =>
+ purchase.coinDepositPermissions.map((x) =>
Amounts.parseOrThrow(x.contribution),
),
).amount;
@@ -280,7 +280,7 @@ export async function getHistory(
replay: pe.isReplay,
sessionId: pe.sessionId,
timestamp: pe.timestamp,
- numCoins: purchase.payReq.coins.length,
+ numCoins: purchase.coinDepositPermissions.length,
amountPaidWithFees: Amounts.stringify(amountPaidWithFees),
verboseDetails,
});
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index abcb2ad1d..74bfcc70b 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -42,6 +42,7 @@ import {
codecForProposal,
codecForContractTerms,
CoinDepositPermission,
+ codecForMerchantPayResponse,
} from "../types/talerTypes";
import {
ConfirmPayResult,
@@ -431,12 +432,6 @@ async function recordConfirmPay(
sessionId = proposal.downloadSessionId;
}
logger.trace(`recording payment with session ID ${sessionId}`);
- const payReq: PayReq = {
- coins: coinDepositPermissions,
- merchant_pub: d.contractData.merchantPub,
- mode: "pay",
- order_id: d.contractData.orderId,
- };
const payCostInfo = await getTotalPaymentCost(ws, coinSelection);
const t: PurchaseRecord = {
abortDone: false,
@@ -445,8 +440,8 @@ async function recordConfirmPay(
contractData: d.contractData,
lastSessionId: sessionId,
payCoinSelection: coinSelection,
- payReq,
payCostInfo,
+ coinDepositPermissions,
timestampAccept: getTimestampNow(),
timestampLastRefundStatus: undefined,
proposalId: proposal.proposalId,
@@ -609,7 +604,6 @@ async function processDownloadProposalImpl(
).href;
logger.trace("downloading contract from '" + orderClaimUrl + "'");
-
const proposalResp = await httpPostTalerJson({
url: orderClaimUrl,
body: {
@@ -777,26 +771,24 @@ export async function submitPay(
throw Error("not submitting payment for aborted purchase");
}
const sessionId = purchase.lastSessionId;
- let resp;
- const payReq = { ...purchase.payReq, session_id: sessionId };
console.log("paying with session ID", sessionId);
- const payUrl = new URL("pay", purchase.contractData.merchantBaseUrl).href;
+ const payUrl = new URL(
+ `orders/${purchase.contractData.orderId}/pay`,
+ purchase.contractData.merchantBaseUrl,
+ ).href;
+
+ const merchantResp = await httpPostTalerJson({
+ url: payUrl,
+ body: {
+ coins: purchase.coinDepositPermissions,
+ session_id: purchase.lastSessionId,
+ },
+ codec: codecForMerchantPayResponse(),
+ http: ws.http,
+ });
- try {
- console.log("pay req", payReq);
- resp = await ws.http.postJson(payUrl, payReq);
- } catch (e) {
- // Gives the user the option to retry / abort and refresh
- console.log("payment failed", e);
- throw e;
- }
- if (resp.status !== 200) {
- console.log(await resp.json());
- throw Error(`unexpected status (${resp.status}) for /pay`);
- }
- const merchantResp = await resp.json();
console.log("got success from pay URL", merchantResp);
const now = getTimestampNow();
@@ -1030,7 +1022,7 @@ export async function confirmPay(
coinPriv: coin.coinPriv,
coinPub: coin.coinPub,
contractTermsHash: d.contractData.contractTermsHash,
- denomPub: coin.denomPub,
+ denomPubHash: coin.denomPubHash,
denomSig: coin.denomSig,
exchangeBaseUrl: coin.exchangeBaseUrl,
feeDeposit: denom.feeDeposit,
@@ -1050,8 +1042,6 @@ export async function confirmPay(
sessionIdOverride,
);
- logger.trace("confirmPay: submitting payment after creating purchase record");
- logger.trace("purchaseRecord:", purchase);
return submitPay(ws, proposalId);
}