<commit_before>﻿@using Newtonsoft.Json
@using Nwazet.Commerce.Services
@model Nwazet.Commerce.ViewModels.StripeCheckoutViewModel
@{
    var title = Layout.Title = T("Checkout with Stripe - 2: Credit Card Information");
    Script.Require("jQuery");
    Script.Include("https://js.stripe.com/v1/");
    var nameFormatter = WorkContext.Resolve<IAddressFormatter>();
    var address = Model.BillingAddress;
    using (Script.Foot()) {
        <script type="text/javascript">
            Stripe.setPublishableKey("@Model.PublishableKey");

            $(function() {
                var tokenForm = $("#token-form"),
                    errors = $(".payment-errors"),
                    showError = function(condition, message) {
                        if (!condition) {
                            errors.show().html(message);
                        } else {
                            errors.hide();
                        }
                    },
                    cardNumber = $(".card-number")
                        .blur(function() {
                            showError(
                                Stripe.validateCardNumber(cardNumber.val()),
                                "@T("Invalid card number")");
                        }),
                    cvc = $(".card-cvc")
                        .blur(function() {
                            showError(
                                Stripe.validateCVC(cvc.val()),
                                "@T("Invalid CVC")");
                        }),
                    expMonth = $(".card-expiry-month").keypress(function(e) {
                        if (e.which == 47) {
                            e.preventDefault();
                            expYear.focus();
                            return false;
                        }
                    }),
                    expYear = $(".card-expiry-year")
                        .blur(function() {
                            showError(
                                Stripe.validateExpiry(expMonth.val(), expYear.val()),
                                "@T("Invalid expiration date")");
                        }),
                    name = $(".card-name"),
                    addressLine1 = @Html.Raw(JsonConvert.SerializeObject(address.Address1)),
                    addressLine2 = @Html.Raw(JsonConvert.SerializeObject(address.Address2)),
                    city = @Html.Raw(JsonConvert.SerializeObject(address.City)),
                    state = @Html.Raw(JsonConvert.SerializeObject(address.Province)),
                    zip = @Html.Raw(JsonConvert.SerializeObject(address.PostalCode)),
                    country = @Html.Raw(JsonConvert.SerializeObject(address.Country)),
                    submit = $(".submit-button")
                        .click(function(event) {
                            event.preventDefault();
                            submit.prop("disabled", true);

                            Stripe.createToken({
                                number: cardNumber.val(),
                                cvc: cvc.val(),
                                exp_month: expMonth.val(),
                                exp_year: expYear.val(),
                                name: name.val(),
                                address_line1: addressLine1,
                                address_line2: addressLine2,
                                address_city: city,
                                address_state: state,
                                address_zip: zip,
                                address_country: country
                            }, stripeResponseHandler);
                            return false;
                        }),
                    stripeResponseHandler = function(status, response) {
                        if (response.error) {
                            showError(false, response.error.message);
                            submit.prop("disabled", false);
                        } else {
                            var token = response.id;
                            tokenForm
                                .append($("<input type=\"hidden\" name=\"stripeToken\"/>").val(token))
                                .get(0)
                                .submit();
                        }
                    };
            });
        </script>
    }
}
<h1>@title</h1>
<div class="payment-errors"></div>

<div id="payment-form">
    <label for="@Html.Id("name")">@T("Name on card")</label>
    <input id="@Html.Id("name")" value="@nameFormatter.FullName(address)" type="text" size="20" autocomplete="off" class="card-name input-medium" />

    <label for="@Html.Id("cardNumber")">@T("Card Number")</label>
    <input id="@Html.Id("cardNumber")" type="text" size="20" autocomplete="off" class="card-number input-medium"/>

    <label for="@Html.Id("cvc")">@T("CVC")</label>
    <input id="@Html.Id("cvc")" type="text" size="4" autocomplete="off" class="card-cvc input-mini"/>
    <div class="hint">@T("a 3-digit code on the back of your card, or a 4-digit code on the front if your card is an American Express.")</div>
