aboutsummaryrefslogtreecommitdiff
path: root/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-07-30 17:28:09 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-07-30 17:28:14 +0530
commitb51932cc85287a04dca13cbb3e4d12c5b98e9c47 (patch)
tree2af698817f7d5501ff7c39922a89cd619237f974 /src/operations
parent78718d35343adfe36a4511a06662b626f4bf4957 (diff)
downloadwallet-core-b51932cc85287a04dca13cbb3e4d12c5b98e9c47.tar.xz
support claim tokensv0.7.1-dev.15
Diffstat (limited to 'src/operations')
-rw-r--r--src/operations/pay.ts21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index c2877da64..4a8c2144f 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -603,11 +603,17 @@ async function processDownloadProposalImpl(
).href;
logger.trace("downloading contract from '" + orderClaimUrl + "'");
- const reqestBody = {
+ const requestBody: {
+ nonce: string,
+ token?: string;
+ } = {
nonce: proposal.noncePub,
};
+ if (proposal.claimToken) {
+ requestBody.token = proposal.claimToken;
+ }
- const resp = await ws.http.postJson(orderClaimUrl, reqestBody);
+ const resp = await ws.http.postJson(orderClaimUrl, requestBody);
const proposalResp = await readSuccessResponseJsonOrThrow(
resp,
codecForProposal(),
@@ -715,6 +721,7 @@ async function startDownloadProposal(
merchantBaseUrl: string,
orderId: string,
sessionId: string | undefined,
+ claimToken: string | undefined,
): Promise<string> {
const oldProposal = await ws.db.getIndexed(
Stores.proposals.urlAndOrderIdIndex,
@@ -732,6 +739,7 @@ async function startDownloadProposal(
download: undefined,
noncePriv: priv,
noncePub: pub,
+ claimToken,
timestamp: getTimestampNow(),
merchantBaseUrl,
orderId,
@@ -865,7 +873,7 @@ export async function preparePayForUri(
`invalid taler://pay URI (${talerPayUri})`,
{
talerPayUri,
- }
+ },
);
}
@@ -874,6 +882,7 @@ export async function preparePayForUri(
uriResult.merchantBaseUrl,
uriResult.orderId,
uriResult.sessionId,
+ uriResult.claimToken,
);
let proposal = await ws.db.get(Stores.proposals, proposalId);
@@ -912,7 +921,7 @@ export async function preparePayForUri(
const res = await getCoinsForPayment(ws, contractData);
if (!res) {
- console.log("not confirming payment, insufficient coins");
+ logger.info("not confirming payment, insufficient coins");
return {
status: PreparePayResultType.InsufficientBalance,
contractTerms: d.contractTermsRaw,
@@ -957,7 +966,7 @@ export async function preparePayForUri(
status: PreparePayResultType.AlreadyConfirmed,
contractTerms: purchase.contractTermsRaw,
paid: false,
- };
+ };
} else if (purchase.paymentSubmitPending) {
return {
status: PreparePayResultType.AlreadyConfirmed,
@@ -1020,7 +1029,7 @@ export async function confirmPay(
if (!res) {
// Should not happen, since checkPay should be called first
- console.log("not confirming payment, insufficient coins");
+ logger.warn("not confirming payment, insufficient coins");
throw Error("insufficient balance");
}