I am trying to create custom payments using stripe API.
I would like the user to be able to input any number for a payment within a form and have my php get the input to charge the card for the selected amount.
In my php code the "amount is usually set to a fixed number like 50.00" but I would like it to be dependent on the users input in the html form.
Here is what I have so far.
Thanks
<form action="testprocess.php" method="POST">
<h3> Enter Payment Amount</h3>
<input type="number" name="pay" id="pay">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_00000000000"
data-amount=""
data-name="test"
data-description="text">
</script>
</form>
___________________
<?php
// See your keys here: asgfcvbjh
\Stripe\Stripe::setApiKey("sk_test_0000000000000");
// Token is created using Stripe.js or Checkout!
// Get the payment token submitted by the form:
// Charge the user's card:
$pay = $_POST['pay'];
$charge = \Stripe\Charge::create(array(
"amount" => $pay,
"currency" => "usd",
"description" => "test",
));
?>
You can do it the following way, you have to create a custom checkout. Credit goes to this guy.
Output