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) »
  • Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
Pages: [1]

Author Topic: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!  (Read 834 times)

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
March 04, 2014, 05:44:54 pm
Greetings,

In testing on a brand new clean install of CiviCRM, we just discovered something inconsistent, but that actually works. (Installed 4.4.3, updated to 4.4.4 prior to testing.)

For our site, the main use of CiviCRM we need combine:
1) CiviMembership - as it is a website with paid membership component
2) CiviContribution - to collect the funds
3) CiviProfile - to gather contact information

A fourth aspect which we have disabled presently is to have the CiviProfile create a Drupal account, however for testing purposes we do not wish to fabricate countless test Drupal accounts.

So, we had this scenario configured, and specifically the CiviContribution "Financial Type" was set to "Member Dues". Transactions against the PayJunction test gateway were getting stuck in processing state and would never complete.

We went back in as straight up CiviContribution Donation transactions process through to completion... so we set the "Financial Type" of the site membership join page to "Donation" and test transactions process through to completion.

Further, on the Contribution Dashboard, in the "Type" column, we see transactions which now complete properly show up as "Member Dues".

Questions:

1) What within CiviCRM is different between a "Financial Type" --> "Member Dues" verses "Donation" that would cause CiviCRM to drop the response coming back from PayJunction?

2) Where is the disconnect that now that we have reconfigured the CiviContribute page for site memberships to "Financial Type" --> "Donation" do the transactions show up as "Member Dues" on the Contribution Dashboard?
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
March 06, 2014, 06:19:44 am
I thought to set up some test cases on http://drupal.demo.civicrm.org/ in order to reproduce our findings somewhere that people could touch/feel/help us with.

The language of that test site seems to be set to non English. Is it intended to be configured that way presently?

Resolution: It was simple enough to reconfigure it back from Italian to USA English. Off to set up test cases...
« Last Edit: March 06, 2014, 06:25:05 am by mdlueck »
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
March 21, 2014, 11:45:55 am
Still trying to track down why PayJunction transactions do not complete on our server, however do on the CiviCRM Drupal demo site.

Today I thought to track down where in the CiviCRM code wraps the module (packages/PayJunction/pjClasses.php) I added logging to a while ago. Seems it is wrapped by yet another PayJunction specific file: CRM/Core/Payment/PayJunction.php

I added more logging, then ran a live transaction to the PayJunction test gateway, same as I tested successfully on the CiviCRM Drupal demo site.

Modifications to packages/PayJunction/pjClasses.php as follows:
Code: [Select]
    // create a pjpgRequest object passing the transaction object
    $pjpgRequest = new pjpgRequest($pjpgTxn);
//error_log("PayJunction.php doDirectPayment new pjpgRequest, pjpgRequest = >" . $pjpgRequest . "<");

    $pjpgHttpPost = new pjpgHttpsPost($pjpgRequest);
//error_log("PayJunction.php doDirectPayment new pjpgHttpsPost, pjpgHttpPost = >" . $pjpgHttpPost . "<");

    // get an pjpgResponse object
    $pjpgResponse = $pjpgHttpPost->getPJpgResponse();
error_log("PayJunction.php doDirectPayment pjpgHttpPost->getPJpgResponse, pjpgResponse = >" . $pjpgResponse . "<");

    if (self::isError($pjpgResponse)) {
error_log("PayJunction.php doDirectPayment isError of pjpgResponse was true");
      return self::error($pjpgResponse);
    }

    /* Check for application errors */

    $result = self::checkResult($pjpgResponse);
    if (is_a($result, 'CRM_Core_Error')) {
error_log("PayJunction.php doDirectPayment application error was true, result = >" . $result . "<");
      return $result;
    }

    // Success
    $params['trxn_result_code'] = $pjpgResponse['dc_response_code'];
    $params['trxn_id'] = $pjpgResponse['dc_transaction_id'];
    $params['gross_amount'] = $params['amount'];
error_log("PayJunction.php doDirectPayment Success");

    return $params;
  }
  // end function doDirectPayment


  /*
   * This function checks the PayJunction response code
   */
  function isError(&$response) {
    $responseCode = $response['dc_response_code'];

    if ($responseCode == "00" || $responseCode == "85") {
error_log("PayJunction.php isError FALSE");
      return FALSE;
    }
    else {
error_log("PayJunction.php isError TRUE");
      return TRUE;
    }
  }


  // ignore for now, more elaborate error handling later.
  function &checkResult(&$response) {
error_log("PayJunction.php checkResult");
    return $response;
  }

It appears that PayJunction accepted the charge and processed smoothly. Why is CiviCRM not understanding that, leaving transactions in "pending" state after a several second delay/pause?

