Payment.sendconfirmation api - add further tpl variables.
authoreileen <emcnaughton@wikimedia.org>
Fri, 15 Feb 2019 18:07:18 +0000 (07:07 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 15 Feb 2019 18:07:44 +0000 (07:07 +1300)
This is a continuance of the introduction of this api

CRM/Contribute/BAO/Contribution.php
CRM/Financial/BAO/Payment.php
tests/phpunit/api/v3/PaymentTest.php

index dc7a4f208f41552a06e6d8ea51b3d3b869d788b6..1a444fcc62cff7e767671473dd21436e44677b96 100644 (file)
@@ -4832,7 +4832,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
     $balanceTrxnParams['from_financial_account_id'] = $fromFinancialAccountId;
     $balanceTrxnParams['total_amount'] = $params['total_amount'];
     $balanceTrxnParams['contribution_id'] = $params['contribution_id'];
-    $balanceTrxnParams['trxn_date'] = !empty($params['contribution_receive_date']) ? $params['contribution_receive_date'] : date('YmdHis');
+    $balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis')));
     $balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
     $balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('total_amount', $params);
     $balanceTrxnParams['currency'] = $contribution['currency'];
index 2897ee1526ea4be1864c07af265020d73c53c5e3..c0fa6d83db2aa5a5c6f500f104775f5546c4ac69 100644 (file)
@@ -212,6 +212,9 @@ class CRM_Financial_BAO_Payment {
       'paymentAmount' => $entities['payment']['total_amount'],
       'event' => NULL,
       'component' => 'contribution',
+      'checkNumber' => CRM_Utils_Array::value('check_number', $entities['payment']),
+      'receive_date' => $entities['payment']['trxn_date'],
+      'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']),
     ];
     if (!empty($entities['event'])) {
       $templateVariables['component'] = 'event';
@@ -240,6 +243,9 @@ class CRM_Financial_BAO_Payment {
       'paymentAmount',
       'event',
       'component',
+      'checkNumber',
+      'receive_date',
+      'paidBy',
     ];
     // Need to do these before switching the form over...
     $todoParams = [
@@ -247,9 +253,6 @@ class CRM_Financial_BAO_Payment {
       'totalPaid',
       'refundAmount',
       'paymentsComplete',
-      'receive_date',
-      'paidBy',
-      'checkNumber',
       'contributeMode',
       'isAmountzero',
       'billingName',
index 5585a58f6b82db4c34b82d8b834ebae4c01352d6..b4e94d656fc363fcec2bee5ac6d6ffe084266b43 100644 (file)
@@ -113,6 +113,8 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
     $params = array(
       'contribution_id' => $contribution['id'],
       'total_amount' => 50,
+      'check_number' => '345',
+      'trxn_date' => '2018-08-13 17:57:56',
     );
     $payment = $this->callAPISuccess('payment', 'create', $params);
     $this->checkPaymentResult($payment, [
@@ -133,6 +135,9 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
       'This Payment Amount: $ 50.00',
       'Balance Owed: $ 100.00', //150 was paid in the 1st payment.
       'Event Information and Location',
+      'Paid By: Check',
+      'Check Number: 345',
+      'Transaction Date: August 13th, 2018  5:57 PM',
     ));
     $mut->stop();
   }