<div class="container" id="wrapper">
    <div class="general-block-decorator">
        <div class="title title-without-tabs">
            {intl l="Configure stripepayment" d="stripepayment.bo.default"}
        </div>

        <div class="row">
            <div class="col-md-12">
                {if $success|default:null}
                    <div class="alert alert-success">
                        {intl l="Configuration correctly saved" d="stripepayment.bo.default"}
                    </div>
                {/if}

                {form name="stripepayment_config_form"}
                    <form action="{$current_url}" method="post">
                        {include "includes/inner-form-toolbar.html" hide_flags = 1 close_url={url path='/admin/modules'}}
                        <br/>

                        {form_field form=$form field="success_url"}
                        <input type="hidden" name="{$name}" value="{url path='/admin/modules'}" />
                        {/form_field}

                        {form_hidden_fields form=$form}

                        {form_field form=$form field="enabled"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                <input type="checkbox" name="{$name}" id="{$label_attr.for}" {if $value}checked{/if} placeholder="{intl l='The configuration value enabled' d="stripepayment.bo.default"}" />
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="enabled"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}
                        {form_field form=$form field="stripe_element"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                <input type="checkbox" name="{$name}" id="{$label_attr.for}" {if $value}checked{/if} placeholder="{intl l='active stripe element' d="stripepayment.bo.default"}" />
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="stripe_element"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}
                        {form_field form=$form field="one_click_payment"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                <input type="checkbox" name="{$name}" id="{$label_attr.for}" {if $value}checked{/if} placeholder="{intl l='active one click payment' d="stripepayment.bo.default"}" />
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="stripe_element"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}
                        {form_field form=$form field="secret_key"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="secret_key"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            <input type="text" class="form-control" name="{$name}" id="{$label_attr.for}" value="{$value}" placeholder="{intl l='The configuration value secret_key' d="stripepayment.bo.default"}" />
                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help nofilter}</span>
                            {/if}
                        </div>
                        {/form_field}
                        {form_field form=$form field="publishable_key"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="publishable_key"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            <input type="text" class="form-control" name="{$name}" id="{$label_attr.for}" value="{$value}" placeholder="{intl l='The configuration value publishable_key' d="stripepayment.bo.default"}" />
                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}

                        {form_field form=$form field="webhooks_key"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="webhooks_key"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            <input type="text" class="form-control" name="{$name}" id="{$label_attr.for}" value="{$value}" placeholder="{intl l='The configuration value webhooks_key whsec_...' d="stripepayment.bo.default"}" />
                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}

                        {form_field form=$form field="secure_url"}
                        <div class="form-group {if $error}has-error{/if}">
                            <label class="control-label" for="{$label_attr.for}">
                                {$label}
                                {if $required}<span class="required">*</span>{/if}

                                {form_error form=$form field="secure_url"}
                                <br />
                                <span class="error">{$message|default:null}</span>
                                {/form_error}
                            </label>

                            <input type="text" class="form-control" name="{$name}" id="{$label_attr.for}" value="{$value}" placeholder="{intl l='The configuration value secure_url' d="stripepayment.bo.default"}" />
                            {if ! empty($label_attr.help)}
                                <span class="help-block">{$label_attr.help}</span>
                            {/if}
                        </div>
                        {/form_field}

                        <div class="form-group">
                            <label class="control-label" for="web_hooks_urls">{intl l='Webhooks endpoint url' d="stripepayment.bo.default"}</label>
                            <input id="web_hooks_urls" type="text" class="form-control disabled" disabled value="{url path="/module/StripePayment/stripe_webhook/{$value}/listen"}">
                        </div>

                        <div class="form-group">
                            <label>{intl l='Webhooks event to activate' d="stripepayment.bo.default"}</label>
                            <ul>
                                <li>payment_intent.payment_failed</li>
                                <li>payment_intent.succeeded</li>
                                <li>checkout.session.completed</li>
                            </ul>
                        </div>
                        {include "includes/inner-form-toolbar.html" hide_flags = 1 close_url={url path='/admin/modules'} page_bottom=1}
                    </form>
                {/form}
            </div>
        </div>
    </div>
</div>
