fix payto

This commit is contained in:
Sebastian 2023-01-23 08:15:22 -03:00
parent 59ce6e3d99
commit 509011f9bc
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 22 additions and 5 deletions

View File

@ -1,8 +1,8 @@
{ {
"private": true, "private": true,
"name": "@gnu-taler/merchant-backoffice", "name": "@gnu-taler/merchant-backoffice",
"version": "0.0.4", "version": "0.0.5",
"license": "MIT", "license": "AGPL-3.0-or-later",
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "./build.mjs", "build": "./build.mjs",

View File

@ -14,6 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/ */
import { parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { h, VNode } from "preact"; import { h, VNode } from "preact";
import { QR } from "../../../../components/exception/QR.js"; import { QR } from "../../../../components/exception/QR.js";
@ -36,7 +37,13 @@ export function CreatedSuccessfully({
onConfirm, onConfirm,
onCreateAnother, onCreateAnother,
}: Props): VNode { }: Props): VNode {
const link = `${entity.response.payto_uri}?message=${entity.response.reserve_pub}&amount=${entity.request.initial_balance}`; const p = parsePaytoUri(entity.response.payto_uri);
if (p) {
p.params["message"] = entity.response.reserve_pub;
p.params["amount"] = entity.request.initial_balance;
}
const link = !p ? entity.response.payto_uri : stringifyPaytoUri(p);
const { i18n } = useTranslationContext(); const { i18n } = useTranslationContext();
return ( return (
<Template onConfirm={onConfirm} onCreateAnother={onCreateAnother}> <Template onConfirm={onConfirm} onCreateAnother={onCreateAnother}>

View File

@ -19,7 +19,11 @@
* @author Sebastian Javier Marchano (sebasjm) * @author Sebastian Javier Marchano (sebasjm)
*/ */
import { Amounts } from "@gnu-taler/taler-util"; import {
Amounts,
parsePaytoUri,
stringifyPaytoUri,
} from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
import { format } from "date-fns"; import { format } from "date-fns";
import { Fragment, h, VNode } from "preact"; import { Fragment, h, VNode } from "preact";
@ -49,7 +53,13 @@ export function DetailPage({ id, selected, onBack }: Props): VNode {
const didExchangeAckTransfer = Amounts.isNonZero( const didExchangeAckTransfer = Amounts.isNonZero(
Amounts.parseOrThrow(selected.exchange_initial_amount), Amounts.parseOrThrow(selected.exchange_initial_amount),
); );
const link = `${selected.payto_uri}?message=${id}&amount=${selected.merchant_initial_amount}`; const p = parsePaytoUri(selected.payto_uri);
if (p) {
p.params["message"] = id;
p.params["amount"] = selected.merchant_initial_amount;
}
const link = !p ? selected.payto_uri : stringifyPaytoUri(p);
return ( return (
<div class="columns"> <div class="columns">