Using either the rc7 or dev release, I get the following error when trying to checkout with stripe:

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

Comments

aviindub’s picture

Status: Active » Postponed (maintainer needs more info)

nobody else is having this problem with a stock setup, so you are going to have to provide more detail. a developer needs enough info to be able to replicate your bug before it can be worked on.

WillsCreative’s picture

I'm not sure what more information I can provide, because there aren't any errors in the log. The log on Stripe shows:

Parsed Request POST Body

amount: "999"
currency: "USD"
description: "Order Number: 323"

error:
type: "invalid_request_error"
message: "You must supply either a source or a customer id"

My live keys are entered in the payment method settings. I enable the payment method. Then when I try to checkout using my credit card I get the errors in OP. Could this error be caused because my site doesn't have SSL setup?

aviindub’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

SSL is probably required. im not sure actually, because i forgot there is still such a thing as non-SSL websites. you should run SSL regardless of whether its required for stripe.

in any case, this doesnt sound like a bug to me.

WillsCreative’s picture

Status: Closed (cannot reproduce) » Needs work

Not giving up, I found this other thread with a similar issue: https://www.drupal.org/node/2287761
I installed Jquery Update module and set it to jquery version 1.5 and now the checkout process works perfectly and cards get charged. I'm assuming something in the module isn't playing right with something else, causing jquery issues.

aviindub’s picture

Status: Needs work » Postponed (maintainer needs more info)

i'm using jQuery Update as well, and have it set to v 1.8, and Stripe works fine for me. so that's not it, at least not by itself.

torgospizza’s picture

I am having this issue on occasion with the following scenario.

In Commerce 1.10 it was made available the concept of "free orders" - an order that matches a certain requirement, specifically that no payment methods are available (and it is configured that payment is not required to complete checkout) can move to Completion without the user requiring to enter any payment method.

Unfortunately on occasion I seem to get an error with Stripe under these conditions:

1) Stripe is the default payment method;
2) CoF is enabled;
3) "Store this card" is enabled by default;
4) Payment is not required (for example due to a Commerce Gift Card covering the total order).

To reproduce:
1) Add a Commerce GC that covers your order;
2) Make sure Stripe is enabled, CoF is enabled and the card is set to be saved by default.
3) Check out as normal.
4) It will tell you that Payment is not required for checkout, so continue.

Expected result:
Checkout completes. Seems to act perfectly most of the time.

Actual Result:
Bounced back to Review page with "There are errors on the page" and "Following error received when processing card: You must supply either a source or a customer id". Gift card is also removed and you are forced to go back to the Checkout page and re-add it.