Output from my test transaction is as follows:

Code: [Select]
[Fri Mar 21 15:48:20 2014] [error] [client *.*.*.*] pjClasses.php url = >https://www.payjunctionlabs.com/quick_link<, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:20 2014] [error] [client *.*.*.*] pjClasses.php request = >dc_logon=pj-ql-01&dc_password=pj-ql-01p&dc_first_name=Michael&dc_last_name=Lueck&dc_expiration_month=02&dc_expiration_year=2023&dc_number=4444333322221111&dc_verification_number=000&dc_transaction_amount=15.00&dc_transaction_type=AUTHORIZATION_CAPTURE&dc_version=1.2&dc_address=123+Any+Road&dc_city=Any+Town&dc_state=AL&dc_zipcode=12345&dc_country=US&dc_schedule_create=true&dc_schedule_limit=999&dc_schedule_periodic_number=1&dc_schedule_periodic_type=month&dc_schedule_start=2014-03-21&<, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:22 2014] [error] [client *.*.*.*] pjClasses.php Curl error = ><, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:23 2014] [error] [client *.*.*.*] pjClasses.php content = >dc_merchant_name=PayJunction Demo\x1cdc_merchant_address=1903 State Street\x1cdc_merchant_city=Santa Barbara\x1cdc_merchant_state=CA\x1cdc_merchant_zip=93101\x1cdc_merchant_phone=800-601-0230\x1cdc_device_id=313\x1cdc_transaction_date=2014-03-21 12:48:13\x1cdc_transaction_action=charge\x1cdc_approval_code=PJ20AP\x1cdc_response_code=00\x1cdc_response_message=APPROVAL PJ20AP\x1cdc_transaction_id=45028\x1cdc_posture=void\x1cdc_invoice_number=\x1cdc_notes=\x1cdc_card_name=Michael Lueck\x1cdc_card_brand=VSA\x1cdc_card_exp=XX/XX\x1cdc_card_number=XXXX-XXXX-XXXX-1111\x1cdc_card_address=123 Any Road\x1cdc_card_city=Any Town\x1cdc_card_zipcode=12345\x1cdc_card_state=AL\x1cdc_card_country=US\x1cdc_base_amount=15.00\x1cdc_tax_amount=0.00\x1cdc_capture_amount=15.00\x1cdc_cashback_amount=0.00\x1cdc_shipping_amount=0.00<, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:23 2014] [error] [client *.*.*.*] PayJunction.php doDirectPayment pjpgHttpPost->getPJpgResponse, pjpgResponse = >Array<, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:23 2014] [error] [client *.*.*.*] PayJunction.php isError FALSE, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:23 2014] [error] [client *.*.*.*] PayJunction.php checkResult, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328
[Fri Mar 21 15:48:23 2014] [error] [client *.*.*.*] PayJunction.php doDirectPayment Success, referer: http://d1.orgname.org/civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=954595d80a4a5028e993eb40851a220f_3328

Last line of that Apache log: "Success"

Why is CiviCRM not receiving that Success status back from the PayJunction specific modules?
« Last Edit: March 21, 2014, 12:54:41 pm by mdlueck »
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
March 23, 2014, 06:38:36 am
All right, I think I am onto something...

CRM/Contribute/BAO/Contribution/Utils.php

I added logging of the array coming back from the call to:
$result = $payment->doDirectPayment($paymentParams);

$result consistently has the trxn_result_code and payment_processor fields populated. (For ALL transaction types!)

In the case the transaction is a simple donation further down those fields are still populated within the $contribution array.

For site memberships which are the more complicated transaction type mentioned in my OP:
Quote
For our site, the main use of CiviCRM we need combine:
1) CiviMembership - as it is a website with paid membership component
2) CiviContribution - to collect the funds
3) CiviProfile - to gather contact information

for those, the trxn_result_code and payment_processor fields are blanked out in the $contribution array.

Could this be the reason that the more complicated transactions get stuck in pending state? Where could those fields come up missing between these two enumeration points?

