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) »
  • Payment Processor : WorldPay recurring payments
Pages: [1]

Author Topic: Payment Processor : WorldPay recurring payments  (Read 5120 times)

dougall

  • Guest
Payment Processor : WorldPay recurring payments
August 28, 2008, 05:32:41 am
hi,

I'm writing a payment processor for WorldPay based closely on PayPalImpl & PayPalIPN (i.e. billing_mode 4).

It seems that when a repeat payment is initiated from the Donations page, then both a Contribution and a ContributionRecur are generated (prior to transferring to the payment servers), and there is an assumption that the first IPN will be notification of an actual payment.

This is fine for PayPal, but for WorldPay's recurring payments mechanism (called FuturePay), the initial IPN received is not a payment, it is a notification that a FuturePay agreement has been made (and it provides a FuturePay id for handling the recurring payment subsequently).

Consequently the Contribution that has been already generated is not required at this stage, so I believe my IPN processor for WorldPay should remove it:

So...
- is it safe to just delete a contribution at this stage, or will there be other references to it?
- what is the best way to code the deletion of this contribution?

Thanks,
  Dougall

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Payment Processor : WorldPay recurring payments
August 28, 2008, 06:18:09 am
Quote
- is it safe to just delete a contribution at this stage, or will there be other references to it?
IMO yes.

Quote
- what is the best way to code the deletion of this contribution?
You should use CRM_Contribute_BAO_Contribution::deleteContribution( $contributionId ); for deleting contribution.

HTH

Kurund
Found this reply helpful? Support CiviCRM

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: Payment Processor : WorldPay recurring payments
August 28, 2008, 11:33:40 am

I dont think we assume the first IPN is for the contribution. Might make sense (and simplify the code) to keep the first contribution there, and flip the status when you receive an IPN from worldpayment indicating that it has been completed

any specific reason u think we make the assumption? The IPN code is independent of core and is payment processor specific, so you can have your own rules there :)

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

dougall

  • Guest
Re: Payment Processor : WorldPay recurring payments
August 30, 2008, 03:20:12 am
Sorry, I didn't word myself correctly, this was my assumption rather than yours (PayPalIPN.php is making no assumptions, it's simply doing it's job for PayPal IPNs!).

In PayPaylPN.php in the function recur() there is the following:
Code: [Select]
       if ( ! $first ) {
            // create a contribution and then get it processed
            $contribution =& new CRM_Contribute_DAO_Contribution( );
            $contribution->contact_id = $ids['contact'];
            $contribution->contribution_type_id  = $contributionType->id;
            $contribution->contribution_page_id  = $ids['contributionPage'];
            $contribution->contribution_recur_id = $ids['contributionRecur'];
            $contribution->receive_date          = $now;

            $objects['contribution'] =& $contribution;
        }

So my assumption is this: the first time a recurring payment IPN from PayPal is received, a contribution object is not created here in PayPalIPN since it has already been created by CiviCRM prior to transferring the donor's browser to the payment service. Is this correct?

The reason I was considering deleting this initial contribution is as follows:

For FuturePay (WorldPay's recurring payment mechanism) the initial IPN agreement provides a futurePayId and customized parameters with the relevant CiviCRM ids (contact, contribution, recurring contribution, contribution page and optionally membership).

In subsequent FuturePay IPN payments only the futurePayId is provided, so it is necessary to store these other ids in a db table at the start and retrieve them later when required.

Since the initial contribution is only relevant to the first recurring payment it seems a little inelegant (and possibly slightly confusing) to store it as well, so I thought I'd remove this initial contribution when the agreement is made and then create a new contribution each time a FuturePay payment notification is received.

This avoids the first FuturePay IPN payment being a special case where the contribution_id must be retrieved in addition to the other ids.

I hope this all sounds at least vaguely sensible!

Many thanks again,
  Dougall
« Last Edit: August 30, 2008, 03:22:53 am by dougall »

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: Payment Processor : WorldPay recurring payments
August 30, 2008, 11:42:23 am

Your plan sounds reasonable based on FuturePay's characteristics.

For paypal standard (both recurring and single payments) / google checkout, we create a contribution record and have it all filled up and in a pending state BEFORE we send it off to the payment processor. So the ping back is a bit simpler (for single). Hence we modelled the recurring that way, since it could follow the same flow

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

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Payment Processor : WorldPay recurring payments
January 29, 2009, 12:25:58 am
I don't see this as an option in core - can anyone update me on what happened with WorldPay? cheers
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Payment Processor : WorldPay recurring payments
January 29, 2009, 02:03:41 am
WorldPay is not supported by CiviCRM Core Team and hence not part of Core.

Kurund
Found this reply helpful? Support CiviCRM

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

This forum was archived on 2017-11-26.