Git Product home page Git Product logo

Comments (13)

DCSnip3r avatar DCSnip3r commented on June 8, 2024 1

@dackers86 I believe they turned on merge:true so this is feasible to accomplish now. The general solution for this issue is to create function triggers that watch document writes that the extension initiates. I'm fine to close this

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on June 8, 2024

Hey @leetworx, yes, the function syntax is different for normal Firebase Cloud Functions: https://firebase.google.com/docs/functions/http-events

from stripe-firebase-extensions.

leetworx avatar leetworx commented on June 8, 2024

Ah, so this is a distinction between cloud functions and firebase extensions? Thanks very much for the clarification - got it working!

from stripe-firebase-extensions.

mshenawy22 avatar mshenawy22 commented on June 8, 2024

@thorsten-stripe @leetworx I want to customize the create user functions so it also stores the phone number and email of the user inside the Customer document.
Shall I configure the index.js in the src folder or the index.js in the lib folder. and what is the difference between the two.

Thanks very much

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on June 8, 2024

@mshenawy22 you cannot modify the extension, but you can deploy your own additional Cloud Functions to run alongside the extension. With version 0.1.7 (to be released this week), you can disable the automatic syncing (see https://github.com/stripe/stripe-firebase-extensions/blob/next/firestore-stripe-subscriptions/CHANGELOG.md#version-017---2020-10-15) and instead you write your own function to manage the customer details in Cloud Firestore. The extension will not overwrite your customer data in Cloud Firestore but rather merge in the stripe data when needed.

from stripe-firebase-extensions.

mshenawy22 avatar mshenawy22 commented on June 8, 2024

@thorsten-stripe :
Why I can't modify the extension , if I downloaded your extension source code then added a function in the index.js that makes use of local functions and variables in the file ,then deployed that new function only , why won't this work?

Disabling the automatic syncing won't help in my case and I'm sure in many other cases .
for ex : There are two type of users, paying customer and service receiving customer. I want to create a Customer document only for the paying customer who register through a certain page on the web , hence an HTTP triggered google function is needed.if non paying customer has signed up , I don't want a stripe customer document to be created for them.

It would be great if you made the syncing function configurable , specially what triggers it .

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on June 8, 2024

@mshenawy22 sorry, this slipped through the cracks.

Why I can't modify the extension , if I downloaded your extension source code then added a function in the index.js that makes use of local functions and variables in the file ,then deployed that new function only , why won't this work?

Developing extensions is currently still in closed alpha. While the source code for the extensions is public as a reference, it is not possible for you to deploy an extension from a local code base to your Firebase project.

But you don't need to. You can simply write your own Cloud Functions to run next to the extension.

It would be great if you made the syncing function configurable , specially what triggers it .

By turning off the automatic sync of the extension, you are completely free to write your own function with your own desired trigger to create your customer documents. The extension will then create a Stripe customer object on the fly when you create the first checkout session for a given user and simply merge the Stripe specific data in your user doc. So you have complete control over how you manage your users.

from stripe-firebase-extensions.

Apsistec avatar Apsistec commented on June 8, 2024

@mshenawy22 sorry, this slipped through the cracks.

Why I can't modify the extension , if I downloaded your extension source code then added a function in the index.js that makes use of local functions and variables in the file ,then deployed that new function only , why won't this work?

Developing extensions is currently still in closed alpha. While the source code for the extensions is public as a reference, it is not possible for you to deploy an extension from a local code base to your Firebase project.

But you don't need to. You can simply write your own Cloud Functions to run next to the extension.

It would be great if you made the syncing function configurable , specially what triggers it .

By turning off the automatic sync of the extension, you are completely free to write your own function with your own desired trigger to create your customer documents. The extension will then create a Stripe customer object on the fly when you create the first checkout session for a given user and simply merge the Stripe specific data in your user doc. So you have complete control over how you manage your users.

If you look in Google Cloud Functions Reports you can see the raw files and make changes there or copy them into your IDE and work on them from there. What is great about it is they have already done the heavy lifting, so be sure to appreciate them for providing this to us. It is quite amazing.

from stripe-firebase-extensions.

mshenawy22 avatar mshenawy22 commented on June 8, 2024

from stripe-firebase-extensions.

DCSnip3r avatar DCSnip3r commented on June 8, 2024

I use a firebase function to create a product using the stripe npm package. This triggers a webhook that creates a product document in firebase.

However, I have additional data that I want to add to the product after I create it with the stripe API. To do this, I can write to a firebase using the product ID that the stripe module returns, and using 'set' with {merge:true}.

This will work fine if the webhook fires and creates the product before this line of my code executes, but if it fires after I think it will overwrite the meta data I want to add. Is it possible to turn on {merge:true} for the product creation that fires on the stripe product.created webhook?

Otherwise, a workaround is I can set these product details with a new function that triggers on firestore product document creations. This will work only if the webhook-driven product doc creation is never faster than the response from calling the Stripe API product creation function plus an unrelated document write for querying the reference later

from stripe-firebase-extensions.

thorsten-stripe avatar thorsten-stripe commented on June 8, 2024

@DCSnip3r I'd recommend that you add your additional data to the metadata on the product object (either when you create it or later on via an updat request), that's automatically synced to the Firestore:
image

from stripe-firebase-extensions.

DCSnip3r avatar DCSnip3r commented on June 8, 2024

@thorsten-stripe Does this work with data types like a firestore geopoint? This should generally work, thank you. One disadvantage is the 'stripe_metadata_' prefix. I personally would not be confused if this were removed

from stripe-firebase-extensions.

dackers86 avatar dackers86 commented on June 8, 2024

HI @DCSnip3r.

Is this issue something that needs to be consider. Or you happy for me to close?

from stripe-firebase-extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.