Hello!
I have encountered an issue while trying to add a payment to an order. I successfully created a new order using my custom process, but the order does not have any payments. I’m attempting to add a payment following the documentation:
Here’s my code:
const orderId = createdOrder._id;
if (body.generalStatus === "success") {
const payments = [{
amount: {
amount: body.amount.toString()
},
refundDisabled: false,
paymentDetails: {
offlinePayment: true,
status: "APPROVED"
}
}];
try {
const createPayment = await orderTransactions.addPayments(orderId, payments);
console.log('Payment added successfully:', createPayment);
} catch (error) {
console.error('Error adding payment:', error);
}
} else {
console.log('General status is not success. Payment not added.');
}
However, I am getting the following error:
Error adding payment:
message: 'INVALID_ARGUMENT: "payments[0].paymentDetails" must not be empty'
details: validationError: fieldViolations:
- field: payments[0].paymentDetails
description: must not be empty
violatedRule: REQUIRED_FIELD
How can I resolve this issue? Am I missing any required fields in the paymentDetails
object?
Thank you for your help!