Example Use Case: Adding Carbon Offsetting to Checkout
Suppose that you have an existing checkout page that customers use to pay for their flights. How would you go about adding carbon offsetting to your checkout process?
Let's assume that you would like to allow your customers to offset flights at 50%, 100%, or 150% of the total carbon emitted during the flight. This means that you will need to show the customer the amount of carbon that will be emitted, allow them to choose what, if anything, to offset, and then record and offset the emission depending on the customer decision.
1. Estimating Emissions Before Checkout is Complete
Since in this case we need to show the user the total carbon emitted before checkout is complete we probably don't want to record the emission yet. This is because the customer may back out- we only want to record an emission when a flight actually happens. To get an estimate of the emissions for a flight without making a record, we can use /api/emissions/estimate
. By passing in the tail number, flight duration, and (optionally) the fuel type, we can get an estimation of the total carbon that will be emitted on this flight.
Note that in order to pass in the tail number, we need to have uploaded our aircraft to the DynoFlight system. You can do this with a POST to the /api/fleet
endpoint. Here you can specify the aircraft model from our supported model types, as well as (optionally) specify the fuel type typically used by the aircraft (defaults to 'Jet A').
Now that we have an estimate of the carbon that will be emitted, we can show the user and ask them how much, if any, they would like to offset. How you do this is up to you: a slider to determine percentage, a checkbox, or anything else.
2. Customer Checkout
Once the user decides to proceed to checkout and chooses to offset some portion of the flight's emissions, we need to handle the payment for the offset and provision the corresponding CORCs through the API.
We offer two approaches for handling payment and provisioning:
2.a Customer Checkout (Via DynoFlight)
This approach streamlines the checkout process by utilizing the /api/provisions/checkout
endpoint. This endpoint initiates a prepaid checkout process, creating a provision for a selected set of emissions and returning a Stripe Checkout link for payment processing.
To use this endpoint, first POST to /api/emissions
to create a record of the emission for the customer's flight. Once created you can create a new checkout page for the customer with the emission ID you wish to offset, the offset percentage, and an optional redirect URL for after the checkout is complete.
Example POST request to /api/provisions/checkout
:
Upon successful payment, the customer will be redirected to the URL you specify. If no link is provided, they will be redirected to a default DynoFlight 'Thank You' page. After the payment is processed, the provision and certificate will automatically be created and will be accessible in the UI and API. The customer will also receive a verification email generated by us on your behalf to the email provided during the Stripe checkout process.
2.b Customer Checkout (Via your own checkout)
For a more customized experience, you can incorporate the cost of the credits into your existing flight checkout process. After collecting payment, you can provision CORCs through the DynoFlight API by first POSTing to /api/emissions
to create a record(s) of the emission followed by POSTing to/api/provisions
with the amount of offset you provisioned on behalf of your customer. Finally, link any associated emission with the provision by PUTting to /api/provisions/{provision_id}/emissions
with your emission ID. This ensures that the customer's certificate and your records in the DynoFlight portal display the associated flight and emission details.
Note that you will be invoiced at the end of the month for any provisions made through the API in this way. If you would like to have the customer checkout through DynoFlight see 2.a.
You'll receive a certificate link in the response to the provision requests which can be shared with the customer. This certificate will show the status of the provision and any associated emissions.
Last updated