.... needa pass currency
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
import { trpcApiStore } from "$lib/stores/api";
|
import { trpcApiStore } from "$lib/stores/api";
|
||||||
import { toast } from "svelte-sonner";
|
import { toast } from "svelte-sonner";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
|
import { currencyStore } from "../currency/view/currency.vm.svelte";
|
||||||
import { customerInfoVM } from "../customerinfo/view/customerinfo.vm.svelte";
|
import { customerInfoVM } from "../customerinfo/view/customerinfo.vm.svelte";
|
||||||
import { productStore } from "../product/store";
|
import { productStore } from "../product/store";
|
||||||
import { paymentInfoVM } from "./payment-info-section/payment.info.vm.svelte";
|
import { paymentInfoVM } from "./payment-info-section/payment.info.vm.svelte";
|
||||||
@@ -74,13 +75,14 @@ class CheckoutViewModel {
|
|||||||
const parsed = newOrderModel.safeParse({
|
const parsed = newOrderModel.safeParse({
|
||||||
...priceDetails,
|
...priceDetails,
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
|
currency: get(currencyStore).code,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (parsed.error) {
|
if (parsed.error) {
|
||||||
console.log(parsed.error);
|
console.error("Order model validation error:", parsed.error.errors);
|
||||||
const err = parsed.error.errors[0];
|
const err = parsed.error.errors[0];
|
||||||
toast.error("Failed to perform checkout", {
|
toast.error("Failed to perform checkout", {
|
||||||
description: err.message,
|
description: `${err.path.join(".")}: ${err.message}`,
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -91,10 +93,13 @@ class CheckoutViewModel {
|
|||||||
productId: get(productStore)?.id,
|
productId: get(productStore)?.id,
|
||||||
});
|
});
|
||||||
if (pInfoParsed.error) {
|
if (pInfoParsed.error) {
|
||||||
console.log(parsed.error);
|
console.error(
|
||||||
|
"Payment info validation error:",
|
||||||
|
pInfoParsed.error.errors,
|
||||||
|
);
|
||||||
const err = pInfoParsed.error.errors[0];
|
const err = pInfoParsed.error.errors[0];
|
||||||
toast.error("Failed to perform checkout", {
|
toast.error("Failed to validate payment information", {
|
||||||
description: err.message,
|
description: `${err.path.join(".")}: ${err.message}`,
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { billingDetailsVM } from "$lib/domains/checkout/payment-info-section/billing.details.vm.svelte";
|
import { billingDetailsVM } from "$lib/domains/checkout/payment-info-section/billing.details.vm.svelte";
|
||||||
import { calculateFinalPrices } from "$lib/domains/checkout/utils";
|
import { calculateFinalPrices } from "$lib/domains/checkout/utils";
|
||||||
import { ckFlowVM } from "$lib/domains/ckflow/view/ckflow.vm.svelte";
|
import { ckFlowVM } from "$lib/domains/ckflow/view/ckflow.vm.svelte";
|
||||||
|
import { currencyStore } from "$lib/domains/currency/view/currency.vm.svelte";
|
||||||
import { customerInfoVM } from "$lib/domains/customerinfo/view/customerinfo.vm.svelte";
|
import { customerInfoVM } from "$lib/domains/customerinfo/view/customerinfo.vm.svelte";
|
||||||
import {
|
import {
|
||||||
createOrderPayloadModel,
|
createOrderPayloadModel,
|
||||||
@@ -119,15 +120,16 @@ export class CreateOrderViewModel {
|
|||||||
orderModel: {
|
orderModel: {
|
||||||
...priceDetails,
|
...priceDetails,
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
|
currency: get(currencyStore).code,
|
||||||
},
|
},
|
||||||
flowId: ckFlowVM.flowId,
|
flowId: ckFlowVM.flowId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (parsed.error) {
|
if (parsed.error) {
|
||||||
console.error("Order payload validation error:", parsed.error.errors);
|
console.error("Order payload validation error:", parsed.error.errors);
|
||||||
const msg = parsed.error.errors[0].message;
|
const err = parsed.error.errors[0];
|
||||||
toast.error("Invalid order data", {
|
toast.error("Invalid order data", {
|
||||||
description: msg,
|
description: `${err.path.join(".")}: ${err.message}`,
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user