<commit_msg>Better name field on payment page.<commit_after>﻿@using Newtonsoft.Json
@using Nwazet.Commerce.Services
@model Nwazet.Commerce.ViewModels.StripeCheckoutViewModel
@{
    var title = Layout.Title = T("Checkout with Stripe - 2: Credit Card Information");
    Script.Require("jQuery");
    Script.Include("https://js.stripe.com/v1/");
    var nameFormatter = WorkContext.Resolve<IAddressFormatter>();
    var address = Model.BillingAddress;
    using (Script.Foot()) {
        <script type="text/javascript">
            Stripe.setPublishableKey("@Model.PublishableKey");

            $(function() {
                var tokenForm = $("#token-form"),
                    errors = $(".payment-errors"),
                    showError = function(condition, message) {
                        if (!condition) {
                            errors.show().html(message);
                        } else {
                            errors.hide();
                        }
                    },
                    cardNumber = $(".card-number")
                        .blur(function() {
                            showError(
                                Stripe.validateCardNumber(cardNumber.val()),
                                "@T("Invalid card number")");
                        }),
                    cvc = $(".card-cvc")
                        .blur(function() {
                            showError(
                                Stripe.validateCVC(cvc.val()),
                                "@T("Invalid CVC")");
                        }),
                    expMonth = $(".card-expiry-month").keypress(function(e) {
                        if (e.which == 47) {
                            e.preventDefault();
                            expYear.focus();
                            return false;
                        }
                    }),
                    expYear = $(".card-expiry-year")
                        .blur(function() {
                            showError(
                                Stripe.validateExpiry(expMonth.val(), expYear.val()),
                                "@T("Invalid expiration date")");
                        }),
                    name = $(".card-name"),
                    addressLine1 = @Html.Raw(JsonConvert.SerializeObject(address.Address1)),
                    addressLine2 = @Html.Raw(JsonConvert.SerializeObject(address.Address2)),
                    city = @Html.Raw(JsonConvert.SerializeObject(address.City)),
                    state = @Html.Raw(JsonConvert.SerializeObject(address.Province)),
                    zip = @Html.Raw(JsonConvert.SerializeObject(address.PostalCode)),
                    country = @Html.Raw(JsonConvert.SerializeObject(address.Country)),
                    submit = $(".submit-button")
                        .click(function(event) {
                            event.preventDefault();
                            submit.prop("disabled", true);

                            Stripe.createToken({
                                number: cardNumber.val(),
                                cvc: cvc.val(),
                                exp_month: expMonth.val(),
                                exp_year: expYear.val(),
                                name: name.val(),
                                address_line1: addressLine1,
                                address_line2: addressLine2,
                                address_city: city,
                                address_state: state,
                                address_zip: zip,
                                address_country: country
                            }, stripeResponseHandler);
                            return false;
                        }),
                    stripeResponseHandler = function(status, response) {
                        if (response.error) {
                            showError(false, response.error.message);
                            submit.prop("disabled", false);
                        } else {
                            var token = response.id;
                            tokenForm
                                .append($("<input type=\"hidden\" name=\"stripeToken\"/>").val(token))
                                .get(0)
                                .submit();
                        }
                    };
            });
        </script>
    }
}
<h1>@title</h1>
<div class="payment-errors"></div>

<div id="payment-form">
    <label for="@Html.Id("name")">@T("Name")</label>
    <input id="@Html.Id("name")" value="@nameFormatter.FullName(address)" type="text" size="20" autocomplete="off" class="card-name input-medium" />
    <div class="hint">@T("as it appears on your card.")</div>

    <label for="@Html.Id("cardNumber")">@T("Card Number")</label>
    <input id="@Html.Id("cardNumber")" type="text" size="20" autocomplete="off" class="card-number input-medium"/>

    <label for="@Html.Id("cvc")">@T("CVC")</label>
    <input id="@Html.Id("cvc")" type="text" size="4" autocomplete="off" class="card-cvc input-mini"/>
    <div class="hint">@T("a 3-digit code on the back of your card, or a 4-digit code on the front if your card is an American Express.")</div>

{'fraction_non_alphanumeric': 0.12685050798258346, 'fraction_numerical': 0.004257377842283503, 'mean_word_length': 1.1714285714285715, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288618', 'n_tokens_mistral': 2548, 'n_tokens_neox': 2396, 'n_words': 414}