Giter VIP home page Giter VIP logo

Comments (3)

codediodeio avatar codediodeio commented on June 3, 2024 1

Thanks for opening the issue. There were some minor breaking changes in v1.0 of Cloud Functions. I will be setting aside some time to migrate everything this week.

from angular-firebase-stripe.

pdemilly avatar pdemilly commented on June 3, 2024

Found this on firebase change.log

Firebase SDK for Cloud Functions Migration Guide: Beta to version 1.0
Version 1.0.0 of the Firebase SDK for Cloud Functions introduces some important changes in the API. The primary change, a replacement of event.data format with data and context parameters, affects all asynchronous (non-HTTP) functions. The updated SDK can also be used with firebase-functions-test, a brand new unit testing companion SDK. See Unit Testing Functions for more information.

Authentication
In earlier releases, event.data.metadata contained the deprecated fields createdAt and lastSignedInAt. Version 1.0 removes these fields completely and replaces them with creationTime and lastSignInTime fields in the userRecord.metadata parameter.

Before (<= v0.9.1)

// This code won't work with Cloud Functions SDK 1.0 and higher!
exports.authAction = functions.auth.user().onCreate((event) => {
const userMetadata = event.data.metadata;

const creationTime = userMetadata.createdAt; // 2016-12-15T19:37:37.059Z
const lastSignInTime = userMetadata.lastSignedInAt; // 2018-01-03T16:23:12.051Z
}
Now (v1.0.0)

exports.authAction = functions.auth.user().onCreate((userRecord, context) => {
const creationTime = userRecord.metadata.creationTime; // 2016-12-15T19:37:37.059Z
const lastSignInTime = userRecord.metadata.lastSignInTime; // 2018-01-03T16:23:12.051Z
}

Therefore I think the function

export const createStripeCustomer = functions.auth
    .user().onCreate((event) => {

should be replaced by:

export const createStripeCustomer = functions.auth
    .user().onCreate((user, context) => {
       const userRef = db.collection('users').doc(user.uid);
       return createCustomer(user)
            .then(customer => {
             
                /// update Firestore with stripe customer id
                const data = { stripeCustomerId: customer.id }
                return userRef.set(data, { merge: true });
            })
            .catch(console.log)

from angular-firebase-stripe.

codediodeio avatar codediodeio commented on June 3, 2024

You're exactly right, I have updated the auth function for v1.0.

from angular-firebase-stripe.

Related Issues (7)

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.