PHP - passing custom variables through Stripe

Can I pass custom variables in the Stripe Checkout layout?

This is my form code:

<form action="/includes/api/stripe/charge.php" method="POST">
                  <script
                    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                    data-key="pk_V4y6c4urwnTkLMEVNs0qBIQQJ5Yzu"
                    data-image="/square-image.png"
                    data-name="Demo Site"
                    data-description="2 widgets ($20.00)"
                    data-amount="2000"
                    data-email="<?php echo $userdata["email"]; ?>"
                    data-userid="<?php echo $userdata["id"];?>"
                    data-currency="usd"
                    data-bitcoin="true">
                  </script>
                </form>

I have added a custom data attribute called data-userid, although I cannot see this field in the response.

How to add custom value fields?

+4
source share
1 answer

I found the answer to this question. Just add the field <input>to <form>and get the value from this input field on your PHP page, for example:

$input = $_POST["inputvalue"];

Thus, the form will look like this:

<form action="/api/stripe/charge" method="POST">
  <script src="https://checkout.stripe.com/checkout.js" 
          class="stripe-button" 
          data-key="pk_V4y6c4urwnTkLMEVNs0qBIQQJ5Yzu" 
          data-image="/square-image.png" 
          data-name="Demo Site" 
          data-description="2 widgets ($20.00)" 
          data-amount="2000" 
          data-currency="usd" 
          data-bitcoin="true">
  </script>
  <input type="hidden" name="inputvalue" value="value">
</form>
+8
source

All Articles