#Rahim Dobani
1 messages · Page 1 of 1 (latest)
Not sure, it should definitely keep the same customer as far as I am aware.
Can you send me an example ID of a customer that was created this way?
{
"customer": {
"id": "cus_OiQ7ePwf0w6YSb",
"object": "customer",
"address": null,
"balance": 0,
"created": 1695827013,
"currency": null,
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": "rahim@gmail.com",
"invoice_prefix": "24914D6F",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": "rahimdobani",
"next_invoice_sequence": 1,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
},
"success": true
}
this is response
{
"customerID": "cus_OiP3YL5RVYNpnU",
"email": "rahim@gmail.com",
"name": "rahimdobani"
}
this is req params i am giving
its changing customer id
and creating new customer
?
In our logs, it looks like both of those accounts were created via a standard create account call, not from an update call
https://dashboard.stripe.com/test/logs/req_tgENxYsrID2XQ4
https://dashboard.stripe.com/test/logs/req_tgENxYsrID2XQ4
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Can you do a quick test for me? If you spin up another node project quickly and just run the customer update function and nothing else, is a new customer still created?
Whats the right api to update customer email and name?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
How to i pass email and name to be update?
const customer = await stripe.customers.update(
customerID,
{metadata: {email,name}}
);
like this or this
const customer = await stripe.customers.update(
customerID,
email,
name,
);
?
customerID,
email: email,
name: name,
);```
The doc that I linked to shows the parameters that are available for that method
its not working like this
Can you tell me more about how it is not working?
Are you getting a specific error?
const customer = await stripe.customers.update(
customerID,
email: email,
name: name,
);
its giving me syntax error
Can you send me the full text of the syntax error?
SyntaxError: missing ) after argument list
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (/Users/rahimdobani/Documents/Node js/Webhook/routes/nocoDB.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
// console.log(req.body)
let token = req.headers['x-access-token'] || req.headers['authorization'];
// Remove Bearer from string
token = token ? token.replace(/^Bearer\s+/, "") : "";
if (token === process.env.BEARER_TOKEN) {
const email = req && req.body && req.body.email
const name = req && req.body && req.body.name
const customerID = req.body.customerID
try {
const customer = await stripe.customers.update(
customerID,
email: email,
name: name,
);
res.status(200).send({ customer: customer, success: true, });
} catch (err) {
// response.status(400).send(`Webhook Error: ${err.message}`);
console.log(err);
res.status(500).send({ message: "Please try again", error: err, success: false, });
return;
}
}
else {
res.status(200).send({ success: false });
}
this is code
Ah apologies, it looks like the syntax is
'cus_1234',
{
description: '(created by Stripe Shell)',
name: 'Jenny Rosen',
email: 'example@website.com',
}
);```