Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply Stripe Coupon

I'm using Stripe's default form for payment processing. How can I add a coupon field? I've created a coupon, but I'm not sure how I would process the coupon code.

<form class="efocus" action="form_process.php?source=payment" method="post">
    <input type="hidden" name="fee" value="1795">
    <script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
          data-key="<?php echo $stripe['publishable_key']; ?>"
          data-amount=1795 data-description="Month-to-month Package">
    </script>
</form>

Is this possible or do I need to build a custom form?

like image 215
Paul Dessert Avatar asked Aug 02 '13 18:08

Paul Dessert


2 Answers

You can't Add a coupon Field to the Pop Up Form shown by using the stripe JS. Hopefully they will add this ability. It would be extremely helpful.

You can still add a the coupon code field between the form tags, but that field will not appear in the form that pops up. It will appear underneath the actual stripe checkout button.

<form class="efocus" action="form_process.php?source=payment" method="post">
<input type="hidden" name="fee" value="1795">
<script
    src="https://checkout.stripe.com/v2/checkout.js" 
    class="stripe-button"
    data-key="<?php echo $stripe['publishable_key']; ?>"
    data-amount=1795 data-description="Month-to-month Package">
</script>

<input type="text" name="discount" value="YOUR_DISCOUNT_ID_HERE" />

</form>

This is definitely not ideal. Since there will now be an input field under the button. So you may want to code your own Stripe Form?

Anyone who tells you that you can add Fields to the POP up form, please get a link to where it says that in the documentation, or a link to any working example, demo, etc anywhere on the internet.

like image 69
Brev Tiw Avatar answered Oct 12 '22 08:10

Brev Tiw


You can't add a coupon to Checkout. Checkout only creates the token to charge the customer. The coupon is applied when the token is returned to the server. Here's a code sample from stripe

stripe.Customer.create(
  source=token,
  plan="basic_monthly",
  email="[email protected]",
  coupon="coupon_ID"
)
like image 2
joshlsullivan Avatar answered Oct 12 '22 10:10

joshlsullivan