The current example is pretty stupid (just asks for your name).
commerce_payment already has the functions for outputting a CC form and validating the number, and commerce_kickstart_payment (the Kickstart payment example module) uses them happily. Let's do that in Commerce as well.

Comments

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new2.38 KB

Here's a patch. It limits the form to Visa/MasterCard/Amex, we could make it allow all types instead. This was just Kickstart's default.

bojanz’s picture

Status: Needs review » Needs work

commerce_payment_example_transaction() is still looking for a $name. I didn't roll a complete patch.

ar-jan’s picture

Would this no longer allow the possibility to simulate a payment without valid cc number? Because that is a useful feature, and:

if you want a payment method with no validation, you should enable commerce_example_payment instead.

https://drupal.org/node/1900734#comment-7038772

bojanz’s picture

The CC number showed by default on the form passes validation, so you can still do that.

rszrama’s picture

Status: Needs work » Fixed

There were still other things to take care of here, such as updating the message for the completed transaction and masking the credit card number (because we all know people will still attempt to use this with real credit card numbers...). I also noticed a CSS error in the core credit card form CSS that I've fixed (and thus mitigated the need for RTL support).

Also, I'm not setup to test this right now, but I think we may be including the credit card form without a necessary addition of the include to the form's build information array. I'll have to try and produce a failure on that later.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/0099075

bojanz’s picture

Nice! :)

rszrama’s picture

Did a test with a forced error on the checkout review page and couldn't turn up any problems with respect to the include file. I guess it's because we get the base form include file in the build_info array from the menu item (sites/all/modules/commerce/modules/checkout/includes/commerce_checkout.pages.inc) and don't need to specify any include files that come through that. Guess it should've been a no-brainer given we don't have to add the various checkout pane include files to the array. Duh. : P

Status: Fixed » Closed (fixed)

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

Status: Closed (fixed) » Needs work

The last submitted patch, 1: 2144745-1-awesomify-commerce-payment-example.patch, failed testing.

rszrama’s picture

Status: Needs work » Closed (fixed)