Reputation: 829
I'm getting this error message every time I try to create an external account for my custom stripe user.
Here's my actual function:
exports.createExternalAccount = functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
const source = event.data.val();
console.log('SOURCE', source);
if (source === null) return null;
return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {
return snapshot.val();
}).then(customer => {
console.log('CREATE EXTERNAL FOR COSTUMER', customer);
const source = event.data.val();
return stripe.accounts.createExternalAccount(customer,{
external_account: source
});
});
});
I tried to add a currency, but still not working:
exports.createExternalAccount = functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
const source = event.data.val();
console.log('SOURCE', source);
if (source === null) return null;
return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {
return snapshot.val();
}).then(customer => {
console.log('CREATE EXTERNAL FOR COSTUMER', customer);
const source = event.data.val();
return stripe.accounts.createExternalAccount(customer,{
external_account: source,
currency: 'usd'
});
});
});
Does anybody know how to solve it?
This is my payment source function
exports.addPaymentSource = functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
const source = event.data.val();
if (source === null) return null;
return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {
return snapshot.val();
}).then(customer => {
return stripe.customers.createSource(customer, {source});
}).then(response => {
return event.data.adminRef.parent.set(response);
}, error => {
return event.data.adminRef.parent.child('error').set(userFacingMessage(error)).then(() => {
return reportError(error, {user: event.params.userId});
});
});
});
Upvotes: 1
Views: 314
Reputation: 1146
When you're making the Create a Source request, ideally through Elements or Stripe.js/v3, you should also pass a currency
-argument.
Upvotes: 1