gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/02: wallet-core: make templateParams optional


From: gnunet
Subject: [taler-wallet-core] 02/02: wallet-core: make templateParams optional
Date: Fri, 16 Feb 2024 13:39:20 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

commit b70f922fdd928c3ab675522dc8031371909a88ab
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Feb 16 13:39:18 2024 +0100

    wallet-core: make templateParams optional
---
 packages/taler-util/src/wallet-types.ts            |  2 +-
 .../src/operations/pay-merchant.ts                 | 26 +++++++++++++---------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index b79bfe4fe..e6a66ac9d 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -1927,7 +1927,7 @@ export const codecForSharePaymentResult = (): 
Codec<SharePaymentResult> =>
 
 export interface PreparePayTemplateRequest {
   talerPayTemplateUri: string;
-  templateParams: Record<string, string>;
+  templateParams?: Record<string, string>;
 }
 
 export const codecForPreparePayTemplateRequest =
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts 
b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index fc34feb30..4b692fe69 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -1563,26 +1563,30 @@ export async function preparePayForTemplate(
   ws: InternalWalletState,
   req: PreparePayTemplateRequest,
 ): Promise<PreparePayResult> {
-  const url = parsePayTemplateUri(req.talerPayTemplateUri);
+  const parsedUri = parsePayTemplateUri(req.talerPayTemplateUri);
   const templateDetails: MerchantUsingTemplateDetails = {};
-  if (!url) {
+  if (!parsedUri) {
     throw Error("invalid taler-template URI");
   }
+  logger.trace(`parsed URI: ${j2s(parsedUri)}`);
   if (
-    url.templateParams.amount !== undefined &&
-    typeof url.templateParams.amount === "string"
+    parsedUri.templateParams.amount !== undefined &&
+    typeof parsedUri.templateParams.amount === "string"
   ) {
-    templateDetails.amount = (req.templateParams.amount ??
-      url.templateParams.amount) as AmountString | undefined;
+    templateDetails.amount = (req.templateParams?.amount ??
+      parsedUri.templateParams.amount) as AmountString | undefined;
   }
   if (
-    url.templateParams.summary !== undefined &&
-    typeof url.templateParams.summary === "string"
+    parsedUri.templateParams.summary !== undefined &&
+    typeof parsedUri.templateParams.summary === "string"
   ) {
     templateDetails.summary =
-      req.templateParams.summary ?? url.templateParams.summary;
+      req.templateParams?.summary ?? parsedUri.templateParams.summary;
   }
-  const reqUrl = new URL(`templates/${url.templateId}`, url.merchantBaseUrl);
+  const reqUrl = new URL(
+    `templates/${parsedUri.templateId}`,
+    parsedUri.merchantBaseUrl,
+  );
   const httpReq = await ws.http.fetch(reqUrl.href, {
     method: "POST",
     body: templateDetails,
@@ -1593,7 +1597,7 @@ export async function preparePayForTemplate(
   );
 
   const payUri = stringifyPayUri({
-    merchantBaseUrl: url.merchantBaseUrl,
+    merchantBaseUrl: parsedUri.merchantBaseUrl,
     orderId: resp.order_id,
     sessionId: "",
     claimToken: resp.token,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]