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) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Membership renewal with Google Checkout & Separate Membership Payment
Pages: [1]

Author Topic: Membership renewal with Google Checkout & Separate Membership Payment  (Read 5383 times)

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 05:51:39 am
I’m trying to work out how to do membership renewals using Google Checkout.   

There are two fees to our membership payment system:–
      (1)   Membership type which is either ordinary or joint.
      (2)   An optional insurance fee

I thought I could achieve this using  [CiviCRM  » CiviContribute  » Manage Contribution Page  » Membership Settings] and ticking the “Separate Membership Payment” box.

The Separate Membership Payment should do this:
Quote
If this option is checked AND the contribution page includes a separate contribution amount block - two transactions will be generated: one for the membership fee amount; and one for the selected contribution amount. (This option is NOT available for PayPal Website Payments Standard.)

So, when I configure Contribution Amounts I get a membership sign up page which offers radio buttons depending on what membership the contact wants to take and another set of radio buttons depending on what insurance they want.

(http://bec-cave.org.uk/temp/CCP1.JPG)

Selecting Ordinary Membership and Insurance and pressing the Continue button links to a summary and the Google Checkout button.

(http://bec-cave.org.uk/temp/CCP2.JPG)

Separate Membership Payment was not being picked up by Google Checkout and only the first amount was being presented for billing. I got around this by editing civicrm/CRM/Core/Payment/Google.php by adding $item2.

Code: [Select]
        //Create a new shopping cart object
        $merchant_id  = $this->_paymentProcessor['user_name'];   // Merchant ID
        $merchant_key = $this->_paymentProcessor['password'];    // Merchant Key
        $server_type  = ( $this->_mode == 'test' ) ? 'sandbox' : '';
       
        $cart =  new GoogleCart($merchant_id, $merchant_key, $server_type);
        $item1 = new GoogleItem($params['item_name'],'', 1, $params['amount'], $params['currencyID']);
        $cart->AddItem($item1);

        //$cart  =  new GoogleCart($merchant_id, $merchant_key, $server_type);
        $item2 = new GoogleItem($params['item_name'],'', 2, $params['amount'], $params['currencyID']);
        $cart->AddItem($item2);

This works as far as sending the correct amount to Google but the contribution saved in CiviContribute only picks up the first amount. Also , when the value of the contribution is zero, then the Google Checkout button is not displayed.

So... Questions:

1. How can I get CiviContribute to record all the contributions?
2. How do I discard Contributions with zero value from the cart?
3. Is it possible to get the contribution label to show on the summary screen instead of "Contribution Amount"?
4. When the data is passed to Google Checkout to process the items show up as "Online Contribution-Name of Contribution Page". Could this also append the contribuition label? eg Subs, Insurance, Magazine Subscription etc.
5. Is there another way of achieving this? I investigated a new domain and membership type for insurance but it didn't fly.

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 08:28:14 am
Correction - Modifying civicrm/CRM/Core/Payment/Google.php doesn't work correctly.  As I did it it adds a second item into the cart with a quantity of 2. Since my test values were 15 and 30 it appeared the second item was going through when in reality it is just twice 15!!! Another reason for giving more information than just the Page Title as the checkout item description.

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: Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 11:59:25 am

The "Separate Membership Transaction" warning should read as "This option is NOT supported for PayPal Website Payments standard AND google checkout). Both these methods are callback based methods and doing two transactions is more complicated and hence we've skipped it.

Can u check and test if this works without the seperate payment membership option. i.e. we clump both the amounts in one amount

thanx

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

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 01:09:05 pm
Hi Lobo,

Bundling to one amount will work. The main reason why I was looking at the separate payments was so we can identify what the funds are for.

Also a side effect of this is that the contribution amounts need to also include the membership fee. This means that a member has to choose there membership level (of which there are 7) and then their other fee uplifts. With 2 fee uplifts that means I need 14 price options. With 3 price uplifts it gets even more complicated.

Separate payments would clearly be slicker here. I could go for other payment processors but Google pricing is very sharp (free until 2008 and then far less the PayPal).

I'm also puzzling over these two problems.

1) How do you deal with one person paying for a "Joint Membership"?

2) How do you stop people applying for memberships which there not entitled to? (We have a load of Life members from a funding raising exercise many many years ago).   Would be nice if there were some rules around this. For instance if a probationary member was renewing they would only be offered that membership level.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 03:10:11 pm
Quote from: speleo on August 13, 2007, 01:09:05 pm
Also a side effect of this is that the contribution amounts need to also include the membership fee. This means that a member has to choose there membership level (of which there are 7) and then their other fee uplifts. With 2 fee uplifts that means I need 14 price options. With 3 price uplifts it gets even more complicated.

