When I choose Stripe for my payment option, it only has one field for an API key. Stripe apparently requires both a live secret and a live publishable key for taking payments. Generally the secret key is used on the server side and the publishable key is put into the HTML of the checkout form. Your documentation, however, doesn't seem to mention where it should be in your particular set of templates.

Should I just use Stripe's documentation on that, since yours is silent on the matter, or is there a particular way I need to reference that publishable key in your checkout template(s)?

And if I use the Stripe method, do I need the WHOLE Stripe Header code block I've seen used in the header in other examples:

<script type="text/javascript">
$(document).ready(function() {
$.getScript('https://js.stripe.com/v1/', function() {Stripe.setPublishableKey('pk_live_xxxxxxxxxxxxxxxxxxxxxxxx');});
  /* Ensure your checkout submit button has id="checkout_submit" */
 $("#checkout_submit").click(function() {

/* Only handle requests for Stripe gateway */
if (this.form.elements["payment_method"].value == "stripe") {

  /* Temporarily disable the checkout submit button */
  $("#checkout_submit").attr('disabled', true);

  /* Create a Stripe card token */
    name: $("#payment_name").val(),
    number: $("#payment_card_no").val(),
    cvc: $("#payment_card_csc").val(),
    exp_month: $("#payment_exp_month").val(),
    exp_year: $("#payment_exp_year").val()
  }, stripeResponseHandler);

  /* We don't want to submit the form yet */
  return false;
  /* This function is triggered once Stripe has generated the token */
  function stripeResponseHandler(status, response) {
/* Re-enable the checkout submit button */
$("#checkout_submit").attr('disabled', false);

/* Check whether we have a valid credit card */
if (response.error) {alert(response.error.message);} else {
  /* Set the card token and submit the checkout form */
<!-- End Stripe header code -->

Or should I just call it by itself?

 <script type="text/javascript">Stripe.setPublishableKey('MYPUBLISHABLEAPIKEY');</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.