Charge Documentation

Set Value Payments

Lock down the value of the payment to a specific value.

If you don't want your users to be able to change the price in the form, you can supply the value for the payment as a parameter on the exp:charge:form tag. This value will be encrypted as part of the form, and the payment value will be set to that amount. Any other value passed on the form will be ignored.

This method of setting (and protecting values) works for the following parameters: on_success, on_success:*, success_action, plan_amount, plan_interval, plan_interval_count, plan_currency

{exp:charge:form
  form_class="form-horizontal"
  form_id="charge-form"
  return="{segment_1}/thanks"
  return_error="{segment_1}/error"
  debug="yes"
  plan_amount="99"
  plan_currency="usd"
  plan_interval_count="1"
  plan_interval="week"}

  <fieldset>
    {if have_errors}
      <div class="alert alert-error">
        <h4>We have {error_count} errors</h4>
        <ul>
        {errors}
          <li>{error_message}</li>
        {/errors}
        </ul>
      </div>
    {/if}

    <h4>Details</h4>
    <label for="plan_amount" class="col-sm-2 control-label">Customer Name</label>

    <input type="text" class="form-control" id="customer_name" name="customer_name" placeholder="eg. Joe Smith" value="{customer_name}" />
    {if error_customer_name}
      <div class="alert alert-warning">
        {error_customer_name_message}
      </div>
    {/if}

    <label for="plan_amount" class="col-sm-2 control-label">Customer Email</label>
    <input type="text" class="form-control" id="customer_name" name="customer_email" placeholder="eg. joe@smith.org" value="{customer_email}" />
    {if error_customer_email}
      <div class="alert alert-warning">
        {error_customer_email_message}
      </div>
    {/if}

    <hr>

    <h4>Plan</h4>

    <label for="plan_amount" class="col-sm-2 control-label">Details</label>
    <input type="text" class="form-control disabled" disabled="disabled" id="" name="" value="99 EUR Weekly" />
    <span class="help-block">
      This is set using 'plan_amount', 'plan_interval', 'plan_interval_count' and 'plan_currency' on the exp:charge:form tag.
      The user will be unable to change this
    </span>

    <hr>

    <h4>Credit Card Details</h4>

    {if have_card_token}
      <h4>Payment Card</h4>
      <p><strong>{card_type}</strong>: {card_number_dotted}</p>
    {if:else}
      <h4>Payment Card</h4>

      <label for="card_number" class="col-sm-2 control-label">Credit Card Number</label>
      <input type="text" class="form-control" id="card_number" value="4242 4242 4242 4242" data-stripe="number" />

      <label for="card_exp_month" class="col-sm-2 control-label">Expires</label>
      <select id="card_exp_month" class="form-control" data-stripe="exp_month">
        {card_months}
          <option value="{month_digit}" {if current_month}selected="selected"{/if}>{month_digit} / {month_long}</option>
        {/card_months}
      </select>

      <select id="card_exp_year" class="form-control" data-stripe="exp_year">
        {card_years}
          <option value="{year_long}">{year_long}</option>
        {/card_years}
      </select>

      <label for="card_cvc" class="col-sm-2 control-label">Security Code</label>
      <input class="form-control" type="text" id="card_cvc" placeholder="" value="123" data-stripe="cvc" />
    {/if}

    <button id="submit_payment" type="submit" class="btn btn-primary form-control">Pay Now</button>
    <div id="payment-errors"></div>
  </fieldset>

{/exp:charge:form}

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="{exp:charge:stripe_js}"></script>
<script src="{exp:charge:js}"></script>
<script>
  (function(window, undefined) {
    Stripe.setPublishableKey('{exp:charge:public_key}');
    $(this).charge('#charge-form', '#payment-errors');
  })(window);
</script>

Support

Having problems setting up and/or using Charge? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.