У меня возникли трудности с передачей общей суммы с html на полосу. У меня есть тележка, чья сумма рассчитывается в cart.js. Я показываю его из index.php. Я хочу взимать общую сумму, которая равна сумме корзины с помощью Stripe. Я не уверен, как передать сумму checkout.php.Как передать корзину общую сумму от html/php to Stripe, где общая сумма тележки вычисляется JS
checkout.php
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create a Customer
$customer = \Stripe\Customer::create(array(
"source" => $token,
"description" => "Example customer")
);
// Charge the Customer instead of the card
\Stripe\Charge::create(array(
"amount" => $amount, // Amount in cents
"currency" => "usd",
"customer" => $customer->id)
);
index.php
<div class="total">
<p class="value">
<!-- value inserted by js -->
</p>
<p class="label">Total</p>
</div>
<form action="./checkout.php" method="post">
<script src="https://checkout.stripe.com/checkout.js"
class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-image="https://something.png"
data-name="nairteashop.org"
data-description="Send lots of love"
data-billing-address="true"
data-label="Checkout"> </script>
</form>
cart.js
var $bagTotal = $('.total .value');
$bagTotal.addClass('total_price');
$bagTotal.text('$' + getTotalPrice(items));