CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Credit Card Surcharge - Patch/Module attached
Pages: [1]

Author Topic: Credit Card Surcharge - Patch/Module attached  (Read 5728 times)

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Credit Card Surcharge - Patch/Module attached
March 08, 2010, 05:35:45 pm
Many moons ago I asked about adding a surcharge to credit card payments, and worked with a friend to make it happen.  In reality, he worked, I told him what I wanted, tested, complained, tested again.  It turns out to be MUCH more complicated than originally thought.  The result is both hook and hack.  I leave it to the real developers to decide what should be added to the core. 

The patch, drupal module, and fully modified civi module (3.1.3) is available at: http://github.com/mariagwyn/civiCC.  Please feel free to branch and modify.  This is only a beginning.  Please don't modify my version.  I will update it if others offer improvements (hint hint).

GOAL: The patch and accompanying drupal module allows a 5% surcharge to be added to all CC payments.  The goal was to automatically add a preset percentage, and create a line item both in the civi record and the emailed receipt.  These goals were met with more and less success.

For EVENTS the patch meets all goals.
For MEMBERSHIP, the patch is really a hack.  IT does not allow line-item description, and depending on the method of adding/renewing the membership, it does not always show the total in the emailed receipt.  It does show the total in the civi payment record.

Here are the files modified:
 civicrm/CRM/Contribute/Form/Contribution/Main.php |    2
 civicrm/CRM/Member/Form/Membership.php            |    2
 civicrm/CRM/Member/Form/MembershipRenewal.php     |    2
 civicrm/CRM/Price/BAO/Set.php                     |    2
 civicrm/CRM/Utils/Hook.php                        |   20

Surely the most offending modifications are to all MEMBERSHIP files.  There seemed to be no other way than add 5% into the core files.  Bad form, I know, and really not worthy of a commit.  This is the area that needs work by experts.

The precessAmount HOOK seems worthy of a commit (main.php; set.php; hook.php) as that is what is called by the drupal module, where the amount can be modified, as well as text, labels, etc.

Attached are the patch for Civi, and the drupal module files (called civihooks, though on my site it lives in the 'dirtyfixes' folder with other hacks).

- maria

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Credit Card Surcharge - Patch/Module attached
March 08, 2010, 08:30:40 pm

would be good to post the processAmount hook and the patches as an issue. We'll check and potentially get it into 3.2

You/Developer should also check how this potentially interacts with the buildAmount hook (if at all)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: Credit Card Surcharge - Patch/Module attached
March 09, 2010, 09:40:27 am
According to Brad (developer) the hook gets called when the build amount doesn't get called, which only gets called if there is no price set.  Since events use price sets (on my setup), the processAmount gets called instead of build amount.  I am not sure what happens when there is no price set on events, we didn't test for that.  Also, the membership payment setup is way different, so we couldn't get a hook to work at all there, which is why it is coded in the core (blech).

Issue started: http://issues.civicrm.org/jira/browse/CRM-5935

choster

  • I’m new here
  • *
  • Posts: 29
  • Karma: 2
    • Lattice Group
  • CiviCRM version: 4.3,4.4,4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.39
  • PHP version: 5.5.15
Re: Credit Card Surcharge - Patch/Module attached
March 10, 2010, 02:56:43 pm
As a general FYI, note that the most credit merchant agreements expressly prohibit passing on the merchant discount rate to the customer as a surcharge, and it is also banned in some U.S. states. See for example http://usa.visa.com/personal/using_visa/no-surcharge.html , http://www.boston.com/business/articles/2009/07/19/sub_shops_credit_card_surcharge_is_unappetizing_and_illegal/ . On the flip side, some countries explicitly allow such surcharges, and enforcement of the no-"convenience charge" provision seems to be spotty.

It may also be possible to get around the provision by offering a discount for cash/check payment rather than adding the charge for credit transactions.

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Credit Card Surcharge - Patch/Module attached
December 05, 2010, 08:28:06 am
why not just add a price set with a manditory field as a surcharge?

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Credit Card Surcharge - Patch/Module attached
December 19, 2010, 12:13:01 pm
Hi mariagwyn : Any progress on adding a surcharge?  we need same functionality, perhaps we can "make it happen!"

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: Credit Card Surcharge - Patch/Module attached
January 18, 2011, 08:02:29 am
The attached (see above) surcharge works on 3.1.4.  I am in the process of upgrading to 3.3, and will let you know if it works on 3.3. 

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Credit Card Surcharge - Patch/Module attached
January 18, 2011, 09:44:03 pm
Another option to avoid the US regulations about adding a surcharge:

Have a checkbox on the donation/event/membership payment page with the wording:

"Click here to make an additional 5% donation, in order to help this organization cover the overhead of this donation. By checking this box, you ensure that 100% of your donation is received by this nonprofit organization."

Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Re: Credit Card Surcharge - Patch/Module attached
April 27, 2011, 09:58:31 am
A very late update: The patch works up through CiviCRM 3.3.3.  The line numbers of the modified files are different but the code/files are the same.

stkrzysiak

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: 3.5.5
  • CMS version: Drupal
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Credit Card Surcharge - Patch/Module attached
August 23, 2011, 11:29:25 am
THis only applies to membership pages, right?  We are on our own for contribution pages?  Thanks!

stkrzysiak

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: 3.5.5
  • CMS version: Drupal
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Credit Card Surcharge - Patch/Module attached
August 23, 2011, 11:38:58 am
Actually, after reading this: http://forum.civicrm.org/index.php?topic=17758.0  It seems that a membership page is a contribution page at heart.  Either way, this doesn't work for our needs but very informative and instructional.  Thanks!

minbori

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 2
  • CiviCRM version: 4.0.8
  • CMS version: Joomla 2.5.24
  • MySQL version: 5.5.37
  • PHP version: 5.3.29
Re: Credit Card Surcharge - Patch/Module attached
September 07, 2011, 09:32:57 am
Just wanted to post a thank you for this....saved me loads of time implementing a similar requirement. I had to tweak mine for a Joomla environment but having this as an example saved my bacon! Many Thanks!

EdP

  • I post frequently
  • ***
  • Posts: 260
  • Karma: 7
  • CiviCRM version: 4.4
  • CMS version: Joomla 2.5.x
Re: Credit Card Surcharge - Patch/Module attached
September 13, 2011, 02:40:17 am
Quote from: minbori on September 07, 2011, 09:32:57 am
Just wanted to post a thank you for this....saved me loads of time implementing a similar requirement. I had to tweak mine for a Joomla environment but having this as an example saved my bacon! Many Thanks!

Any chance you could post your Joomla solution?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Credit Card Surcharge - Patch/Module attached

This forum was archived on 2017-11-26.