A beta-tester reports a failure on using Stripe for checkout.
In the drupal logs I see this:
> Card processing error: Invalid token id: undefined

In the Stripe logs I see a successful v1/tokens request, which returns a good-looking token.
But the v1/charges request that comes next has these parameters:
amount: "1063"
currency: "USD"
card: "undefined"
description: "Order Number: 10"

And it fails because the card attribute contains "undefined", instead of the token
that was returned in the first step.

So the token is getting corrupted somewhere along the line as it passes from Stripe
to the javascript to php and back to Stripe.

This tester tried 4 times, with the same result.
BUT when I try it, it all works smoothly.

Any suggestions for how to trouble-shoot this?

Thanks!

Comments

hbochner’s picture

Status: Active » Closed (cannot reproduce)

Just an update:
my trouble-shooting didn't yield anything.

I marked the user's order as "complete", so that she would get a fresh one
on the next attempt.

And it worked on the next attempt. Perhaps something was corrupted in
the "order" data structure?

Anyway, I can no longer reproduce the problem.
Will keep an eye out for a recurrence.

justingeeslin’s picture

Status: Closed (cannot reproduce) » Active

This sounds similar to what I am experiencing.

When I attempt to process a payment using Stripe. I receive the following messages:

Notice: Undefined index: stripeToken in commerce_stripe_submit_form_submit() (line 148 of /nfs/c08/h04/mnt/123925/domains/d7.jgwebs.com/html/sites/all/modules/commerce_stripe/commerce_stripe.module).
We received the following error processing your card. Please enter you information again or try a different card.
You must supply either a card or a customer id

stripeToken seems to be missing. Let's look in the module around line 148:

  // Assemble charge parameters.
  $c = array(
    'amount' => $charge['amount'],
    'currency' => $payment_method['settings']['stripe_currency'],
    'card' => $_POST['stripeToken'],
    'description' => t('Order Number: @order_number', array('@order_number' => $order->order_number)),
  );

Looks like 'stripeToken' should be defined the $_POST array.

Let's see what is being POSTed.

commerce_payment[payment_... 123
commerce_payment[payment_... 05
commerce_payment[payment_... 2014
commerce_payment[payment_... 4242424242424242
commerce_payment[payment_... Justin Geeslin
commerce_payment[payment_... commerce_stripe|rules_stripe_payment
form_build_id form-DKf-q1A7KB9kqThA9oiqVLqTVBHhgdoIaNbMYga7vl4
form_id commerce_checkout_form_review
op Continue to next step

'stripeToken' is no where to be found in the POST data.

What is stripeToken? What should it be?
Should it be the card number? That IS in POST data..

justingeeslin’s picture

I was able to resolve my issue by changing this module's JavaScript.

In my situation, I need to check if form element '#edit-commerce-payment-payment-method-commerce-striperules-stripe-payment' is checked.
Without this the JavaScript call to compute 'stripeToken' would never occur.

Hope this helps someone.
Maybe I can commit my changes if I have permission.

Anonymous’s picture

I had this same issue OOTB. The module is checking for:

#edit-commerce-payment-payment-method-commerce-stripecommerce-payment-commerce-stripe

where in my case, it should have been:

#edit-commerce-payment-payment-method-commerce-striperules-stripe-payment
avb’s picture

@bryanlburkholder: Your fix worked like a charm.

This should be fixed.

aviindub’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

this appears to be fixed.

tr33m4n’s picture

Status: Closed (fixed) » Active

This is not fixed, Notice: Undefined index: stripeToken in commerce_stripe_submit_form_submit() (line 211 still appears when attempting to submit the form and the following

We received the following error processing your card. Please enter your information again or try a different card.
You must supply either a card or a customer id

Shows up as errors. I tried changing the id of javascript element needed to process however it would seem that my checkout uses the original '#edit-commerce-payment-payment-method-commerce-stripecommerce-payment-commerce-stripe' id, so does not need to change.

Anyone have any other pointers?

Cheers

tr33m4n’s picture

Ah, figure it out. As I'm running a recent version of jQuery the .live function is deprecated, so I had to change it to the .on function. Please update the js with version checking/require a certain version of jQuery

aviindub’s picture

Status: Active » Closed (fixed)