stripe-firebase-extensions
stripe-firebase-extensions copied to clipboard
Add documentation for executing custom functions.
Bug report
- Extension name: [e.g.
firestore-stripe-payments
]
Describe the issue
I just setup Firebase Stripe Extension for my Web App. Everything goes fine. But I am struggling to add few custom functionality. I want to add some token balance for every successful subscription.
E.g.
5USD / Month - 2000 Token 19 USD/ Month - 50000 Token
And these token should be used to call an external API.
I think I can use Eventarc for that. But I don't find any documentation for that. Can anyone point me that please.
Well, I found it later that until I turn on the events on configuration page I am unable to see the dispatched events by the extension.
com.stripe.v1.product
created: Occurs whenever a product is created
updated: Occurs whenever a product is updated
deleted: Occurs whenever a product is deleted
com.stripe.v1.price
created: Occurs whenever a price is created
updated: Occurs whenever a price is updated
deleted: Occurs whenever a price is deleted
com.stripe.v1.checkout.session
completed: Occurs when a Checkout Session has been successfully completed
async_payment_succeeded: Occurs when a payment intent using a delayed payment method finally succeeds
async_payment_failed: Occurs when a payment intent using a delayed payment method fails
com.stripe.v1.customer.subscription
created: Occurs whenever a customer is signed up for a new plan
updated: Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active)
deleted: Occurs whenever a customer's subscription ends
com.stripe.v1.tax_rate
created: Occurs whenever a new tax rate is created
updated: Occurs whenever a tax rate is updated
com.stripe.v1.invoice
paid: Occurs whenever an invoice payment attempt succeeds or an invoice is marked as paid out-of-band
payment_succeeded: Occurs whenever an invoice payment attempt succeeds
payment_failed: Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method
upcoming: Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings
marked_uncollectible: Occurs whenever an invoice is marked uncollectible
payment_action_required: Occurs whenever an invoice payment attempt requires further user action to complete
com.stripe.v1.payment_intent
processing: Occurs when a PaymentIntent has started processing
succeeded: Occurs when a PaymentIntent has successfully completed payment
canceled: Occurs when a PaymentIntent is canceled
payment_failed: Occurs when a PaymentIntent has failed the attempt to create a payment method or a payment.
Example.
const {onCustomEventPublished} = require("firebase-functions/v2/eventarc");
const logger = require("firebase-functions/logger");
const {initializeApp} = require("firebase-admin/app");
const {getFirestore} = require("firebase-admin/firestore");
exports.onimageresized = onCustomEventPublished(
"com.stripe.v1.customer.subscription.created",
async (event) => {
//whatever
logger.info(event);
});
@dbjpanda Can you clarify what the ask is here? Unsure how this relates specifically to one of the Firebase extensions.
@jsteele-stripe
I am developing a chrome extension and trying to add in-app credits in terms of tokens to call an external api.
Each query consumes some tokens.
E.g. My pricing are like :
5USD / Month - 2000 Token 19 USD/ Month - 50000 Token
And these token should be used to call an external API, and deduct the token as per actual usage.
Confusion
I tried Standard Pricing model and custom event listener on com.stripe.v1.customer.subscription.updated
to add/delete/update token on customer document. Everything works fine until a user upgrade or downgrade a subscription and price adjusted based on prorated "time". But in my case, the prorated adjustment should be based on "Tokens".
My thoughts to use package based pricing but how do I send the usage report to Stripe using this extension?
Or how can I update the subscription without using portallink? Because portal link have time based proration.
Any idea, how can I achieve it?
@dbjpanda, I'm also stuck on it. I'm new to Eventarc and all gcp events. I saw the same documentation, but I think something more concrete should help because I got the code example but don't know where and how to deploy it.
Did you find something interesting?
I am running into the same issue. It seems like the function isn't getting triggered and there doesn't seem to be a way to check if the events are actually being published by the stripe extension.
I am running into the same issue. It seems like the function isn't getting triggered and there doesn't seem to be a way to check if the events are actually being published by the stripe extension.
I'm facing the same issue
I'm getting the same issue. The events are being published by stripe, but the functions are not being triggered as they don't have the relevant permissions.