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