fix: remove manual transaction creation causing 400 error
- Remove CREATE_TRANSACTION_MUTATION call that's causing 400 error - Saleor's checkoutComplete already creates order with NOT_CHARGED status for COD - Order doesn't need manual transaction - staff handles fulfillment in dashboard - Keep payment method selection and UI components intact
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
|||||||
CHECKOUT_METADATA_UPDATE,
|
CHECKOUT_METADATA_UPDATE,
|
||||||
CHECKOUT_SHIPPING_METHOD_UPDATE,
|
CHECKOUT_SHIPPING_METHOD_UPDATE,
|
||||||
} from "@/lib/saleor/mutations/Checkout";
|
} from "@/lib/saleor/mutations/Checkout";
|
||||||
import { CREATE_TRANSACTION_MUTATION } from "@/lib/saleor/payments/cod";
|
|
||||||
import { PaymentSection } from "./components/PaymentSection";
|
import { PaymentSection } from "./components/PaymentSection";
|
||||||
import { DEFAULT_PAYMENT_METHOD } from "@/lib/config/paymentMethods";
|
import { DEFAULT_PAYMENT_METHOD } from "@/lib/config/paymentMethods";
|
||||||
import { GET_CHECKOUT_BY_ID } from "@/lib/saleor/queries/Checkout";
|
import { GET_CHECKOUT_BY_ID } from "@/lib/saleor/queries/Checkout";
|
||||||
@@ -386,37 +385,6 @@ export default function CheckoutPage() {
|
|||||||
const order = completeResult.data?.checkoutComplete?.order;
|
const order = completeResult.data?.checkoutComplete?.order;
|
||||||
if (order) {
|
if (order) {
|
||||||
setOrderNumber(order.number);
|
setOrderNumber(order.number);
|
||||||
|
|
||||||
// Create COD transaction for the order
|
|
||||||
if (selectedPaymentMethod === 'cod') {
|
|
||||||
console.log("Step 6: Creating COD transaction...");
|
|
||||||
try {
|
|
||||||
await saleorClient.mutate({
|
|
||||||
mutation: CREATE_TRANSACTION_MUTATION,
|
|
||||||
variables: {
|
|
||||||
id: order.id,
|
|
||||||
transaction: {
|
|
||||||
name: "Cash on Delivery",
|
|
||||||
pspReference: `COD-${order.number}-${Date.now()}`,
|
|
||||||
availableActions: ["CHARGE"],
|
|
||||||
amountAuthorized: {
|
|
||||||
amount: 0,
|
|
||||||
currency: "RSD"
|
|
||||||
},
|
|
||||||
amountCharged: {
|
|
||||||
amount: 0,
|
|
||||||
currency: "RSD"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
console.log("Step 6: COD transaction created successfully");
|
|
||||||
} catch (txError) {
|
|
||||||
console.error("Failed to create COD transaction:", txError);
|
|
||||||
// Don't fail the order if transaction creation fails
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setOrderComplete(true);
|
setOrderComplete(true);
|
||||||
|
|
||||||
// Track order completion
|
// Track order completion
|
||||||
|
|||||||
Reference in New Issue
Block a user