I am using the Enupal Stripe Payments plugin to pass line items to Stripe. The line items get passed in an array. I want to use a javascript cart to hold the items in local storage, reformat that and then send them to the twig array that will eventually be sent to Stripe.
I have reformatted the JSON from local storage using javascript and can see the output in my console. How can I include that javascript inside the twig array? I have read some vague feedback about using AJAX for this but I do not fully understand how to accomplish that or if it is the correct solution for this use case.
Stripe TWIG array example:
{% set options = {
lineItems : MY JAVASCRIPT GOES HERE
} %}