Starting a Session with Wallet Payments
Introduction
Developers can now start a session using the user wallet as a source of payment. eDRV's session handles the rest seamlessly.
Availability Regions
The organization will be required to create and configure a stripe account and it is only available in the US at the moment.
Starting a Session
Developers can start a session by calling the POST /sessions API with an additional property type = wallet.
{
"type": "wallet",
"connector": "63d3a7662a035a1c9ac1356e",
"user": "603763d392204c0c840578be"
}
Error Conditions
eDRV checks the user's wallet before a session can be started. The following error responses can be expected:
a. 405 Invalid user Wallet
If the user does not have a wallet, the API will return aUser does not have a wallet error with a 405 status code.
b. 405 Insufficient Minimum Balance
The user needs to have a minimum balance >= organization.configurations.session (by default this is set to 2000) to start a session otherwise, the API will return User does not have minimum balance error with 405 status code.
c. 405 Wallet/Connector Currency mismatch
If the connector.rate.currency is not the same as wallet.currency, eDRV will return a Wallet currency does not match the rate currency error with 405 status code.
Successful Session Attempt
If the checks above succeed, eDRV will attempt to start a charging session with payment.type = api_wallet, payment.authorized_amount = wallet.balance and payment.status = authorized. (eDRV will also send payment.created and payment_authorized webhook events along with session.created)
{
"_id": "63dcf32e7d291b1b005284ac",
"payment": {
"_id": "63dcf32e7d291b1b005284aa",
"session": "63dcf32e7d291b1b005284ac",
"currency": "usd",
"authorized_amount": 160.72,
"type": "api_wallet",
"status": "authorized",
"createdAt": "2023-02-03T11:42:38.440Z",
"updatedAt": "2023-02-03T11:42:38.440Z"
},
"type": "wallet",
"user": "603763d392204c0c840578be",
"chargestation": "63dccb1691f36e2e26c478b5",
"connector": "63d3a7662a035a1c9ac1356e",
"status": "created",
"createdAt": "2023-02-03T11:42:38.682Z",
"updatedAt": "2023-02-03T11:42:38.682Z"
}
On Session End
When the session ends, the payment.status will be updated to succeeded and a payment.captured webhook will be sent along with wallet.updated.
Pausing a Session
Developers can pause or resume an ongoing session by calling the following APIs. (All OCPP-compliant chargestations ought to support this feature).
- The GET /sessions/:id/pause API will stop the energy flow and trigger a session.paused webhook event.
- The GET /sessions/:id/resume API will start the energy flow and trigger a session.resumed webhook event.
Ending a Session
There is no API to stop a session when the rate attached to a session has a PARKING_TIME component in which case, it can only be stopped in the following two scenarios.
- The user/driver detaches the cable from the charging station.
- When the
session.cost.amountis about to exceedpayment.authorized_amounteDRV's session intelligence will attempt to stop an ongoing session to ensure theauthorized_amountis never exceeded.
If the session does not have a PARKING_TIME rate component, it can be stopped by calling the sessions/:id/stop API.
Once the session ends (as reported by the charging station):
- A
session.endedwebhook event will be triggered which will have the final cost of the session. - The system will try to update the wallet balance based on the final session cost and will send
session.payment.capturedwebhook event.
No Session Stops via API when using Overstay Rates
If a session is running on a Rate that has a PARKING_TIME component then you cannot use the Stop API.
In order to accurately calculate the amount of time a driver "overstayed", the session must not be stopped via the API (in this case, the driver removing the connector triggers the charge station to stop the session).
Updated about 1 year ago
