$this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId);
}
+ /**
+ * Function tests that financial records are updated when Payment Instrument is changed when amount is negative.
+ */
+ public function testCreateUpdateNegativeContributionPaymentInstrument() {
+ $instrumentId = $this->_addPaymentInstrument();
+ $contribParams = array(
+ 'contact_id' => $this->_individualId,
+ 'total_amount' => -100.00,
+ 'financial_type_id' => $this->_financialTypeId,
+ 'payment_instrument_id' => 4,
+ 'contribution_status_id' => 1,
+
+ );
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
+
+ $newParams = array_merge($contribParams, array(
+ 'id' => $contribution['id'],
+ 'payment_instrument_id' => $instrumentId,
+ )
+ );
+ $contribution = $this->callAPISuccess('contribution', 'create', $newParams);
+ $this->assertAPISuccess($contribution);
+ $this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId, array('total_amount' => '-100.00'));
+ }
+
/**
* Function tests that financial records are added when Contribution is Refunded.
*/
'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.
*/
$trxnParams1 = array(
'id' => $trxn['financial_trxn_id'],
);
- $compareParams = array(
- 'total_amount' => -100,
- 'status_id' => 1,
- );
+ if (empty($extraParams)) {
+ $compareParams = array(
+ 'total_amount' => -100,
+ 'status_id' => 1,
+ );
+ }
+ else {
+ $compareParams = array(
+ 'total_amount' => 100,
+ 'status_id' => 1,
+ );
+ }
if ($context == 'paymentInstrument') {
$compareParams += array(
'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount(4),