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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviContribute Suggestions »
  • Payment processor code and classification
Pages: [1]

Author Topic: Payment processor code and classification  (Read 2232 times)

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Payment processor code and classification
September 15, 2014, 09:17:10 am
The concept of a payment processor 'type' is a bit confusing. Usually, it refers to the subclass of the base payment processor type (i.e. the PaymentProcessorType entity).

But there are two other ways of categorizing a payment processor:

1. By 'billing_mode', which seems to have been invented a while ago to deal with unique Paypal-specific behaviour.
2. By 'payment_type' which is usually 1 for credit cards, but can be 2 for direct debit. Introduced some time ago but regularly ignored by core code that is very credit-card centric ...

I'd like to propose that both of these get ditched in favour of greater use of object methods and subclassing.

Specifically, let's create a payment processor class CRM_Core_Payment_CreditCard and make most of the existing payment processors subclass that and put the credit card specific functionality (e.g. the card validation routines, and the field lists and rules) into that. Then we can create a CRM_Core_Payment_DirectDebit for all the direct debit-specific functionality. And then we can take out all the Paypal specific code in core that is nasty. Hey, while we're at it, let's move all those core payment processors into their own extensions!

As a nice corollary, I think we could then create a CRM_Core_Payment_Cheque payment processor and use that instead of the hodge-podge of 'is_pay_later' switches all over the code.

Here's another example of how that could be useful: the credit card swipe devices are credit card payment processors that don't have the same requirements in the credit card fields - for now, they are broken.

And from a code point of view - writing payment processor extensions would be much saner - more code can live in the payment processor object instead of all those buildForm hooks.



Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Payment processor code and classification
September 15, 2014, 03:01:45 pm
In terms of having a Direct Debit vs Credit Card vs 'manual' class what do you see as the fundamental differences? I had been thinking in terms of each payment processor having capabilities rather than assuming any particular capabilities consistently belonged with a particular type.

I agree regarding manual being a type of processor rather than a separate 'pay later'. I discussed this briefly with Kurund & Tim on IRC & they pointed out the change of status would need to be considered - ie. I create a manual 'pending' transaction & then later pay by credit card. I think this situation is NOT specific to manual payments though. I think a direct debit or credit card payment could be created this way and then paid by a different method (in the case of a credit card payment that happens when the process is not completed the first time). We would probably need to get input from Joe on how that would look in terms of financial entries. I think it would simplify the code
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Payment processor code and classification
September 24, 2014, 08:29:45 am
The most straightforward difference between Direct Debit and Credit Card is the billing block fields. Most of Credit Card processors are going to use the same set of fields, and most Direct Debit processors are going to a different set of fields (which is additionally complicated by variations across countries/regions).

But to answer the question of 'fundamental' differences, I'd have to just refer you to my blog post: https://civicrm.org/blogs/adixon/taking-payments-web-without-credit-card-hard

Or in summary: credit cards and direct debit are two different legal bases for transferring money over the internet. So how that might play out in the payment processor code is for example how they handle chargebacks, and how they handle the status of a payment. For credit cards, the transaction is pretty much instant, with the possibility of a charge back later, and the money arrives relatively soon. For Direct Debit, you're always just putting the payment into a queue somewhere for processing, with a greater likelyhood that it won't go through, and also the possibility for a later chargeback, and usually takes a lot longer than credit card to end up in your bank account.

re: pay later payment processor. Yes, i think my posting is probably a little naive about how easy it might be, but I do think it's feasible to implement pay later as a payment processor. From a bookkeeping point of view, I see no reason it wouldn't work as it does now - i.e. it gets entered into accounts receivable. When the payer is ready to actually initiate a payment, then this for now fictitious 'pay-later payment processor' would have to allow the contribution to be associated with a different payment processor (e.g. a 'cash' payment processor or 'cheque' payment processor, or some credit card payment processor), and then the logic of that payment processor would be invoked. A nice bonus would be to allow a payer to follow up a 'pay later' option to have a self-serve option for payment.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Payment processor code and classification
September 24, 2014, 02:09:30 pm
So, I want to challenge the case that the credit card processing is pretty much instant. That is a limitation of our current implementation - but actually credit card processing can be delayed - in particular in the case where tokens are used. Also with recurring contributions they can start immediately or be delayed (as Authorize.net does).

So, I'm not sure the concepts need to be different - even if the timing often is. Does the concept of creating a pending payment & then updating it later still hold. To my mind this concept works for both on-site & off-site credit card processors (& we have in theory agreement to switch to creating failed transactions rather than cleaning them up from dgg).

