<p>After looking into the source code of the encrypt function, the <code>craft.charge.setPaymentOptions()</code> function calls <code>mcrypt_module_get_algo_key_size</code> and because my vagrant box (ubuntu 14.04) didn't have <code>php5-mcrypt</code> installed, it failed there.</p>

<p>To fix it: run <code>apt-get install php5-mcrypt &amp;&amp; sudo php5enmod mcrypt</code>.</p>

CC BY-SA 3.0
2017-09-07T03:09:38.327Z
2017-09-07T03:09:38.327Z
Leon Zhang
<p>I just had a fresh install of Charge 2 and my Craft version is Craft CMS 2.6.2989. However as long as I have <code>{{craft.charge.setPaymentOptions()}}</code> in my template, all my form fields disappear and show up again after I remove this line.</p>

<pre><code>{% extends "_layout" %}
{% set title = "Bookings" | t %}

{% set entry = craft.entries.section('bookings').first %}

{% block content %}
    &lt;div class="[ grid ] island"&gt;
        &lt;div class="[ grid__item desk-seven-twelfths ]"&gt;
            {% if entry.heading | length %}
                &lt;h1 class="brand-color"&gt;{{ entry.heading }}&lt;/h1&gt;
            {% endif %}

            {% if entry.featureImage | length %}
                &lt;img src="{{ entry.featureImage.first.url('halfWidth') }}" alt="{{ entry.Title }}" class="push--bottom"&gt;
            {% endif %}

            {% if entry.introText | length %}
                &lt;div class="lede"&gt;{{ entry.introText }}&lt;/div&gt;
            {% endif %}

            {% if entry.body | length %}
                {% include '_partials/_body' %}
            {% endif %}
        &lt;/div&gt;

        &lt;div class="[ grid__item desk-one-third push--desk-one-twelfth ]"&gt;
            &lt;div class="island ui-background--light"&gt;
                &lt;h3 class="push-half--bottom text--center ui-color--dark"&gt;{{ "Make a Payment" | t }}&lt;/h3&gt;

                &lt;hr class="rule rule--double"&gt;

                &lt;form id="charge-form" method="post" data-publicKey="{{ craft.charge.publicKey }}"&gt;
                    {% set chargeOptions = {'planAmount' : 99} %}
                    {{craft.charge.setPaymentOptions(chargeOptions)}}
                    &lt;input type="hidden" name="action" value="charge/charge"/&gt;

                    &lt;label for="customerEmail"&gt;Receipt Email&lt;/label&gt;
                    &lt;input type="text" name="customerEmail" value="{{ currentUser ? currentUser.email }}" id="customerEmail"/&gt;

                    &lt;label for="cardNumber"&gt;Card Number&lt;/label&gt;
                    &lt;input type="text" data-stripe="number" placeholder="•••• •••• •••• ••••" id="cardNumber"/&gt;

                    &lt;label for="cardExpiry"&gt;Card Expiry&lt;/label&gt;
                    &lt;input type="text" data-stripe="exp" placeholder="mm / yy" id="cardExpiry"/&gt;

                    &lt;label for="cardCvc"&gt;Card CVC&lt;/label&gt;
                    &lt;input type="text" data-stripe="cvc" placeholder="123" id="cardCvc"/&gt;
                &lt;/form&gt; 

            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"&gt;&lt;/script&gt;
    {% includeJsResource('charge/js/jquery.charge.js') %}
    {% includeJsResource('charge/js/stripe_v2.min.js') %}
    {% includejs %}
        $(this).charge();
    {% endincludejs %}
{% endblock %}
</code></pre>

<p><a href="https://i.sstatic.net/6AoyC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6AoyC.png" alt="enter image description here"></a></p>

<p>I can't see what's wrong with my setup...</p>

CC BY-SA 3.0
2017-09-05T04:38:33.410Z
Looks like `{{craft.charge.setPaymentOptions()}}` returns a 500 and the page just half rendered, stopped at this line
Leon Zhang
CC BY-SA 3.0
2017-09-05T05:59:25.270Z
There is something wrong with function

 ```public function encode($arr)
    {
        return base64_encode(craft()->security->encrypt(serialize($arr)));
    }```
Leon Zhang
CC BY-SA 3.0
2017-09-05T06:39:13.157Z
Never mind, I figured out. After looking into the source code of the encrypt function, it calls `mcrypt_module_get_algo_key_size` and because my vagrant box didn't have `php5-mcrypt` installed, it failed there.
To fix it:
`apt-get install php5-mcrypt`
`sudo php5enmod mcrypt`
Leon Zhang
CC BY-SA 3.0
2017-09-05T18:06:47.797Z
Thanks for the follow-up, Leon.  Would you mind adding that as an official answer in case it helps someone in the future?
Brad Bell
<templating><plugin-charge><stripe>
Charge 2 - Stripe form fields not showing
# Charge 2 - Stripe form fields not showing

(Asked by: username_0 on 2017-09-05)

I just had a fresh install of Charge 2 and my Craft version is Craft CMS 2.6.2989. However as long as I have {{craft.charge.setPaymentOptions()}} in my template, all my form fields disappear and show up again after I remove this line.
{% extends "_layout" %}
{% set title = "Bookings" | t %}

{% set entry = craft.entries.section('bookings').first %}

{% block content %}
    
        
            {% if entry.heading | length %}
                {{ entry.heading }}
            {% endif %}

            {% if entry.featureImage | length %}
                
            {% endif %}

            {% if entry.introText | length %}
                {{ entry.introText }}
            {% endif %}

            {% if entry.body | length %}
                {% include '_partials/_body' %}
            {% endif %}
        

        
            
                {{ "Make a Payment" | t }}

                

                
                    {% set chargeOptions = {'planAmount' : 99} %}
                    {{craft.charge.setPaymentOptions(chargeOptions)}}
                    

                    Receipt Email
                    

                    Card Number
                    

                    Card Expiry
                    

                    Card CVC
                    
                 

            
        
    
    
    {% includeJsResource('charge/js/jquery.charge.js') %}
    {% includeJsResource('charge/js/stripe_v2.min.js') %}
    {% includejs %}
        $(this).charge();
    {% endincludejs %}
{% endblock %}


I can't see what's wrong with my setup...

**Tags:** templating, plugin-charge, stripe

> **Comments:**
> **username_0**: Looks like `{{craft.charge.setPaymentOptions()}}` returns a 500 and the page just half rendered, stopped at this line  
> **username_0**: There is something wrong with function   ```public function encode($arr)     {         return base64_encode(craft()->security->encrypt(serialize($arr)));     }```  
> **username_0**: Never mind, I figured out. After looking into the source code of the encrypt function, it calls `mcrypt_module_get_algo_key_size` and because my vagrant box didn't have `php5-mcrypt` installed, it failed there. To fix it: `apt-get install php5-mcrypt` `sudo php5enmod mcrypt`  
> **username_1**: Thanks for the follow-up, Leon.  Would you mind adding that as an official answer in case it helps someone in the future?  

---

## 1 answers

### Answer by username_0 on 2017-09-07. Score: 1 | Accepted answer

After looking into the source code of the encrypt function, the `craft.charge.setPaymentOptions()` function calls `mcrypt_module_get_algo_key_size` and because my vagrant box (ubuntu 14.04) didn't have `php5-mcrypt` installed, it failed there.

To fix it: run `apt-get install php5-mcrypt && sudo php5enmod mcrypt`.


---

