stripe-firebase-extensions
stripe-firebase-extensions copied to clipboard
Using subscription extension without firebase auth directly
Feature request
I would like to use the extension without linking users to the firebase-auth record, because we're using custom authentication and even though the user or customer record has the email, when calling getUser there will be no email returned. This currently causes the email from not being sent to stripe and being cleared inside of the customer record. Would you be interested in accepting a PR for this change?
Is your feature request related to a problem? Please describe.
The extension is assuming that the email is stored within firebase auth. This is not necessarily true when using custom authentication.
Describe the solution you'd like
I would like the connection of the subscriptions extension to firebase-authentication to be optional. It already doesn't attempt to update the custom claims if the stripeRole isn't defined, but it still is unable to read the email from the existing custom record.
Describe alternatives you've considered
The only place that would need to be changed is (sample implementation, there might be a cleaner way to do this and it should probably handle the case where getUser fails in any case.
let customerRecord = (await snap.ref.parent.parent.get()).data();
if (!customerRecord?.stripeId) {
let email = customerRecord && customerRecord.email;
if (!email) {
({ email } = await admin.auth().getUser(context.params.uid));
}
customerRecord = await createCustomerRecord({
uid: context.params.uid,
email,
});
Additional context
The other place that would be interesting is to support JSON inside of the metadata fields. In my case one of the metadata fields should contain an array of strings and currently there is no JSON.parse happening when storing stripe metadata inside of firestore.
I am also running into a similar situation. In my case, the subscription is not tied to a user, but rather an 'organization'
Same situation here
Hello, did you guys succeed using this extension without firebase auth?. @anargu @austinn0 @richtera
We use a fork of the repo
On Tue, Oct 11, 2022 at 10:11 AM dorjsurend @.***> wrote:
Hello, did you guys succeed using this extension without firebase auth?. @anargu https://github.com/anargu @austinn0 https://github.com/austinn0 @richtera https://github.com/richtera
— Reply to this email directly, view it on GitHub https://github.com/stripe/stripe-firebase-extensions/issues/198#issuecomment-1274754219, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFM4WXZDTZTTTCVNR5ROA3WCVYP5ANCNFSM464EWRXA . You are receiving this because you were mentioned.Message ID: @.***>
-- Andreas Richter @.*** 215-518-2619