我需要允许用户使用Stripe输入自定义金额.他们输入他们想要输入的内容.然后我有一个脚本收集默认条带结帐按钮下面的金额.但我怎么能在charge.php上处理充电服务器端呢?
donation.php
//user enter custom amount
id="custom-donation-amount"
placeholder="$50.00" min="0" step="10.00 " />
//default stripe checkout button
data-key="pk_test_XXXXXXXXXXXXXXX"
data-amount="0"
data-name="ORGANIZATION"
data-description="Saving Penguins"
data-image="logo.png"
data-locale="auto"
data-zip-code="true"
data-billing-address="true"
data-label="DONATE"
data-currency="usd">
//script to collect variable amount
$(function() {
$('.donate-button').click(function(event) {
var amount = $('#custom-donation-amount').val();
$('.stripe-button').attr('data-amount', amount)
});
});
charge.php
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$customer = \Stripe\Customer::create(array(
'source' => $token,
'email' => $email)
);
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amount,
'currency' => 'usd'
));
header("Location: confirmation.php");
die();
?>
5620

被折叠的 条评论
为什么被折叠?



