How to add extra value to stripe script?

I need a small customization in my stripe javascript. I have a php value as $invid and I want to pass it as a hidden field to next page of stripe card submission, so I will have both $stripeToken and $invid on next page after card submission, which changes do I need to do in my stripe code:

function stripeResponseHandler(status, response) {
 var $form = $('#payment-form');
 if (response.error) {
  // Show the errors on the form
  $form.find('.payment-errors').text(response.error.message);
  $form.find('button').prop('disabled', false);
 } else {
  // response contains id and card, which contains additional card details
  var token = response.id;
  // Insert the token into the form so it gets submitted to the server
  $form.append($('<input type="hidden" name="stripeToken" />').val(token));
  $form.append($('<input type="hidden" name="invid" value="<?=$invid?>" />'));
  // and submit
  $form.get(0).submit();
 }
};

should be something correct? or how?

None. The stripe code passes the credit card info to Stripe and updates the form with a hidden token field.

Whatever hidden fields you have in the form will be submitted to your next page along with the Stripe token.

Sorry, It doesn’t work, I added hidden field to form and in next page I just got stripeToken without my hidden field, my code above works fine, but I wanted to know if there is any other way?

Did you remember to give the hidden field a name - it wirked perfectly when I was testing that type of processing a couple of months ago.

I believe it had a name but strangely enough it works fine now! I don’t know which mistake I did last time. Thanks. Also I sent a pm to you.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.