Charging your electric vehicle is meant to be quick and hassle-free – just pull up to a station, plug in, and be on your way in minutes. But behind this seamless customer experience lies a complex orchestration of payment processing, security, and invoicing. Levi9’s .NET Tech Lead Mihaela Rădulescu and her team recently brought this frictionless process to life for a startup electrical car charging platform. The solution demanded the agility of a startup build, the security and reliability required when handling payments, and the automation needed to minimize operational costs. Stripe was the answer. It handles the payments and invoicing for the platform, and was chosen for its rapid integration, robust fraud protection, and automatic billing capabilities.
The Levi9’s customer’s platform connects Electric Vehicle (EV) charging stations with Electric Vehicle drivers. Charging station owners can manage and monitor their stations through the platform. Meanwhile, electric car drivers can find stations, track charging sessions, and more. At the end of each month, the platform needs to bill station owners, as well as EV drivers for usage.
With chargers having their own dynamic per kilowatt-hour rates that change frequently, and rates that vary based on time of day, Stripe was the ideal solution. “Nothing fits your use case 100%,” says Mihaela Rădulescu, who led the integration between the platform and payment processor Stripe. But Stripe came pretty close. “We needed a payment processor that could handle variable rates and automatically charge both end-users and charging station managers at the end of each month,” explains Mihaela.
Here’s an inside look at how Stripe works and how our client, an EV charging management company, integrated it into their platform.
Step 1: Stripe as a payment processor provider
Stripe acts as the payment gateway and processor, taking card data and routing it to the appropriate bank. A key advantage to Stripe is that it can be integrated with a customer’s platform, while allowing card data to go directly from the client to Stripe. “This means card data never reaches our servers, which saves us from all the time and effort needed to ensure PCI (Payment Card Industry Data Security Standard) compliance requirements are met and then upheld,” revealed the Levi9 .NET Tech Lead.
To process payments, Stripe offers both its own check out page, as well as a library of pre-built components called Elements that integrate directly with Stripe.js. Elements allow website designers to better integrate the look and feel of their service during the payment process, while routing all sensitive data to Stripe directly.
Step 2: Creating customers and payment methods
When electric car drivers sign up for the charging platform, the app uses the Stripe Elements to securely collect their card details and create a Customer and Payment Method in Stripe. “This happens directly from our front end to Stripe without card data ever reaching our servers,” emphasizes Mihaela.
Step 3: Usage tracking
As drivers use charging stations, the platform tracks their usage in real-time. The platform receives “usage events” that contain station identification, start time, end time, and kilowatt-hours. Rates depend on the charging station location (city centers cost more than outskirts). Rates also vary based on time of day (peak hours vs. night). The platform matches each usage session with the correct rate.
One particular challenge during this process was finding a way to bill fractionary charging, as Stripe does not allow “product quantities” to be fractionary themselves. Some ingenuity was required from the development team at this point and they came up with the solution of billing watt-hours instead of kilowatt-hours.
Step 4: Generating invoices
At the end of the month, the EV charging platform totals each user’s power usage and generates invoices through Stripe’s API. The invoices contain line items with the Wh quantity and unit price. Stripe calculates total costs from there and handles tax calculation.
“We just provide the usage data and Stripe takes care of invoicing and payment,” explains Mihaela.
Stripe also manages a second type of invoice. The EV platform is also billing charging station owners, who use the platform to get an up-to-date overview of their stations, to manage them and associate different rates according to their business strategy.
Step 5: Getting paid
Payments are automatically processed by Stripe within a maximum of one hour after invoicing. The payment process can be triggered by making an explicit call to the Stripe API, but the Levi9 development team preferred to allow Stripe to automatically withdraw the money from the payment card on the file. Failed payments, which sometimes happen, are automatically retried by Stripe.
For failed payments, Stripe also issues a notification, through a webhook, towards the charging platform, keeping them in the loop about the status of payment. These real time webhook updates are not limited to errors, but are sent throughout the entire process, for each event, such as successful charges and payment intents. These notifications allow the platform to always keep client data in sync.
While Stripe solved critical needs for all stakeholders, the process was not without challenges for the development team. A key lesson was around Stripe’s many options for billing. For example, subscription versus usage-based billing. Subscriptions provide ongoing charges based on fixed plans. But with dynamic per Wh pricing, subscriptions were not practical. “We had to get creative in using usage-based billing along with invoice line items and webhooks to implement a variable pricing model.”
For any company dealing with online payments, especially variable payments on-the-go, Stripe provides great advantages. By allowing the Levi9 team to successfully integrate a payment provider that lifts off the burden of financial regulations and automates invoicing and withdrawals, the start-up EV platform was able to focus on bringing the best experience to its customers and making a more sustainable, environment-friendly future possible.