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) »
  • Custom donate pages and qfKey
Pages: [1]

Author Topic: Custom donate pages and qfKey  (Read 1287 times)

Micah Lee

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 4
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 7
  • MySQL version: 5.1.49
  • PHP version: 5.3.3
Custom donate pages and qfKey
October 05, 2011, 11:24:26 am
I'm making a snazzy looking donate page. I'm making it as a normal drupal page with a form on it that posts to /civicrm/contribute/transact, with all the appropriate fields on it. I'm doing it this way rather than editing the contribution page template for a couple of reasons. In this form the layout of the billing information, credit card information, and custom profile fields are all jumbled up (and the exact layout is quite important), and I'm also make a "Pay with PayPal" checkbox that, when checked, dynamically changed values so that it will submit to a PayPal contribution page instead of an Authorize.net one, from the same form.

The snag I'm hitting is with the qfKey. What is it? I gather that it's probably some sort of unique hash that contains within it the current session and the id of the contribution page. How would I go about generating new qfKeys for different contribution pages in a drupal module? I could make my drupal page generate these when loading this drupal donate page.

Is there anything else I'm missing that might cause problems or make this harder to implement than I realize? Thanks!

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Custom donate pages and qfKey
October 12, 2011, 05:23:06 pm
Hi Micah,

qfKey is generated for each form instance by CiviCRM's form handling framework, HTML_QuickForm, which is as much a top-to-bottom framework as Drupal's FAPI.  That means it's virtually impossible to create your own HTML form and have it submitted to CiviCRM.

I'd be surprised if editing (or even better: overriding) the template doesn't let you adjust the layout as needed.  Check here for info on changing the look of CiviCRM forms and pages: http://wiki.civicrm.org/confluence/display/CRMDOC40/Theming+CiviCRM

As for adjusting the payment processor dynamically, I'm not sure that's possible.  The redirect that takes the user to any offsite payment page (paypal, authorize.net, etc.) happens in the back end based on the configured payment processor, so adjustments to the form itself won't affect that.  There are other issues there, too, such as how CiviCRM handles any payment status feedback from the payment gateway service.

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Micah Lee

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 4
  • CiviCRM version: 4.1.0
  • CMS version: Drupal 7
  • MySQL version: 5.1.49
  • PHP version: 5.3.3
Re: Custom donate pages and qfKey
October 13, 2011, 10:27:43 am
Yeah, the main reason I wanted a form that submitted to multiple contribution pages was so I could make a single page handle different payment processors. That's not possible within CiviCRM at the moment, but it is possible with javascript. You can just check the "pay with paypal" checkbox all the credit card fields get hidden and the qfKey gets dynamically updated.

I built the interface for this, however then I realized that it's a much bigger process to choose which contribution form gets submitted than just changing the value of a contribution_form_id hidden field. So I gave up and decided to go ahead and override templates, and have our credit card and paypal payment contribution pages be on separate pages.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Custom donate pages and qfKey

This forum was archived on 2017-11-26.