Download this file
| 1 | {{/* abono-subscribe-button — a POST form that starts Checkout. A POST |
| 2 | because the handler mints a Stripe session; csrf.Protect checks the |
| 3 | origin, so there is no token to carry. |
| 4 | |
| 5 | The form sends plan, interval (when there is one) and code (when Code |
| 6 | is set), to Action. |
| 7 | |
| 8 | Keys: |
| 9 | Action string, required — where the form posts |
| 10 | Plan string, required — the plan to buy |
| 11 | Interval string, optional — "month" or "year"; empty sends none, |
| 12 | and Checkout takes the plan's only sold price |
| 13 | Label string, optional — the button's words; "abono.button.subscribe" by default |
| 14 | Code bool, optional — a promotion code field above the button |
| 15 | L *ui.Localizer */}} |
| 16 | {{define "abono-subscribe-button"}}{{$L := localizer $}}{{$id := printf "abono-code-%s-%s" .Plan (or (opt . "Interval") "any")}}<form rst-form-actions method="post" action="{{.Action}}"><input type="hidden" name="plan" value="{{.Plan}}">{{with opt . "Interval"}}<input type="hidden" name="interval" value="{{.}}">{{end}}{{if opt . "Code"}}<div rst-field><label rst-field-label for="{{$id}}">{{T $L "abono.plan.code_label"}}</label><input rst-input id="{{$id}}" name="code" type="text" autocomplete="off" autocapitalize="characters" spellcheck="false" aria-describedby="{{$id}}-hint"><small rst-field-hint id="{{$id}}-hint">{{T $L "abono.plan.code_hint"}}</small></div>{{end}}<button type="submit" rst-btn="primary">{{with opt . "Label"}}{{.}}{{else}}{{T $L "abono.button.subscribe"}}{{end}}</button></form>{{end}} |
| 17 | |