Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JulienD’s picture

Here is a patch to add the card on file feature. I based my developments onto the fork of commerce_cardonfile.

This patch is adding the cardonfile functionality in the current payment method. To enable it, edit the payment method settings.

Implementing this feature wasn't as simple as I thought. The biggest reason was because we tried to combine two different payment method because be2bill is implemented as an off-site payment but their API can only be used in a REST mode and more like an on-site payment method. To implement it, I created a custom form and stored some information in the user session. I had a look on commerce_braintree which do something similar.

Commerce_cardonfile is not designed to be used for off-site payment methode and the module require a credit card field in the form or it couldn't works. So I added a field named as commerce_cardonfile wished in the form. I'm not happy with that but that issue should be asked to the maintener of commerce_cardonfile.
Also, Commerce_cardonfile need a credit card date to works but be2bill doesn't give us this information, so I created a fake credit card date with a validity of a year and a half.

Because Be2bill's card on file API is really simple I couldn't have the possibility to implement the create/update functionnalities. The customer has just the possibility to store a credit card during the checkout process or to delete a stored card, not much more

How to test :
- Installation and configuration:

  • Apply the patch to commerce_be2bill module.
  • Download and enable if necessary the commerce_cardonfile module (the official or the fork)
  • Go to the Be2bill's payment method settings - http://example.com/admin/commerce/config/payment-methods/manage/commerce... - and click on the edit button at the bottom of the page.
  • Check the cardonfile option "Enable Card on File functionality" at the bottom of the page in the "Optional" section.

- Doing an off-site payment and storing a card:

  • Add a product to your cart and process the checkout until you reach the payment form
  • Select the be2bill payment method "credit card", and check the box "Store this credit card on file for future use". By default, if you don't have stored any credit card yet, the "Set as your default card" option should be selected and disabled.
  • Complete the form and you should be redirected and the Be2bill website.
  • Fill in all the asked information and validate the form. You should be redirected on your website.
  • Your credit card is now stored on your website and is available for future payment.

- Complete an order with a stored credit card

  • Add a product to your cart and process the checkout until you reach the payment form
  • Select the be2bill payment method "credit card", and you should now have the possibility to select a previously registered credit card.
  • Continue your checkout. You will NOT be redirected on be2bill website because we are using their REST API, instead you will be redirected on the complete page of your order.

- Deleting a stored credit card

  • Go to your profile page /user and click on the tab "Stored Payments"
  • Here is the page where you can manage all your registered credit cards.
  • Click on the "delete" link to remove a credit card from the database.
GuGuss’s picture

Hi,

I tested your patch and it works fine with the fork of commerce_cardonfile !

Anyway, I think that patch should add a submodule which implements another payment method with CoF integration (See other payment modules like Payleap, Paypal...).

FYI: I also tested it with the non-forked module and I've the checkbox to enable Card on File, but the card is not stored on the user profile nor in the database. I know that's on purpose still !

GuGuss’s picture

@Julien: It seems that the Card on File option is still available even if the merchant unchecked the Enable Card on File functionality.

The option shouldn't be displayed in that case.

JulienD’s picture

@Julien: It seems that the Card on File option is still available even if the merchant unchecked the Enable Card on File functionality.

Are you talking about the option in the payments method list ? If yes, this form is provided by the Cardonfile module. I'll have a look on this !

GuGuss’s picture

Yes that one ! When the box is unchecked, then the Card on File option shouldn't be displayed during checkout.

That's one reason to have 2 separate payment methods ^^

Haza’s picture

Status: Active » Needs review
FileSize
18.59 KB

New patch with the current CoF -dev version.

Still only one payment method (that how it should be done, not 2 different payment method)

Haza’s picture

New patch, added an option to optin the card on file during checkout.
Change the "month/year" date of the CoF to "0/0" because we don't have the informations.

Haza’s picture

Bring back the "fake" end date. With more heavy (and deeeeeeeeep) testing, I just realized that wasn't working.

perusio’s picture

Issue summary: View changes

@Haza thanks for the patch. It required some code modification to make it work with the current commerce_cardonfile. Commited with quite a few changes. Commit here: http://drupalcode.org/project/commerce_be2bill.git/commit/7dfa0d6.

perusio’s picture

Status: Needs review » Closed (fixed)