Ajax passing JS variable to PHP Stripe SCK to set amount dynamically

You can create a route which when hit through ajax and a form will send the variable through the JS . Something like:

c::set('routes', array(
    array(
        'pattern' => 'products/(:any)/charge',
        'method' => 'POST',
        'action'  => function() {
            stripeCheckout();
        },
    ),
));