fix some transaction list issues
This commit is contained in:
parent
59178331a4
commit
49f362ba6d
@ -73,10 +73,9 @@ export function getTotalRefreshCost(
|
|||||||
).amount;
|
).amount;
|
||||||
const totalCost = Amounts.sub(amountLeft, resultingAmount).amount;
|
const totalCost = Amounts.sub(amountLeft, resultingAmount).amount;
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"total refresh cost for",
|
`total refresh cost for ${amountToPretty(amountLeft)} is ${amountToPretty(
|
||||||
amountToPretty(amountLeft),
|
totalCost,
|
||||||
"is",
|
)}`,
|
||||||
amountToPretty(totalCost),
|
|
||||||
);
|
);
|
||||||
return totalCost;
|
return totalCost;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ export async function getFullRefundFees(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRefundKey(d: MerchantRefundDetails): string {
|
function getRefundKey(d: MerchantRefundDetails): string {
|
||||||
return `{d.coin_pub}-{d.rtransaction_id}`;
|
return `${d.coin_pub}-${d.rtransaction_id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function acceptRefundResponse(
|
async function acceptRefundResponse(
|
||||||
@ -144,9 +144,14 @@ async function acceptRefundResponse(
|
|||||||
const unfinishedRefunds: MerchantRefundDetails[] = [];
|
const unfinishedRefunds: MerchantRefundDetails[] = [];
|
||||||
const failedRefunds: MerchantRefundDetails[] = [];
|
const failedRefunds: MerchantRefundDetails[] = [];
|
||||||
|
|
||||||
|
console.log("handling refund response", refundResponse);
|
||||||
|
|
||||||
const refundsRefreshCost: { [refundKey: string]: AmountJson } = {};
|
const refundsRefreshCost: { [refundKey: string]: AmountJson } = {};
|
||||||
|
|
||||||
for (const rd of refunds) {
|
for (const rd of refunds) {
|
||||||
|
logger.trace(
|
||||||
|
`Refund ${rd.rtransaction_id} has HTTP status ${rd.exchange_http_status}`,
|
||||||
|
);
|
||||||
if (rd.exchange_http_status === 200) {
|
if (rd.exchange_http_status === 200) {
|
||||||
// FIXME: also verify signature if necessary.
|
// FIXME: also verify signature if necessary.
|
||||||
finishedRefunds.push(rd);
|
finishedRefunds.push(rd);
|
||||||
@ -160,6 +165,8 @@ async function acceptRefundResponse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute cost.
|
||||||
|
// FIXME: Optimize, don't always recompute.
|
||||||
for (const rd of [...finishedRefunds, ...unfinishedRefunds]) {
|
for (const rd of [...finishedRefunds, ...unfinishedRefunds]) {
|
||||||
const key = getRefundKey(rd);
|
const key = getRefundKey(rd);
|
||||||
const coin = await ws.db.get(Stores.coins, rd.coin_pub);
|
const coin = await ws.db.get(Stores.coins, rd.coin_pub);
|
||||||
@ -280,6 +287,8 @@ async function acceptRefundResponse(
|
|||||||
// after a retry delay?
|
// after a retry delay?
|
||||||
let queryDone = true;
|
let queryDone = true;
|
||||||
|
|
||||||
|
logger.trace(`got ${numNewRefunds} new refund permissions`);
|
||||||
|
|
||||||
if (numNewRefunds === 0) {
|
if (numNewRefunds === 0) {
|
||||||
if (p.autoRefundDeadline && p.autoRefundDeadline.t_ms > now.t_ms) {
|
if (p.autoRefundDeadline && p.autoRefundDeadline.t_ms > now.t_ms) {
|
||||||
queryDone = false;
|
queryDone = false;
|
||||||
@ -311,7 +320,7 @@ async function acceptRefundResponse(
|
|||||||
console.log("refund query not done");
|
console.log("refund query not done");
|
||||||
}
|
}
|
||||||
|
|
||||||
p.refundsRefreshCost = {...p.refundsRefreshCost, ...refundsRefreshCost };
|
p.refundsRefreshCost = { ...p.refundsRefreshCost, ...refundsRefreshCost };
|
||||||
|
|
||||||
await tx.put(Stores.purchases, p);
|
await tx.put(Stores.purchases, p);
|
||||||
|
|
||||||
|
@ -254,8 +254,7 @@ export async function getTransactions(
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const rg of pr.refundGroups) {
|
for (const rg of pr.refundGroups) {
|
||||||
const pending = Object.keys(pr.refundsDone).length > 0;
|
const pending = Object.keys(pr.refundsPending).length > 0;
|
||||||
|
|
||||||
const stats = getRefundStats(pr, rg.refundGroupId);
|
const stats = getRefundStats(pr, rg.refundGroupId);
|
||||||
|
|
||||||
transactions.push({
|
transactions.push({
|
||||||
@ -263,11 +262,11 @@ export async function getTransactions(
|
|||||||
pending,
|
pending,
|
||||||
info: {
|
info: {
|
||||||
fulfillmentUrl: pr.contractData.fulfillmentUrl,
|
fulfillmentUrl: pr.contractData.fulfillmentUrl,
|
||||||
merchant: {},
|
merchant: pr.contractData.merchant,
|
||||||
orderId: pr.contractData.orderId,
|
orderId: pr.contractData.orderId,
|
||||||
products: [],
|
products: pr.contractData.products,
|
||||||
summary: pr.contractData.summary,
|
summary: pr.contractData.summary,
|
||||||
summary_i18n: {},
|
summary_i18n: pr.contractData.summaryI18n,
|
||||||
},
|
},
|
||||||
timestamp: rg.timestampQueried,
|
timestamp: rg.timestampQueried,
|
||||||
transactionId: makeEventId(
|
transactionId: makeEventId(
|
||||||
|
Loading…
Reference in New Issue
Block a user