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 (Moderator: Donald Lobo) »
  • Web2Pay Payment Processor
Pages: [1]

Author Topic: Web2Pay Payment Processor  (Read 4062 times)

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Web2Pay Payment Processor
August 10, 2008, 06:55:35 pm
I'm looking at implementing a payment processor via Web2Pay/Flo2Cash. It's a hosted solution, but different to Google and Paypal hosted in that they expect the transaction details to come in via POST not GET.

So, my final screen (which would otherwise need to redirect to eg PayPal with some GET params) needs to be a POST form which launches the user to Web2Pay.

I can't see an example payment processor in CiviCRM 2.0 which does something like this, so I figured I'd ask here in case there's an example I'm missing. If so, please let me know :)

We'll be contributing the Web2Pay/Flo2Cash module back once complete, although it may only be of interest to orgs within AU/NZ.
@xurizaemon ● www.fuzion.co.nz

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Web2Pay Payment Processor
August 10, 2008, 07:57:42 pm
(Please excuse the monologue while I document my progress; if I succeed then I may take a break and write it up as a Wiki page.)

First issue: getting the new processor to load :)

I read the docs listed below:
  • http://wiki.civicrm.org/confluence/display/CRMDOC/Creating+Additional+Payment+Processor+Plugins
  • http://www.idealso.com/civicrm/AUTHORIZENET_NOTES
  • http://forum.civicrm.org/index.php/topic,4226.0.html

I made the changes in CRM/Core/SelectValues.php as required, adding the new processor to the array in CRM_Core_SelectValues::paymentProcessor().

The key you use here must match the filename in CRM/Core/Payment/ - so my function ended up looking like,
Code: [Select]
    /**
     * Function to get the Payment Processor
     *
     * @return array $processor array of payment processor
     * @static
     */
    static function &paymentProcessor()
    {
        static $processor = null;
        if (!$processor) {
            $processor = array(
                               'PayPal'           => ts('PayPal - Website Payments Pro'),
                               'PayPal_Express'   => ts('PayPal - Express'),
                               'PayPal_Standard'  => ts('PayPal - Website Payments Standard'),
                               'AuthNet_AIM'      => ts('Authorize.Net - AIM'),
                               'Google_Checkout'  => ts('Google Checkout'),
                               'Moneris'          => ts('Moneris'),
                               'Flo2CashHosted'   => ts('Flo2Cash Hosted'),
                               'Dummy'            => ts('Test Payment Processor'),
                               );
        }
        return $processor;
    }

I found that the documented file CRM/Core/Payment/Config.php didn't exist, and after a moment found that this had been moved to the DB table civicrm_payment_processor_type. So I added my new processor here.

