When paying with a stored card, users get the following error message:

  • We received the following error processing your card. Please enter your information again or try a different card.
  • Invalid Card Number

There seems to be a logic error in the commerce_beamstream.module's commerce_beanstream_submit_form_submit() function.

There are three possible scenarios when paying with a credit card:
1. User is paying with a new credit card and wants to store this card on file
2. User is paying with a new credit card and does not want to store it on file
3. User is paying with a credit card they have already stored on file

When a user is paying with a credit card, the current logic is:

  • Is the user storing the credit card?
    • YES (i.e. $pane_values['credit_card']['cardonfile_store'] == 1)
      • Is the user charging a new credit card?
        • YES (i.e. $pane_values['cardonfile'] === 'new')
          • Store the card and run the transaction on the new card (1a)
        • NO (i.e. $pane_values['cardonfile'] == [some stored card id])
          • The user is charging a stored card. Run the transaction on the stored card (3a)
    • NO (i.e. $pane_values['credit_card']['cardonfile_store'] != 1, also if it is not set)
      • The user is using a new credit card and is not storing it. Run the transaction on this card (2a)

The problem with the above logic occurs when a user wants to pay with a card they have already stored on file (and tries to get to (3a)). When the user selects to use a stored credit card in the form, the 'cardonfile_store' field doesn't appear, so the $pane_values['credit_card']['cardonfile_store'] == 1 test will fail and send the user to the (2a) path, which tries to send new credit card info to Beanstream. Because the form is also not displaying the fields to enter the credit card number, expiry date, etc, the transaction will fail because Beanstream doesn't get this required credit card info to run this transaction.

I propose the following logic:

  • Is the user charging a new credit card?
    • YES (i.e. $pane_values['cardonfile'] === 'new')
      • Is the user storing the credit card?
        • YES (i.e. $pane_values['credit_card']['cardonfile_store'] == 1)
          • Store the card and run the transaction on the new card (1b)
        • NO (i.e. $pane_values['credit_card']['cardonfile_store'] != 1)
          • The user is using a new credit card and is not storing it. Run the transaction on this card (2b)
    • NO (i.e. $pane_values['cardonfile'] == [some stored card id])
      • The user is charging a stored card. Run the transaction on the stored card (3b)

This logic is more compatible with the way the form fields display. If the user enters a new credit card, then the fields to provide the credit card number, expiration date, etc appear along with the 'cardonfile_store' field. If the user selects to use a stored card, these fields don't display and are not needed to run the transaction.

I have a working patch which uses this new logic and will post shortly.

Comments

kylesmith’s picture

Status: Active » Needs review
StatusFileSize
new3.47 KB

Here's my patch.

I've tested my three scenarios and it's working on my site.

  • spiderman committed 82ddc6c on 7.x-2.x
    Issue #2329761 by kylesmith: Fixes Can't charge an order to a stored...
spiderman’s picture

Status: Needs review » Fixed

Thanks Kyle! This has just been committed and pushed to the 2.x branch: http://drupalcode.org/project/commerce_beanstream.git/commit/82ddc6c

Status: Fixed » Closed (fixed)

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