← Back to blog

Stripe Firebase Extension (October Release)

Darren Ackers

Lead Developer

24th October, 2023

Need a custom tool? Invertase can help

Tired of investing in off-the-shelf software that doesn't quite fit your business? Invertase can build solutions tailored to your exact needs. Tell us what you're looking for here and we'll be in touch.

Introduction

We are excited to announce many new features and improvements to the Firestore Stripe Payments Extension. This blog post aims to walk you through these updates, including support for the flow_data parameter in the createPortalLink function, creating Stripe customers on-the-fly with portal links and customisable payment methods options when making payments.

Firestore Stripe Payments

This month, we have many new features provided by the community. And so a huge thank-you to all contributors who made this release possible!

Let’s delve deep into what the latest release has in store for us…

Support for the flow_data Parameter

The createPortalLink function now supports the flow_data parameter, allowing you to customize Stripe’s customer portal sessions further.

This can be added based on the following example onCall function:

/** Create a function reference */
const functionRef = firebase
  .app()
  .functions('us-central1')
  .httpsCallable('ext-firestore-stripe-payments-createPortalLink');

const { data } = await functionRef({
  returnUrl: window.location.origin,
  locale: "auto", // Optional, defaults to "auto"
  configuration: "{{portal_ID}}", //optinal portal config Id
  flow_data: { // Optional flow data for your portal
    type: 'subscription_cancel',
    subscription_cancel: {
      subscription: '{{SUBSCRIPTION_ID}}',
    },
    after_completion: {
      type: 'redirect',
      redirect: {
        return_url: '<https://example.com/account/subscription_canceled>',
      },
    },
}});

window.location.assign(data.url);

Creating Stripe Customers On-The-Fly with Portal links

Another popular feature request is to allow the auto-creation of the Stripe custom when creating a portal link.

Typically, a Firestore user will automatically synchronise with Stripe when configured through the extension configuration.

While this feature already existed when creating a new checkout session, the feature did not exist when creating portal links.

Based on this community issue, developers are keen to allow this process to take place if a Stripe customer does not yet exist.

As of the latest version, if a Stripe user does not exist, then this will be created, automatically adding the new Stripe customer to the portal Firestore document.

Payment method collection when creating a checkout session

Another new feature is setting payment method collections when creating a checkout session.

By default, the payment_method_collection property will be set to `always.` This can now be overridden when creating the Firestore document:

const docRef = await db
  .collection('customers')
  .doc(currentUser.uid)
  .collection('checkout_sessions')
  .add({
    price: 'price_1GqIC8HYgolSBA35zoTTN2Zl',
    success_url: window.location.origin,
    cancel_url: window.location.origin,
    payment_method_collection: 'always' //always, if_required
  });

Firestore Stripe Invoices

Some minor updates have also been added to the Stripe Invoices extension.

Create invoice refactoring

The codebase has been updated with fixed syntax and assignment errors, leading to a tidier codebase.

Node16 upgrade

With the recent deprecation warning for node16. We are in the current process of progressively upgrading to Node18 and beyond for all extensions. Originally, this extension was on node10 and upgraded along with a few other deployment fixes. Further updates to this and others can be expected in the future!

Housekeeping

As with every project, we endeavour to continue improving the processes involved in maintaining the database. Given this month’s fantastic community contribution, we have introduced the ability to provide your webhooks for testing and a few documentation updates.

Customized webhooks for testing

By providing a new PROXY_URL web-hook, developers can now produce their own proxy based web-hook when developing locally and also when running PRs through the GitHub actions CLI environment. Simply create a proxy of your choice and add the URL to your .env file before running the test suite:

PROXY_URL={PROXY_URL}/{PROJECT_NAME}/{PROJECT_LOCATION}/ext-firestore-stripe-payments-handleWebhookEvents

Updated guide on installing through the CLI

A more helpful guide has been added to the readme for the Firestore Stripe Payments extension; this goes into further detail on how to configure and install from your local machine. Please find the updated guide here.

Conclusion

These updates bring about much-requested features and improvements, making the Firestore Stripe Payments Extension more flexible and efficient.

Thank you for your continued support, and we hope you find these new features beneficial for your projects.

Stay tuned for more updates and exciting news that we will share in the future. Follow us on Invertase TwitterLinkedin, and Youtube, and subscribe to our monthly newsletter to stay up-to-date. You may also join our Discord to have an instant conversation with us.

Darren Ackers

Lead Developer

Categories

Tags