1
合計金額をHTMLからストライプに渡すのが難しいです。私はcart.jsで合計が計算されるカートを持っています。私はindex.phpから表示しています。私は、ストライプを使用してカートの合計金額を請求します。私はcheckout.phpに量を渡す方法がわかりません。カートの合計金額をhtml/phpからストライプに渡す方法。
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));