Separate payments would clearly be slicker here. I could go for other payment processors but Google pricing is very sharp (free until 2008 and then far less the PayPal).

Chatting with Lobo about this - and we're not currently planning to support separate payments for the "callback-based" processor options as they're much more complicated to deal with and hard to debug etc. Hopefully Google will move to offering an API based solution in the near future :-)

Quote from: speleo on August 13, 2007, 01:09:05 pm
I'm also puzzling over these two problems.
1) How do you deal with one person paying for a "Joint Membership"?

2) How do you stop people applying for memberships which there not entitled to? (We have a load of Life members from a funding raising exercise many many years ago).   Would be nice if there were some rules around this. For instance if a probationary member was renewing they would only be offered that membership level.

1) Currently, you can create memberships that cover "related contacts" - and offer those online. However, you would have to manually add the related contact / relationship (perhaps based on some custom fields that you add via a profile on the signup page).

2) I think there's quite a bit of room for improvement / additional functionality in CiviMember's "online renewal" feature. It would be great if you would help push this forward by detailing out requirements on the "Phase 2 specifications" page ( http://wiki.civicrm.org/confluence//x/uzI ) -  and then getting some  discussion going with other CiviMember users to help validate / generalize the approach and options.

Protect your investment in CiviCRM by  becoming a Member!

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 13, 2007, 03:14:37 pm
Thanks Dave. I'll flesh out my thoughts about the whole membership renewal process over the next week or so and get some discussion going. Be good to get this locked down before the v2 feature freeze.


speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 14, 2007, 05:50:45 am
I've worked out that I can filter the Memberships Renewal to only show the contacts current membership by adding this:

    {if $row.current_membership AND $context EQ "makeContribution"}
        ....
    {/if}

civicrm\templates\CRM\Contribute\Form\Contribution\MembershipBlock.tpl

Quote
        <table id="membership-listings" class="no-border">
        {foreach from=$membershipTypes item=row }
           {if $row.current_membership AND $context EQ "makeContribution" }
           <tr {if $context EQ "makeContribution" OR $context EQ "thankContribution" }class="odd-row" {/if}valign="top">
               {if $showRadio }
                   {assign var="pid" value=$row.id}
                   <td>{$form.selectMembership.$pid.html}</td>
               {/if}
              <td>
                   <strong>{$row.name}</strong><br />
                   {$row.description} &nbsp;
                   {if ($membershipBlock.display_min_fee AND $context EQ "makeContribution") AND $row.minimum_fee GT 0 }
                       {if $is_separate_payment OR ! $form.amount.label}
                           {ts 1=$row.minimum_fee|crmMoney}(membership fee - %1){/ts}
                       {else}
                           {ts 1=$row.minimum_fee|crmMoney}(contribute at least %1 to be eligible for this membership){/ts}
                       {/if}
                   {/if}
                       
              </td>
           
               <td>
                 {if $row.current_membership AND $context EQ "makeContribution" }
                  <br /><em>{ts 1=$row.current_membership|crmDate 2=$row.name}Your current <strong>%2</strong> membership expires on %1.{/ts}</em>
                 {/if}
              </td>
           </tr>
      {/if}        
        {/foreach}

Now the contact is only offered the option of renewing the membership they currently have. However...the tricky bit is filtering the contributions to only show the ones relevant to that membership level. I thought I could do this in the templates as well but on investigation it doesn't look so easy. Where does the array for the Fixed Contribution Options get built?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 14, 2007, 07:38:48 am
Quote
Where does the array for the Fixed Contribution Options get built?

I think you're asking about the amount radio buttons (e.g. Insurance options in your screenshot)? If so, the radio button form field is built in CRM/Contribute/Form/Contribution/Main.php - in the buildAmount() function.
Protect your investment in CiviCRM by  becoming a Member!

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 14, 2007, 12:54:58 pm
Thanks Dave, That's exactly what I was after!!

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: Membership renewal with Google Checkout & Separate Membership Payment
August 15, 2007, 05:09:34 am
With the change to civicrm\templates\CRM\Contribute\Form\Contribution\MembershipBlock.tpl in the posts below, I've now worked out a method just displaying the contributions applicable to the contacts current membership type.

I've achieved this by modifying the CRM\Contribute\Form\Contribution\Main.php file as show below.

This is the origional code starting at line 232
Code: [Select]
    function buildAmount( $separateMembershipPayment = false )
    {
        $elements = array( );

        // first build the radio boxes
        if ( ! empty( $this->_values['label'] ) ) {
            require_once 'CRM/Utils/Money.php';
            for ( $index = 1; $index <= count( $this->_values['label'] ); $index++ ) {
                $elements[] =& $this->createElement('radio', null, '',
                                                    CRM_Utils_Money::format($this->_values['value'][$index]) . ' ' . $this->_values['label'][$index],
                                                    $this->_values['amount_id'][$index],
                                                    array('onclick'=>'clearAmountOther();'));
                                                    }
            }

with this:
Code: [Select]
    function buildAmount( $separateMembershipPayment = false )
    {
        $elements = array( );

        // first build the radio boxes
        if ( ! empty( $this->_values['label'] ) ) {
    require_once 'CRM/Utils/Money.php';


    // find out the current membership status of the contact
    // and place the result in array $contactMemStatus
    $session =& CRM_Core_Session::singleton( );
    $contactID = $session->get( 'userID' );
            require_once 'api/v2/Membership.php';
    $contactMemStatus = civicrm_contact_memberships_get($contactID);

    // search through the array for the key membership_name and place
    // the result in $ContactMemS.
    // This assumes that a member only has a single membership record.
    // I'm sure there is a neater way of doing this...
    foreach($contactMemStatus as $key=>$value) {
    if (is_array($value)){
    foreach($value as $key1=>$value1) {
    if (is_array($value1)){
foreach($value1 as $key2=>$value2) {
if ($key2 == 'membership_name') {
$ContactMemS = $value2;
}
}
    }
    }
    }
    }

    for ( $index = 1; $index <= count( $this->_values['label'] ); $index++ ) {
   
    // Check to see if the Contribution Amounts relate to the
    // the contacts current membership type and discard others.
    // This assumes that the Contribution Amount label includes
    // the membership type label.
    if (stripos($this->_values['label'][$index],
    $ContactMemS)
    !== false) {

// continue to build the radio buttons
    $elements[] =& $this->createElement('radio', null, '',
    CRM_Utils_Money::format($this->_values['value'][$index]) . ' ' . $this->_values['label'][$index],
                            $this->_values['amount_id'][$index],
    array('onclick'=>'clearAmountOther();'));
    }

    }
        }

I'm sure you can tell by the above code that I'm not too hot with PHP!!

This will get the contacts current membership type (Ordinary, Joint, Life, etc) and do an instring search against the contribution label to ensure that only the relevant contributions get offered. For example, I'm an "ordinary" member, when I go to renew my membership I'm only shown my current membership type and the contribution options associated with it.

However, I now found another problem which could be a show stopper. I setup a test user account with Google Checkout and use this to do test transactions. The transaction goes through fine but when I go back to my contact I find the contacts name and address have been changed that of the Google Checkout test account. So...If a member pays using an account which does not match his name and address then it will automagically alter his contact record. Upshot is that we start to loose members.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Membership renewal with Google Checkout & Separate Membership Payment

This forum was archived on 2017-11-26.