Code: [Select]
mysql> select * from civicrm_payment_processor_type ;
+----+-----------+-----------------+------------------------------------+-------------+-----------+------------+------------------------+----------------+-----------------+---------------+------------------------+----------------------------------------------------+-----------------+----------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+----------------------+--------------------------------------------------+-----------------------------------------------------------+--------------+----------+
| id | domain_id | name            | title                              | description | is_active | is_default | user_name_label        | password_label | signature_label | subject_label | class_name             | url_site_default                                   | url_api_default | url_recur_default                            | url_button_default                                        | url_site_test_default                                      | url_api_test_default | url_recur_test_default                           | url_button_test_default                                   | billing_mode | is_recur |
+----+-----------+-----------------+------------------------------------+-------------+-----------+------------+------------------------+----------------+-----------------+---------------+------------------------+----------------------------------------------------+-----------------+----------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+----------------------+--------------------------------------------------+-----------------------------------------------------------+--------------+----------+
|  1 |         1 | Dummy           | Dummy Payment Processor            | NULL        |         1 |          1 | User Name              | NULL           | NULL            | NULL          | Payment_Dummy          | NULL                                               | NULL            | NULL                                         | NULL                                                      | NULL                                                       | NULL                 | NULL                                             | NULL                                                      |            1 |     NULL |
|  2 |         1 | PayPal_Standard | PayPal - Website Payments Standard | NULL        |         1 |          0 | Merchant Account Email | NULL           | NULL            | NULL          | Payment_PayPalImpl     | https://www.paypal.com/                            | NULL            | https://www.paypal.com/                      | NULL                                                      | https://www.sandbox.paypal.com/                            | NULL                 | https://www.sandbox.paypal.com/                  | NULL                                                      |            4 |        1 |
|  3 |         1 | PayPal          | PayPal - Website Payments Pro      | NULL        |         1 |          0 | User Name              | Password       | Signature       | NULL          | Payment_PayPalImpl     | https://www.paypal.com/                            | NULL            | NULL                                         | https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif | https://www.sandbox.paypal.com/                            | NULL                 | NULL                                             | https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif |            3 |     NULL |
|  4 |         1 | PayPal_Express  | PayPal - Express                   | NULL        |         1 |          0 | User Name              | Password       | Signature       | NULL          | Payment_PayPalImpl     | https://www.paypal.com/                            | NULL            | NULL                                         | https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif | https://www.sandbox.paypal.com/                            | NULL                 | NULL                                             | https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif |            3 |     NULL |
|  5 |         1 | Google_Checkout | Google Checkout                    | NULL        |         1 |          0 | Merchant ID            | Key            | NULL            | NULL          | Payment_Google         | https://checkout.google.com/                       | NULL            | NULL                                         | http://checkout.google.com/buttons/checkout.gif           | https://sandbox.google.com/checkout/                       | NULL                 | NULL                                             | http://sandbox.google.com/checkout/buttons/checkout.gif   |            4 |     NULL |
|  6 |         1 | Moneris         | Moneris                            | NULL        |         1 |          0 | User Name              | Password       | Store ID        | NULL          | Payment_Moneris        | https://www3.moneris.com/                          | NULL            | NULL                                         | NULL                                                      | https://esqa.moneris.com/                                  | NULL                 | NULL                                             | NULL                                                      |            1 |        1 |
|  7 |         1 | AuthNet_AIM     | Authorize.Net - AIM                | NULL        |         1 |          0 | API Login              | Payment Key    | MD5 Hash        | NULL          | Payment_AuthorizeNet   | https://secure.authorize.net/gateway/transact.dll  | NULL            | https://api.authorize.net/xml/v1/request.api | NULL                                                      | https://secure.authorize.net/gateway/transact.dll          | NULL                 | https://apitest.authorize.net/xml/v1/request.api | NULL                                                      |            1 |        1 |
|  8 |         1 | PayJunction     | PayJunction                        | NULL        |         1 |          0 | User Name              | Password       | NULL            | NULL          | Payment_PayJunction    | https://payjunction.com/quick_link                 | NULL            | NULL                                         | NULL                                                      | https://payjunction.com/quick_link                         | NULL                 | NULL                                             | NULL                                                      |            1 |        0 |
|  9 |         1 | Flo2Cash_Hosted | Flo2Cash Hosted                    | NULL        |         1 |          0 | Account ID             | Pass           | NULL            | NULL          | Payment_Flo2CashHosted | https://secure.flo2cash.co.nz/web2pay/default.aspx | NULL            | NULL                                         | NULL                                                      | http://demo.flo2cash.co.nz/client/Default/MemberLogin.aspx | NULL                 | NULL                                             | NULL                                                      |            4 |     NULL |
+----+-----------+-----------------+------------------------------------+-------------+-----------+------------+------------------------+----------------+-----------------+---------------+------------------------+----------------------------------------------------+-----------------+----------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+----------------------+--------------------------------------------------+-----------------------------------------------------------+--------------+----------+
9 rows in set (0.00 sec)

I think the trick here was matching 'Payment_Flo2CashHosted' (column class_name in the DB table) to the key 'Flo2CashHosted' in CRM_Core_SelectValues::paymentProcessor(). It would be cool to have this clarified (anyone?)
@xurizaemon ● www.fuzion.co.nz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Web2Pay Payment Processor
August 10, 2008, 09:57:32 pm
nb my impression is that editing this file is obsolete (as at v2) CRM/Core/SelectValues.php

I think the important part is as you say having the class name in the civicrm_payment_processor_type table and having the php files of the same name in the payments folder in the event, core and contribute folders
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

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Web2Pay Payment Processor
August 10, 2008, 10:58:29 pm
I agree. I tried to break it by changing the values in CRM/Core/SelectValues.php, and try as I might, it wouldn't stop working :)

People: Ignore CRM/Core/SelectValues.php, those are not the vals you're looking for.
@xurizaemon ● www.fuzion.co.nz

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Web2Pay Payment Processor
August 11, 2008, 02:52:33 am
Hi Chris,

I just took a quick look at your processor that you are trying to set up. The code for the paypal express method in the paypalImpl file (ie. civicrm/CORE/payment/paypalIMPL.php) deals with Posting information to and from the processor. It uses CURL via the invokeapi() function defined in that .php file.

these three  functions are all two way POST transactions:
 setExpressCheckOut( &$params ) // returns a token
 getExpressCheckoutDetails( $token ) // returns user billing information
 doExpressCheckout( &$params ) //finalises transaction & returns result

In paypal express a post is made to the processor & then a reply comes back to that post from the processor. I'm not clear whether this code is applicable when the posting is being done by the user's browser being re-directed rather than server to server but it would help with "your website checkout page would make a HTTP POST to our secure hosted payment page"

I have gone done the track of using the IPN material (copying heavily from the googleIPN file) because there are two html GETs received with paymentExpress - one from the payment processor and one as a browser re-direct and each one contains enough encrypted information to complete the transaction so either/or should work.

I copied the google processor code to package up the 'privatedata' to be sent and the 'return_url' (where to re-direct the customer to from my code) and unpackage and interpret it and fire off the necessary functions when it came back. So far I have got it working but I need to do a bit more testing on failed transactions and make sure it works properly if the user's browser never returns or only returns much later. I also need to edit the .tpl file for the thank you page as it refers specifically to Paypal or Google & do a wee tidy up but I'm mostly there.

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Web2Pay Payment Processor

This forum was archived on 2017-11-26.