#ZeroThreeEight
1 messages · Page 1 of 1 (latest)
👋 happy to help
would you mind sharing the request ID? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Hi
Yes
But the error is regarding my own code
Error handling chargeback: Error: Stripe: Argument "customer" must be a string, but got: [object Object] (on API request to `GET /v1/customers/{customer}`) \
if (eventType === "charge.dispute.created") {
console.log("Chargeback functie gestart");
try {
// Retrieve and expand the charge object to access the customer ID
const charge = await stripe.charges.retrieve(data.charge, {
expand: ["customer"],
});
const customer = await stripe.customers.retrieve(charge.customer);
// Update database
const id = customer.metadata.id;
const ref = db.collection("users").doc(id);
const get = await ref.get();
const userData = get.data();
console.log("Met ID: " + id);
const updatedData = {
...userData,
eindDatum: moment().format("DD-MM-YYYY"),
isBetaald: "Chargeback",
};
const update = ref.update(updatedData);
const sheet = await axios.put(
`${process.env.SHEET_BEST_API}/id/${id}`,
{
...updatedData,
}
);
// Unsubscribe with subscription ID
try {
const subscriptionId = userData.subscriptionId;
const deleted = await stripe.subscriptions.del(subscriptionId);
console.log("Subscription successfully canceled");
} catch (error) {
console.error("Error canceling subscription:", error);
}
} catch (error) {
console.error("Error handling chargeback:", error);
}
}
if (eventType === "checkout.session.completed") {
try {
("Checkout session completed!");
const customer = await stripe.customers.retrieve(data.customer);
// Add to database
const id = customer.metadata.id;
const ref = db.collection("users").doc(id);
const get = await ref.get();
const userData = get.data();
const updatedData = {
...userData,```
Above you'll find my webhook
At the moment I cannot test chargebacks the development / testing area
And im already in production with this code
you need to pass data.customer.id
Where?
const customer = await stripe.customers.retrieve(data.customer);
The customer object isn't included in the webhook call, as it is in the checkout.session.completed (as I understood from your colleague)
const customer = await stripe.customers.retrieve(charge.customer.id);
I see
So do I need to edit one line ?
const customer = await stripe.customers.retrieve(charge.customer) -->
const customer = await stripe.customers.retrieve(charge.customer.id);
both lines where you do stripe.customers.retrieve
The checkout function works good actually if you mean that one
Its the dispute handler thats not working
then yes