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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Which function - complete a pay later transaction
Pages: [1]

Author Topic: Which function - complete a pay later transaction  (Read 1287 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Which function - complete a pay later transaction
January 03, 2010, 02:37:19 am
Hello,

The answer doesn't seem to be leaping out at me so a pointer would be appreciated - I'm trying to figure out which function to use to receipt on a pay later payment as if it were being done in the front end - ie. the receipt e-mail should be sent out and the participation record should be confirmed.

I think one of the API calls should do this but I'm not sure which one

Or perhaps:

    Contribution/BAO/Contribution/Contributions::create(&$params, &$ids)

NB - when the $ids array is passed around is there a standard format ? - something like
$ids( contribution_id -> x,
contact_id -> y)

I always wind up reverse engineering the code everytime I see $params or $ids to figure out what should be in the array but I'm sure there must be some easier logic I could follow.


 
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

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: Which function - complete a pay later transaction
January 03, 2010, 10:42:10 am

check:

CRM/Contribute/Form/Task/Status.php

specifically function postProcess( )

there are a bunch of steps involved that we've tried to centralize in one place (BaseIPN.php)

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Which function - complete a pay later transaction
January 05, 2010, 05:08:48 pm
OK - here is what I used to confirm a transaction.

Code: [Select]
        require_once 'CRM/Core/Payment/BaseIPN.php';
        $baseIPN = new CRM_Core_Payment_BaseIPN( );
        require_once 'CRM/Core/Transaction.php';
        $transaction = new CRM_Core_Transaction( );
        $amount = $document->Invoices->Invoice->Total;

        $input['component'] = 'event';
$input['check_number'] = $field['check_number'];
        $input['total_amount'] = $amount;
        $input['amount'] = $amount;                                  // goes into the civicrm_financial_trxn table as 'total amount'
        $input['net_amount']                = $amount;
        $input['is_test']               = 0;
        $input['fee_amount']            = 0;
       $input['payment_instrument_id'] = 5;     // per - civicrm/admin/options/payment_instrument&group=payment_instrument&reset=1
        $input['receive_date']            = date( 'YmdHis' );
        $ids['contact' ]      = $field['contact_id'];
        $ids['contribution']      = $field['contribution_id'];
        $ids['participant']      = $field['id'];
        $ids['event']      = $field['civicrm_event_id'];
        $input['trxn_id'] = $paymentID;
         if ( ! $baseIPN->validateData( $input, $ids, $objects, false ) ) {
                CRM_Core_Error::fatal( );
            }
         $baseIPN->completeTransaction( $input, $ids, $objects, $transaction, false );
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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Which function - complete a pay later transaction

This forum was archived on 2017-11-26.