Paul Dessert
Paul Dessert

Reputation: 6389

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?

Upvotes: 20

Views: 9047

Answers (2)

joshlsullivan
joshlsullivan

Reputation: 1500

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"
)

Upvotes: 2

Brev Tiw
Brev Tiw

Reputation: 602

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.

Upvotes: 24

Related Questions