Code: [Select]
      if (is_object($payment)) {
error_log("Utils.php Pre payment->doDirectPayment(paymentParams)");
        $result = $payment->doDirectPayment($paymentParams);
foreach ($result as $LDSkey => $LDSvalue) {
    error_log("Utils.php Post payment->doDirectPayment(paymentParams), result, LDSkey = >" . $LDSkey . "<, LDSvalue = >" . $LDSvalue . "<");
}
      }
      else {
        CRM_Core_Error::fatal($paymentObjError);
      }
    }

    if ($component == 'membership') {
      $membershipResult = array();
    }

    if (is_a($result, 'CRM_Core_Error')) {
      //make sure to cleanup db for recurring case.
      if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
        CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
      }
      if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
        CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
      }

      if ($component !== 'membership') {
        CRM_Core_Error::displaySessionError($result);
        CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact',
            "_qf_Main_display=true&qfKey={$form->_params['qfKey']}"
          ));
      }
      $membershipResult[1] = $result;
    }
    elseif ($result || ($form->_amount == 0.0 && !$form->_params['is_pay_later'])) {
      if ($result) {
        $form->_params = array_merge($form->_params, $result);
      }
      $form->_params['receive_date'] = $now;
      $form->set('params', $form->_params);
      $form->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $result));
      $form->assign('receive_date',
        CRM_Utils_Date::mysqlToIso($form->_params['receive_date'])
      );

      // result has all the stuff we need
      // lets archive it to a financial transaction
      if ($contributionType->is_deductible) {
        $form->assign('is_deductible', TRUE);
        $form->set('is_deductible', TRUE);
      }

      if (isset($paymentParams['contribution_source'])) {
        $form->_params['source'] = $paymentParams['contribution_source'];
      }

      // check if pending was set to true by payment processor
      $pending = FALSE;
      if (CRM_Utils_Array::value('contribution_status_pending',
          $form->_params
        )) {
        $pending = TRUE;
error_log("Utils.php contribution_status_pending TRUE");
      }
      if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
        $contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form,
          $form->_params, $result,
          $contactID, $contributionType,
          TRUE, $pending, TRUE
        );
error_log("Utils.php is_recur direct");
      }
      $form->postProcessPremium($premiumParams, $contribution);

      $membershipResult[1] = $contribution;
    }

//Log the contribution no matter what at this point...
foreach ($contribution as $LDSkey => $LDSvalue) {
    error_log("Utils.php contribution, LDSkey = >" . $LDSkey . "<, LDSvalue = >" . $LDSvalue . "<");
}
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

Wes Reimer

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 1
  • CiviCRM version: 4.4.6
  • CMS version: WordPress 3.9.x
  • MySQL version: 5.5.36-cll
  • PHP version: 5.3.27
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
May 01, 2014, 10:21:45 am
I'm having this same problem with PayPal (sandbox) on a membership signup form. I tried your suggestion of changing the financial type to "Donation" but the contribution status is still "Pending : Incomplete Transaction" and the user is not added as a member (presumably because the transaction did not complete). Do you have any other suggestions?

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
May 02, 2014, 12:26:31 pm
Greetings Wes,

I began again on a different thread. The latest post is here: http://forum.civicrm.org/index.php/topic,32168.msg138698.html#msg138698

Looks to me like the more complicated transactions combining three separate CiviCRM capabilities "get stuck in pending state" and I see the CC gateway success message not getting returned within the CiviCRM code. For memberships, it actually appears to return a different array object than for straight up donation transactions. The CC gateway success details are not populated in that other array the PHP code returns. I have no idea how these three CiviCRM component memberships are ever suppose to complete successfully. Yet my prototype testing on the CiviCRM demo site (with D7) works as expected.  ???

Looks like CiviCRM mishandles the CC gateway success return code in some way. WHERE is the operative question yet to be discovered.

I am thankful,
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

Wes Reimer

  • I post occasionally
  • **
  • Posts: 49
  • Karma: 1
  • CiviCRM version: 4.4.6
  • CMS version: WordPress 3.9.x
  • MySQL version: 5.5.36-cll
  • PHP version: 5.3.27
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
May 07, 2014, 11:30:35 am
UPDATE: I just found out the reason the membership was not added was because I was in test mode, and you can find test memberships in the same way that you find test contributions: Memberships > Find Memberships > Membership is a Test? Yes > Search

So this appears to have nothing to do with the transaction apparently not completing. It still says "Pending : Incomplete Transaction" under the test contribution.

mdlueck

  • Ask me questions
  • ****
  • Posts: 382
  • Karma: 4
  • CiviCRM version: 4.7.24
  • CMS version: Drupal 6.x
  • MySQL version: 5.5.54
  • PHP version: 5.3.10
Re: Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!
May 09, 2014, 04:23:53 am
Greetings Wes,

In our case, we are testing with a copy of our production site on a different domain name. We have installed the test CC gateway configuration into the live CiviCRM CC gateway fields. Thus we are sending "live test" transactions in our case.

Yes, I recall if you run through the actual CiviCRM test settings, some things were less automagic than sending real live translations. Thus I do not believe we should be getting bit by that in our case.

I am thankful,
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Civi 4.4.4 + Pay Junction, discovered a way to make transactions complete, why?!

This forum was archived on 2017-11-26.