Stripe social security number nodejs - javascript

What parameter do I need to send social security numbers to Stripe when creating a Connected account?
I know how to send the last 4 but what about all of it?
try {
const account = await stripe.accounts.create({
type: 'custom',
country: 'US',
email: "jake#gmail.com",
business_type: 'individual',
individual: {
email: "jake#gmail.com",
first_name: "Jake",
last_name: "Jake",
ssn_last_4: "4241",

You'd want to pass in id_number (which can be the full SSN) or a PII token from Stripe.js.

Related

how to create extra field when capturing checkout in commerce js

i am using commerce js on my website and i want to create an extra field for getting phone number from user but commerce js does'nt have any documentation about extra_field. can any one tell me how to add it
i also created extra field in commerce js dashboard
here is my order data object
const orderData = {
line_items: checkoutToken.line_items,
customer: {
firstname: shippingData.firstName,
lastname: shippingData.lastName,
email: shippingData.email,
},
shipping: {
name: "International",
street: shippingData.address1,
town_city: shippingData.city,
county_state: shippingData.shippingSubdivision,
postal_zip_code: shippingData.zip,
country: shippingData.shippingCountry,
},
fulfillment: { shipping_method: shippingData.shippingOption },
payment: {
gateway: "stripe",
stripe: {
payment_method_id: paymentMethod.id,
},
},
extra_fields: {
contact: shippingData.contact,//its not working
}
};
When capturing the order, provide the extra_fields object with each extra field ID as the key and the value you want to use.
extra_fields: { [extraFieldId]: 'your custom field value' }
from https://commercejs.com/docs/api/?shell#capture-order

Cannot charge a customer that has no active card

So I am getting the error in Stripe that "Cannot charge a customer that has no active cards".
I am using node js for this
Payment Code is given below
try {
const customer = await stripe.customers.create({
email: req.body.email,
source: req.body.id,
});
const payment = await stripe.charges.create(
{
amount: req.body.totalAmount * 100,
currency: "inr",
customer: customer.id,
receipt_email: req.body.email,
confirm: true,
off_session: true,
},
{
idempotencyKey: uuidv4(),
}
);
And I am getting the following error
type: 'StripeCardError',
raw: {
code: 'missing',
doc_url: 'https://stripe.com/docs/error-codes/missing',
message: 'Cannot charge a customer that has no active card',
param: 'card',
type: 'card_error',
}
Log out req.body.id as that might be null and then investigate why your frontend is not passing that parameter to your backend.
Second, confirm and off_session are not supported parameters on the /v1/charges endpoint.

Firebase & website relationship information scramble

enter image description hereI just connected my website to firebase to login users but seems to me whenever a user registers on my website the information they put into my website gets scrambled the moment it enters firebase database
this is my code snippet of the js file
//save message to firebase
function saveMessage(Name, Surname, Email, Number, Country, Verpasswrd, Username, Birthday) {
var newMessageRef = messagesRef.push();
newMessageRef.set({
Name: Name,
Surname: Surname,
Birthday: Birthday,
Email: Email,
Number: Number,
Country: Country,
Gender: Gender,
Verpasswrd: Verpasswrd,
Passwrd: Passwrd,
Username: Username,
})
}`
[![firebase output result][2]][2]

How do I define whether a parameter is required or not using Axios?

I'm creating an Axios request function where I have a looot of parameters for the body request. Most are required, but some are not. What's the best way to handle this?
createAccount(username, first_name, last_name, email, language, client_name, client_email, website_url, street, city, code, country, language, lead_source, date_picker) {
return this.axiosInstance.post('/brands/image', {
username: username,
first_name: first_name,
last_name: last_name,
email: email,
language: language,
client_name: client_name,
client_email: client_email,
website: website,
street: street,
city: city,
code: code,
country: country,
lead_source: lead_source, // non-required
date_picker: date_picker, // // non-required
})
.catch(error => {
console.log("Error: ", error)
})
}
There are two basic approaches you can take:
Read the API documentation of the web service you are making requests to (which could be designed for humans or might be a machine readable JSON schema or similar)
Trial and error
There's no way for the client to know what the server cares about.

MongoDB + Mongoose: $set only if given key does not exist or have falsy value

I need a help on a findOneAndUpdate({upsert: true}) query:
got this shchema:
usersSchema = new Schema(
{
name: {type: String, unique: true, uniqueCaseInsensitive: true}, // username
password: {type: String, minlength: 4},
slug: {type: String, unique: true, uniqueCaseInsensitive: true}, // ok - Automatic on backend - based on name
firstName: {type: String},
middleName: {type: String},
lastName: {type: String},
email: {type: String, unique: true, uniqueCaseInsensitive: true},
//country: {type: String, required: true, minlength: 3}
socialIDs: {
facebook: {
id: {type: String, unique: true}
},
twitter: {},
google: {}
}
}
when user is new, creating account using facebook (with passportjs), the data of firstName, lastName, email, etc are populated with facebook retrieved data. if the user has created his account via local strategy, those fields may be non-existent and, the first time he log in with facebook, they got populated (updating profile).
perfect.
lets say now, the user update manually his profile via online form, BEFORE log in with facebook his first time, and set up a e-mail address (different from the associated with his facebook account).
when he log in with his facebook, the email address will be overwritten with the one retrieved from his facebook account.
is there a way to set the findOneAndUpdate() method to only insert keys that are non-existent (or maybe values on given key default falsy value)?
maybe combining $set with $exists operators somehow (I have tried this, but could not figure out correct syntax)
the query I am using is the following:
User.findOneAndUpdate(
{
$or: [
{email: profile._json.email},
{socialIDs: {facebook: {id: profile._json.id}}}
]
},
{
$set: {
firstName: profile._json.first_name,
middleName: profile._json.middle_name,
lastName: profile._json.last_name,
avatar: profile._json.picture,
gender: profile._json.gender,
email: profile._json.email,
socialIDs: {
facebook: {
id: profile._json.id,
profileLink: profile._json.link,
}
}
}
},
{new: true, upsert: true},
function(err, user){
done(err, user)
});
thanks guys!
there's no conditional $set, however, if the user has already created an account and he has to provide his email when he does, then logging in with Facebook shouldn't overwrite it, which means you can remove the email from the $set operator.
Once you have this, you are left with the use case where a user has not signed up yet (upsert), in that case, you can use $setOnInsert to only in that scenario set the email.

Categories