commit 1e15e48de352bd10c1e07e169d35e8d7d12974e2
parent 3aea0c779f14e23aaadb6018bf27ad22865502fa
Author: Sebastian <sebasjm@gmail.com>
Date: Tue, 11 Feb 2025 17:25:14 -0300
fix #9518 #9519
Diffstat:
3 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx
@@ -368,6 +368,7 @@ export function CreatePage({
parsedPrice ?? Amounts.zeroOfCurrency(config.currency),
totalPrice.amount,
);
+ const discountOrRiseRounded = Math.round((discountOrRise - 1) * 100);
const minAgeByProducts = inventoryList.reduce(
(cur, prev) =>
@@ -484,20 +485,18 @@ export function CreatePage({
<Fragment>
<InputCurrency
name="pricing.products_price"
- label={i18n.str`Total price`}
+ label={i18n.str`Products price sum`}
readonly
tooltip={i18n.str`Total product price added up`}
/>
<InputCurrency
name="pricing.order_price"
- label={i18n.str`Total price`}
+ label={i18n.str`Order price`}
addonAfter={
- discountOrRise > 0 &&
- (discountOrRise < 1
- ? `discount of %${Math.round(
- (1 - discountOrRise) * 100,
- )}`
- : `rise of %${Math.round((discountOrRise - 1) * 100)}`)
+ discountOrRiseRounded > 0 &&
+ (discountOrRiseRounded < 1
+ ? `discount of ${discountOrRiseRounded}%`
+ : `rise of ${discountOrRiseRounded}%`)
}
tooltip={i18n.str`Amount to be paid by the customer`}
/>
@@ -701,7 +700,7 @@ export function CreatePage({
tooltip={i18n.str`Any value greater than 0 will limit the coins able be used to pay this contract. If empty the age restriction will be defined by the products`}
help={
minAgeByProducts > 0
- ? i18n.str`Min age defined by the producs is ${minAgeByProducts}`
+ ? i18n.str`Min age defined by the products is ${minAgeByProducts}`
: i18n.str`No product with age restriction in this order`
}
/>
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx
@@ -25,6 +25,7 @@ import {
TalerError,
TalerMerchantApi,
assertUnreachable,
+ stringifyPayUri,
} from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { VNode, h } from "preact";
@@ -131,14 +132,7 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode {
onCopyURL={async (id) => {
const resp = await lib.instance.getOrderDetails(state.token, id);
if (resp.type === "ok") {
- if (resp.body.order_status === "unpaid") {
- copyToClipboard(resp.body.taler_pay_uri);
- } else {
- if (resp.body.contract_terms.fulfillment_url) {
- copyToClipboard(resp.body.contract_terms.fulfillment_url);
- }
- }
- copyToClipboard(resp.body.order_status);
+ copyToClipboard(resp.body.order_status_url);
}
}}
onCreate={onCreate}
@@ -169,7 +163,7 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode {
setNotif({
message: i18n.str`Could not create the refund`,
type: "ERROR",
- description: i18n.str`There are pending KYC requirements.`
+ description: i18n.str`There are pending KYC requirements.`,
});
return;
}
@@ -186,18 +180,17 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode {
return;
}
default: {
- assertUnreachable(resp)
+ assertUnreachable(resp);
}
-
}
-
}
})
.catch((error) =>
setNotif({
message: i18n.str`Could not create the refund`,
type: "ERROR",
- description: error instanceof Error ? error.message : String(error),
+ description:
+ error instanceof Error ? error.message : String(error),
}),
)
.then(() => setOrderToBeRefunded(undefined));
@@ -253,5 +246,6 @@ function RefundModalForTable({ id, onConfirm, onCancel }: RefundProps): VNode {
}
async function copyToClipboard(text: string): Promise<void> {
+ console.log("copied", text);
return navigator.clipboard.writeText(text);
}
diff --git a/packages/taler-util/src/types-taler-merchant.ts b/packages/taler-util/src/types-taler-merchant.ts
@@ -2341,6 +2341,13 @@ export interface CheckPaymentClaimedResponse {
// Contract terms.
contract_terms: ContractTerms;
+
+ // URI that the wallet must process to complete the payment.
+ taler_pay_uri: string;
+
+ // Status URL, can be used as a redirect target for the browser
+ // to show the order QR code / trigger the wallet.
+ order_status_url: string;
}
export interface CheckPaymentUnpaidResponse {
@@ -3673,6 +3680,8 @@ export const codecForCheckPaymentClaimedResponse =
buildCodecForObject<CheckPaymentClaimedResponse>()
.property("order_status", codecForConstString("claimed"))
.property("contract_terms", codecForContractTerms())
+ .property("taler_pay_uri", codecForTalerUriString())
+ .property("order_status_url", codecForString())
.build("TalerMerchantApi.CheckPaymentClaimedResponse");
export const codecForMerchantOrderPrivateStatusResponse =