From 367b5943204ee8253953d5eb2a994901c544766f Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Fri, 30 Sep 2016 16:06:08 +0530 Subject: [PATCH 1/2] CRM-18027: No credit card transaction details after 4.7 update --- CRM/Contribute/BAO/Contribution.php | 6 +++++- CRM/Core/SelectValues.php | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 2937689fd2b..db99e14b493 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2801,6 +2801,11 @@ public function _assignMessageVariablesToTemplate(&$values, $input, &$template, $template->assign('first_name', $this->_relatedObjects['contact']->first_name); $template->assign('last_name', $this->_relatedObjects['contact']->last_name); $template->assign('displayName', $this->_relatedObjects['contact']->display_name); + + // For some unit tests contribution cannot contain paymentProcessor information + $billingMode = empty($this->_relatedObjects['paymentProcessor']) ? CRM_Core_Payment::BILLING_MODE_NOTIFY : $this->_relatedObjects['paymentProcessor']['billing_mode']; + $template->assign('contributeMode', CRM_Utils_Array::value($billingMode, CRM_Core_SelectValues::contributeMode())); + if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) { $values['useForMember'] = TRUE; } @@ -2884,7 +2889,6 @@ public function _assignMessageVariablesToTemplate(&$values, $input, &$template, CRM_Utils_Date::processDate($this->receive_date) ); $values['receipt_date'] = (empty($this->receipt_date) ? NULL : $this->receipt_date); - $template->assign('contributeMode', 'notify'); $template->assign('action', $this->is_test ? 1024 : 1); $template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index af7f6510b86..c316d6adbbc 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -1012,6 +1012,17 @@ public static function billingMode() { ); } + /** + * @return array + */ + public static function contributeMode() { + return array( + CRM_Core_Payment::BILLING_MODE_FORM => 'direct', + CRM_Core_Payment::BILLING_MODE_BUTTON => 'directIPN', + CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', + ); + } + /** * Frequency unit for schedule reminders. * From 128d44a1a33825cc2b33504787d21f93aca307c1 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 3 Oct 2016 20:19:40 +0530 Subject: [PATCH 2/2] Add unit test --- tests/phpunit/api/v3/ContributionTest.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 498493607cc..d3d1ca43cae 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -2593,9 +2593,36 @@ public function testSendMail() { 'Event', ) ); + + $this->checkCreditCardDetails($mut, $contribution['id']); $mut->stop(); } + /** + * Check credit card details in sent mail via API + * + * @param $mut obj CiviMailUtils instance + * @param int $contributionID Contribution ID + * + */ + public function checkCreditCardDetails($mut, $contributionID) { + $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); + $this->callAPISuccess('contribution', 'sendconfirmation', array( + 'id' => $contributionID, + 'receipt_from_email' => 'api@civicrm.org', + 'payment_processor_id' => $this->paymentProcessorID, + ) + ); + $mut->checkMailLog(array( + 'Credit Card Information', // credit card header + 'Billing Name and Address', // billing header + 'anthony_anderson@civicrm.org', // billing name + ), array( + 'Event', + ) + ); + } + /** * Test sending a mail via the API. */