In my error logs I get: Notice: Undefined index: stripeToken in commerce_stripe_submit_form_submit() (line 249 of commerce_stripe/commerce_stripe.module

I'm not 100% sure if the issue is with Stripe, Card on File or Commerce itself. But based on this behavior it seems that the Card on File information is still being passed to the form, or for some reason the submit() handler is still being called despite the fact that the order form believes no payment is required to complete the checkout.

torgospizza’s picture

I think I understand what is happening, at least in our case:

In commerce_payment.module, when the payment form callbacks are all fired (commerce_payment_pane_checkout_form(), line 51), the line:

rules_invoke_all('commerce_payment_methods', $order);

Basically means, fire all rules hooks for any enabled payment methods.

The end result here is an invocation of commerce_payment_methods(), which does the following:

foreach (module_implements('commerce_payment_method_info') as $module) {
      foreach (module_invoke($module, 'commerce_payment_method_info') as $method_id => $payment_method) {
        $payment_method['method_id'] = $method_id;
        $payment_method['module'] = $module;
        $payment_methods[$method_id] = $payment_method;
      }

So now that we know all info hooks for payment methods get fired, here's what Commerce Stripe's info hook does:

function commerce_stripe_commerce_payment_method_info() {
  $payment_methods = array();

  $payment_methods['commerce_stripe'] = array(
    'title' => _commerce_stripe_load_setting('display_title', t('Stripe')),
    'description' => t('Stripe payment gateway'),
    'active' => FALSE,
    'terminal' => FALSE,
    'offsite' => FALSE,
    'cardonfile' => array(
      'charge callback' => 'commerce_stripe_cardonfile_charge',
      'create form callback' => 'commerce_stripe_cardonfile_create_form',
      'create callback' => 'commerce_stripe_cardonfile_create',
      'update callback' => 'commerce_stripe_cardonfile_update',
      'delete callback' => 'commerce_stripe_cardonfile_delete',
    ),
  );

  return $payment_methods;
}

Note this particular bit:
'title' => _commerce_stripe_load_setting('display_title', t('Stripe')),

That function invokes a function _commerce_stripe_load_settings() which makes a bunch of calls to commerce_payment_method_instance_load():

function _commerce_stripe_load_settings($name = NULL) {
  static $settings = array();

  if (!empty($settings)) {
    return $settings;
  }

  if (commerce_payment_method_load('commerce_stripe') && rules_config_load('commerce_payment_commerce_stripe')) {
    $commerce_stripe_payment_method = commerce_payment_method_instance_load('commerce_stripe|commerce_payment_commerce_stripe');
  }

  if (isset($name) && rules_config_load('commerce_payment_commerce_stripe')) {
    $commerce_stripe_payment_method = commerce_payment_method_instance_load('commerce_stripe|commerce_payment_commerce_stripe');
  }

  if (isset($commerce_stripe_payment_method)) {
    $settings = $commerce_stripe_payment_method['settings'];
  }

  return $settings;
}

I noticed that basically this means whenever we're trying to just look up information about the payment method, Commerce Stripe is loading the payment method regardless of whether it needs to be. The function commerce_payment_method_instance_load() actually executes all of the rules for a given payment method; in the case of Commerce Stripe, this means that the form is created, which includes a submit() handler callback, which gets added to the actions of the Complete Checkout submit button.

In our case, this includes when a Commerce Gift Card (from Commerce GC module) covers the entire order. Ordinarily, the order will simply be completed as a free order because no payment is required for the order to move to completion (thanks to the gift card!). But in our case the process is interrupted because the submit handler has fired, but no card was present - and neither was the value stripeToken, which throws a Notice in PHP.

These glitches combined 9 times out of 10 will not result in any problems, but on occasion the "Payment is not required for this free order" message that WAS there, is now replaced by all of the regular payment methods, and the gift card has been removed from the order.

Hopefully this was easy enough to follow, it took me hours and possibly days to track this down and become (hopefully) familiar enough with the payment method API to find this interesting edge case. If I'm mistaken in any of my understanding please let me know.

My solution is simple. Just patch Commerce Stripe's info hook to not be so dynamic. I took a look at what Commerce Authnet did, and here's the new version for Commerce Stripe:

$payment_methods['commerce_stripe'] = array(
    'title' => t('Stripe'),
    'short_title' => t('Stripe CC'),
    'display_title' => t('Credit card'),
    'description' => t('Stripe payment gateway'),
    'active' => FALSE,
    'terminal' => FALSE,
    'offsite' => FALSE,
    'cardonfile' => array(
      'charge callback' => 'commerce_stripe_cardonfile_charge',
      'create form callback' => 'commerce_stripe_cardonfile_create_form',
      'create callback' => 'commerce_stripe_cardonfile_create',
      'update callback' => 'commerce_stripe_cardonfile_update',
      'delete callback' => 'commerce_stripe_cardonfile_delete',
    ),
  );

So far it seems to work fine, it's a minor change. If I'm on the right track I can generate a patch.

aviindub’s picture

Status: Postponed (maintainer needs more info) » Active

that all seems reasonable to me, and its not a dangerous change in any case. put up the patch and i'll commit it.

torgospizza’s picture

Status: Active » Needs review
StatusFileSize
new590 bytes

Cool, here it is! Pretty straightforward. I just made an adjustment and made both the short title and title "Stripe".

torgospizza’s picture

Also wanted to mention that since applying this patch I have not seen anymore notices in Watchdog about stripeToken.

  • aviindub committed 6fb1e11 on 7.x-1.x authored by torgosPizza
    Issue #2447527 by torgosPizza: You must supply either a source or a...
aviindub’s picture

@WillsCreative can you please confirm this fixes your issue? its on the current dev version.

torgospizza’s picture

@WillsCreative: I'm curious to know as well. In the off chance this doesn't solve your problem, I'd also like to know if you are using Card on File, if you have the CoF functionality enabled in your Stripe payment method's config, and what the setting is defaulting to, since this is the code that is firing to cause your error. (It's either that or the stripeToken field is not getting injected into the form when it should be.)

capfive’s picture

To try and help shed some light on this situation, I am getting a similar error but not EXACTLY the same.

I have the following setup:

1. Drupal Commerce:

Version       :  7.x-1.11+4-dev

2. Commerce License Billing

 Version          :  7.x-1.0-beta4

3. Commerce Stripe

 Version          :  7.x-1.0-rc7

4. Commerce Card on file

Version       :  7.x-2.0-beta5+2-dev

so with card on file not turned on i get no error, payment fires, ends up in the stripe account, no issues, then when i try and use Card on file, it throws up an error, here are the front end:

Warning: Invalid argument supplied for foreach() in _commerce_stripe_create_card() (line 293 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
We received the following error processing your card. Please enter your information again or try a different card.
Must provide source or customer.

And here are the log entries:

Notice: Trying to get property of non-object in commerce_stripe_submit_form_submit() (line 230 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
Notice: Trying to get property of non-object in commerce_stripe_submit_form_submit() (line 229 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
Warning: Invalid argument supplied for foreach() in _commerce_stripe_create_card() (line 293 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
Notice: Trying to get property of non-object in _commerce_stripe_create_card() (line 293 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).

***This one may be unrelated***

Notice: Array to string conversion in drupal_attributes() (line 2421 of /home/espyconnect/public_html/includes/common.inc).

Please help, would love to get this going and use this live :)

aviindub’s picture

@capfive - please try again with the most recent dev version of Commerce Stripe. we have already made changes that should affect this issue since rc7.

capfive’s picture

Updated to the latest dev

 Title            :  Commerce Stripe
 Description      :  Stripe payment gateway integration with Commerce
 Version          :  7.x-1.0-rc7+21-dev
 Date             :  2015-04-10

still getting an error, but this might be different to the last one, so if so i will create a new ticket.

Front end error:

Warning: Invalid argument supplied for foreach() in _commerce_stripe_create_card() (line 318 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
We received the following error processing your card. Please enter your information again or try a different card.
You cannot use a Stripe token more than once: tok_xxx.

Log messages:

Notice: Trying to get property of non-object in _commerce_stripe_create_card() (line 318 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
Warning: Invalid argument supplied for foreach() in _commerce_stripe_create_card() (line 318 of /home/espyconnect/public_html/sites/all/modules/commerce_stripe/commerce_stripe.module).
Following error received when processing card You cannot use a Stripe token more than once: tok_xxx..

The token numbers are the same in the front end and backend errors.

Any help would be great, I will try a clean install to see if it is a module causing the error.

torgospizza’s picture

It almost sounds like you're trying to reuse a Stripe token? I'm not sure how that's possible. But I think the first error is causing the second one... Stripe_Customer::create is being called but failing, which results in the foreach() error.

But anyway yeah I don't think that issue is related.

mdyorke’s picture

I am having the same issue as @capfive. When I try to complete a payment with "Store this credit card on file for future use." checked, it fails but if its uncheck it works.

Please let me know if you find a solution because I'm currently working on a site that needs Card on File/Stripe.

torgospizza’s picture

@mdyorke: That looks to be a different issue altogether. This issue is about the error "You must supply either a source ID or customer ID". If that message is not relevant to your case, please create a new ticket, and provide as much information as you can.

This might be a related issue: #2467611: Undefined index: stripeToken

And as always be sure to try the latest -dev version of the module to see if your issue has been fixed in the interim.

torgospizza’s picture

Status: Needs review » Fixed

I'm also going to mark this tentatively as Fixed, but @aviindub please feel free to re-open if other commenters end up still having this issue.

capfive’s picture

correct it is fixed, i will post a new thread about the token error, it is different to the one you linked, but me and mdyorke are now having the same issue

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.