You also mention in your blog different fields by country - I had to implement this in the Omnipay processor for Cybersource. And I have been looking at processors with a completely different billing block depending on the country -so once again - I think it's a CiviCRM limitation rather than a difference between Credit & Debit cards.

We've also had some discussions about using the CiviCRM event queue to process 'all sorts' of incoming messages - including IPNs. debit card updates & audit information from banks. This would be a great feature - but I think it applies to both credit & debit cards
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Adam Wight

  • I’m new here
  • *
  • Posts: 9
  • Karma: 3
  • CiviCRM version: 4.2.x
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5.3
Re: Payment processor code and classification
September 25, 2014, 04:11:23 pm
Great to see this being discussed!

If it helps to complicate the issue, there are many processors which we might call "aggregators", which present a unified API to many backend payment methods.  The OmniPay library is a good example, there are also third parties like GlobalCollect who offer a similar service, they will process bank transfers, credit cards, direct debit, etc.  Even PayPal will let you use a credit card without an account, in addition to their e-wallet method, after you've already entered their workflow.  It's probably best if the payment details are private to each processor, and that any CiviCRM core functions that need to handle this information do so using attributes like "is this PCI-scope cardholder data?", "recurring System of Record is external?"...

We deal with a lot of different payment processors at Day Job, and I've found that there is no way to categorize them cleanly.  In our case, the main characteristic of a payment processor is the type of interaction it requires from the user.  There is the unhosted type, where fields can be filled out in CiviCRM and our backend can initiate the transaction without further interaction.  There are iframe methods, where the form is hosted by the acquirer/processor, and redirect methods like the PayPal button, where CiviCRM isn't responsible for any of the interactions.  Some processors can switch between interaction styles depending on API parameters.

The ideas in this thread for cleaning up the payment processor code look solid, the only thing I'd like to add is that we should find ways to reuse code which don't rely on a possibly superficial, processor-level difference between credit and debit, cos that might tie our hands when we try to support a processor that can do both.  I like the idea of creating a component like CRM_Core_Payment_CreditCard, but just as a helper, not as part of the class hierarchy.

And thank you adixon for your work on the iATS extension!  I'm configuring it for a friend's non-profit at the moment, and I'm very happy to have this option.

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Payment processor code and classification
October 20, 2014, 07:18:52 am
Here's another step in the code cleanup process, trying to document the situation we've got now.

http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=184188933

To summarize the discussion in this thread: i think it's clear that we can provide some core code support to the individual payment processing classes, and make that support not as hard-coded as it is now. I'm still rooting for the option of a hierarchy of classes, and I want to emphasize that any particular payment processor can always choose to subclass the core abstract class so we're not hamstringing the future here. But I still think this proposal would make it easier to refactor the existing code (which basically makes all these assumptions, so let's put those assumptions in a class together). For future payment processors, it would make sense to me to create a different credit card processor subclass that had many fewer assumptions, and just offered some helper methods that would make implementation of things like exposing forms elements easier (assuming many payment processors more or less use the standard set, and only might need to change a label, etc.). Or the whole IPN implementation and set of assumptions for example.

In any case, there's a whole lot of useful things that object oriented style code can offer us here that isn't being taken advantage of, but should/could.

And finally, in case you ended up on this thread without context, here's where it came from: http://forum.civicrm.org/index.php/topic,32920.0.html

« Last Edit: October 20, 2014, 07:30:04 am by adixon »

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Payment processor code and classification
October 20, 2014, 12:54:24 pm
Can you clarify what the subclasses might look like? e.g what functions would one see on the dd subclass vs a credit card subclass?

NB - I've also added some notes on the wiki page & I'll log a ticket for the tpl change I mention there
« Last Edit: October 20, 2014, 01:02:13 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

magnolia61

  • I post occasionally
  • **
  • Posts: 37
  • Karma: 0
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34 / Joomla 3.3.6
  • MySQL version: MySQL 5.5.40
  • PHP version: PHP 5.5.19
Re: Payment processor code and classification
May 02, 2015, 06:30:31 am
I just opened a new topic that touched the subject of backend Direct Debit handling and dealing with payment_type=2. Please have a look if you want to :-)
http://forum.civicrm.org/index.php/topic,36408.0.html

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • CiviContribute Suggestions »
  • Payment processor code and classification

This forum was archived on 2017-11-26.