简体   繁体   English

申请条纹优惠券

[英]Apply Stripe Coupon

I'm using Stripe's default form for payment processing. 我正在使用Stripe的默认表单进行付款处理。 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? 这是可能的还是我需要构建一个自定义表单?

You can't Add a coupon Field to the Pop Up Form shown by using the stripe JS. 您无法将优惠券字段添加到使用条带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. 任何告诉您可以将字段添加到POP up表单的人,请在文档中获取指向它的位置的链接,或者在互联网上的任何位置获取任何工作示例,演示等的链接。

You can't add a coupon to Checkout. 您无法向Checkout添加优惠券。 Checkout only creates the token to charge the customer. Checkout仅创建令牌以向客户收费。 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="payinguser@example.com",
  coupon="coupon_ID"
)

This should be a comment, but I don't yet have enough reputation. 这应该是一个评论,但我还没有足够的声誉。

Here's a simple checkout form to get you going, per @Brev Tiw's suggestion to build one: 根据@Brev Tiw的建议,这里有一个简单的结账表格,以便建立一个:

<form action="" method="POST" id="payment-form">
    <span class="payment-errors"></span>

    <div class="row">
      <div class="3u -4u 12u$(small)">
       <label>
         <span>Coupon Code</span>
         <input type="text" size="20" data-stripe="coupon" placeholder="" value=""/>
       </label>
      </div>
    </div>


    <div class="row">
      <div class="3u -4u 12u$(small)">
       <label>
         <span>Card Number</span>
         <input type="text" size="20" data-stripe="number"/>
       </label>
      </div>

      <div class="1u 12u$(small)">
        <label>
         <span>CVC</span>
          <input type="text" size="4" data-stripe="cvc"/>
        </label>
      </div>
    </div>

    <div class="row">
      <div class="2u -4u 12u$(small)">
        <span><strong>Exp. Month</strong></span>
        <div class="select-wrapper">
                    <select data-stripe="exp-month" name="exp-month" id="exp-month">
                        <option value="01">01</option>
                        <option value="02">02</option>
                        <option value="03">03</option>
                        <option value="04">04</option>
                        <option value="05">05</option>
                        <option value="06">06</option>
                        <option value="07">07</option>
                        <option value="08">08</option>
                        <option value="09">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                    </select>
        </div></div>


        <div class="2u 12u$(small)">
        <span><strong>Exp. Year</strong></span>
        <div class="select-wrapper">
                    <select data-stripe="exp-year" name="exp-year" id="exp-year">
                        <option value="2015">2015</option>
                        <option value="2016">2016</option>
                        <option value="2017">2017</option>
                        <option value="2018">2018</option>
                        <option value="2019">2019</option>
                        <option value="2020">2020</option>
                        <option value="2021">2021</option>
                        <option value="2022">2022</option>
                        <option value="2023">2023</option>
                        <option value="2024">2024</option>
                        <option value="2025">2025</option>
                    </select>
        </div><br />
    </div><br />
    </div>

    <div>

     <div>
        <h1></h1>
     <input type="submit" value="Pay now" class="special" />
    </div>
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM