Payment Options

The craft.charge.setPaymentOptions() method is required on all stripe.js payment forms.

The setPaymentOptions method encrypts the details about a charge request, and includes them as a hidden opts input in the form. Those are passed with the form submission, and decrypted on the backend to detect what to do with the payment request.

If the hidden opts input is missing or invalid, Charge will reject the request. The method accepts an array of details.


Simply include the craft.charge.setPaymentOptions({..}) inside your payment form. Like so :

<form method="post" id="charge-form">
   <input type="hidden" name="action" value="charge/charge"/>

   {{ craft.charge.setPaymentOptions({ allowDynamic: true }) }}

   .. (all the payment inputs) ..

Upgrading from 1.x? The allowDynamic option will let you set the behaviour of Charge to be the same as the default 1.x behaviour.


You can set all the various payment options using the following values.

allowDynamic e.g. true, defaults to false
Should this form allow dynamic values for plan amounts, intervals and currency. Pass this as true for donation forms where you want a visitor to have control over the amounts being paid. Also by passing true this emulates the original 1.x behaviour. With this passed as true the values for amount, intervals and currency are accepted from inputs with the names planAmount, planInterval, planIntervalCount and planCurrency in the submitted form.
planAmount eg. 99.99
The value in decimals for the charge.
planInterval accepts day, week, month, year
The interval for a recurring plan.
planIntervalCount accepts int
The number of periods for a recurring plan. If you're creating recurring charge, this is required, and must be 1 or higher. Not including, or passing a 0 value will create a one-time charge.
planCurrency optional
Optionally you can specify a non-default currency by passing the three letter currency code, ie. usd. If not included the charge will default to the default currency as defined the settings.
description String
An optional free text description for the payment. This will appear on the Stripe receipt, in the Stripe dashboard, and in the Charge CP.
meta Array
You can pass additional meta data about a charge via an array. These meta values will be passed to the Stripe api and will be visible in the Stripe dashboard for the charge, and in the Charge CP.
actions Array
An array of the actions that will be performed against this Charge.
planChoices Array
An array of sub-plans that can be offered to the customer to choose from. Ideal for setups where you need to offer multiple plan/pricing levels.
The name of the plan choice to default to if not supplied by the user.
The account Id for the payment to be sent to. Used as part of the Connect feature
The value of the application fee to collect for Connect setups.
The percentage value of the fee to collect for Connect setups. ie. 10 == 10% fee.


We recommend setting your options to an array in twig, then assigning it to the setPaymentOptions tag. That way you can still access the details of the request in the template without duplication. Like this :

{% set options = { planAmount : 99.99, description : 'This is an example payment' } %}

{{ craft.charge.setPaymentOptions(options) }}

Pay {{ options.planAmount }} Now..