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"
        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>
            <div class="form-group">
                <div class="row">
                    <label for="plan_amount" class="col-sm-2 control-label">Customer Name</label>

                    <div class="col-sm-10">
                        <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}
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="row">
                    <label for="plan_amount" class="col-sm-2 control-label">Customer Email</label>

                    <div class="col-sm-10">
                        <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}
                    </div>
                </div>
            </div>

            <hr>

            <h4>Plan</h4>

            <div class="alert bg-success text-white">
                <div class="form-group">
                    <div class="row">
                        <label for="plan_amount" class="col-sm-2 control-label">Details</label>

                        <div class="col-sm-10">
                            <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>
                        </div>
                    </div>
                </div>
            </div>

            <hr>

            <h4>Credit Card Details</h4>

            <label for="card-element">Credit or debit card</label>
            <div id="card-element">
                <!-- a Stripe Element will be inserted here. -->
            </div>
            <div id="card-errors" class="text-danger" role="alert"></div>

            <div id="progress" style="display:none;">
            We are processing your payment... please wait.
            </div>

            <div id="payment-errors" class="text-danger" style="display:none;"></div>

            <button id="pay-button" type="button" class="btn btn-xs btn-primary" data-processing="Please Wait...">
            Pay Now
            </button>
        </fieldset>

    {/exp:charge:form}
</div>
</div> <!-- close .row -->

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="{exp:charge:stripe_js}"></script>
<script src="{exp:charge:js}"></script>
<script>
    var elementsOptions = {
        fonts: [
            {
                cssSrc: "https://fonts.googleapis.com/css?family=Lobster",
            }
        ]
    };

    var cardFormOptions = {
        iconStyle: 'solid',
        style: {
            base: {
                iconColor: '#8898AA',
                color: 'black',
                lineHeight: '36px',
                fontWeight: 300,
                fontFamily: 'Lobster, "Helvetica Neue", Helvetica, sans-serif',
                fontSize: '19px',
                padding: '5px',

                '::placeholder': {
                    color: '#8898AA',
                },
            },
            invalid: {
                iconColor: '#e85746',
                color: '#e85746',
            }
        },
        classes: {
            focus: 'is-focused',
            empty: 'is-empty',
        }
    };

$(this).chargeForm({
  stripe_key: '{exp:charge:public_key}',
  form: '#charge-form',
  card: '#card-element',
  pay_button: '#pay-button',
  pay_button_processing_text: 'Please Wait...',
  pay_errors: '#payment-errors',
  progress: '#progress',
  coupon_form: '#coupon-form',
  coupon_field: '#coupon',
  coupon_status: '#coupon_status',
  card_form_options: cardFormOptions,
});
</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.