Можно ли проверить, совпадает ли сумма, которую видит клиент, и сумма, которую видит сервер?
Здесь я выставляю сумму на стороне клиента:
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton">Purchase</button>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_1002UFB11gJ1sXBHcdDM8HPi',
image: '/square-image.png',
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Demo Site',
description: '2 widgets ($20.00)',
amount: 2000
});
e.preventDefault();
});
// Close Checkout on page navigation
window.addEventListener('popstate', function() {
handler.close();
});
</script>
Я отправляю токен из обратного вызова полосы на стороне клиента на сервер:
<?php
require_once(dirname(__FILE__) . '/config.php');
$token = $_POST['stripeToken'];
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => 1000000000000,
'currency' => 'usd'
'email' => '[email protected]',
'card' => $token
));
echo '<h1>Successfully charged $2!</h1>';
?>
Номер на стороне клиента явно ниже, чем на стороне сервера, и полоса взимает плату за номер на стороне сервера.