Skip to content

Instantly share code, notes, and snippets.

@andyfleming
Last active November 27, 2016 02:49
Show Gist options
  • Select an option

  • Save andyfleming/e248de196c14a134e518cdd6482dd2ab to your computer and use it in GitHub Desktop.

Select an option

Save andyfleming/e248de196c14a134e518cdd6482dd2ab to your computer and use it in GitHub Desktop.

Revisions

  1. andyfleming revised this gist Nov 27, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions stripe_checkout_donation.parsley.html
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    <form action="/-api/stripe/checkout" method="POST" id="donation-form">

    <!-- Input field for user -->
    <input type="number" name="donation_amount">
    <input type="number" name="donation_amount" value="5">

    <!-- Values for Zesty -->
    <input type="hidden" name="amount" value="1199"><!-- should match data-amount below (in cents) -->
    <input type="hidden" name="amount" value="500">
    <input type="hidden" name="success_redirect" value="/thank-you-for-your-donation/">
    <input type="hidden" name="failure_redirect" value="/an-error-occurred-with-your-donation/">
    <input type="hidden" name="charge_description" value="Donation on example.com">
  2. andyfleming created this gist Nov 27, 2016.
    29 changes: 29 additions & 0 deletions stripe_checkout_donation.parsley.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <form action="/-api/stripe/checkout" method="POST" id="donation-form">

    <!-- Input field for user -->
    <input type="number" name="donation_amount">

    <!-- Values for Zesty -->
    <input type="hidden" name="amount" value="1199"><!-- should match data-amount below (in cents) -->
    <input type="hidden" name="success_redirect" value="/thank-you-for-your-donation/">
    <input type="hidden" name="failure_redirect" value="/an-error-occurred-with-your-donation/">
    <input type="hidden" name="charge_description" value="Donation on example.com">

    <!-- Stripe Checkout button settings -->
    <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="{{ setting.stripe.key }}"
    data-name="{{ clippings.site_name }}"
    data-description="Donation"
    data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
    data-locale="auto"
    data-zip-code="true">
    </script>

    <script>
    // Every time the donation amount is changed, change the hidden amount field (and convert from dollars to cents)
    jQuery('#donation-form [name="donation_amount"]').on('keyup', function() {
    jQuery('#donation-form [name="amount"]').val(jQuery(this).val() * 100)
    });
    </script>

    </form>