public function tearDown() {
$this->quickCleanUpFinancialEntities();
}
+ /**
+ * Ensure recurring contributions from Contribution Pages
+ * with receipt turned off don't send a receipt.
+ */
+ public function testIPNPaymentRecurNoReceipt() {
+ $mut = new CiviMailUtils($this, TRUE);
+ // Turn off receipts in contribution page.
+ $api_params = array(
+ 'id' => $this->_contributionPageID,
+ 'is_email_receipt' => FALSE,
+ );
+ $this->callAPISuccess('contributionPage', 'update', $api_params);
+
+ // Create initial recurring payment and initial contribution.
+ // Note - we can't use setupRecurringPaymentProcessorTransaction(), which
+ // would be convenient because it does not fully mimic the real user
+ // experience. Using setupRecurringPaymentProcessorTransaction() doesn't
+ // specify is_email_receipt so it is always set to 1. We need to more
+ // closely mimic what happens with a live transaction to test that
+ // is_email_receipt is not set to 1 if the originating contribution page
+ // has is_email_receipt set to 0.
+ $form = new CRM_Contribute_Form_Contribution();
+ $form->_mode = 'Live';
+ $contribution = $form->testSubmit(array(
+ 'total_amount' => 200,
+ 'financial_type_id' => 1,
+ 'receive_date' => date('m/d/Y'),
+ 'receive_date_time' => date('H:i:s'),
+ 'contact_id' => $this->_contactID,
+ 'contribution_status_id' => 1,
+ 'credit_card_number' => 4444333322221111,
+ 'cvv2' => 123,
+ 'credit_card_exp_date' => array(
+ 'M' => 9,
+ 'Y' => 2025,
+ ),
+ 'credit_card_type' => 'Visa',
+ 'billing_first_name' => 'Junko',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => 'Adams',
+ 'billing_street_address-5' => time() . ' Lincoln St S',
+ 'billing_city-5' => 'Maryknoll',
+ 'billing_state_province_id-5' => 1031,
+ 'billing_postal_code-5' => 10545,
+ 'billing_country_id-5' => 1228,
+ 'frequency_interval' => 1,
+ 'frequency_unit' => 'month',
+ 'installments' => '',
+ 'hidden_AdditionalDetail' => 1,
+ 'hidden_Premium' => 1,
+ 'payment_processor_id' => $this->_paymentProcessorID,
+ 'currency' => 'USD',
+ 'source' => 'bob sled race',
+ 'contribution_page_id' => $this->_contributionPageID,
+ 'is_recur' => TRUE,
+ ), CRM_Core_Action::ADD);
+
+ $this->_contributionID = $contribution->id;
+ $this->_contributionRecurID = $contribution->contribution_recur_id;
+ $recur_params = array(
+ 'id' => $this->_contributionRecurID,
+ 'return' => 'processor_id',
+ );
+ $processor_id = civicrm_api3('ContributionRecur', 'getvalue', $recur_params);
+ // Process the initial one.
+ $IPN = new CRM_Core_Payment_AuthorizeNetIPN(
+ $this->getRecurTransaction(array('x_subscription_id' => $processor_id))
+ );
+ $IPN->main();
+
+ // Now send a second one (authorize seems to treat first and second contributions
+ // differently.
+ $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction(
+ array('x_subscription_id' => $processor_id)
+ ));
+ $IPN->main();
+
+ // There should not be any email.
+ $mut->assertMailLogEmpty();
+ }
/**
* Test IPN response updates contribution_recur & contribution for first & second contribution
/**
* @return array
*/
- public function getRecurSubsequentTransaction() {
+ public function getRecurSubsequentTransaction($params = array()) {
return array_merge($this->getRecurTransaction(), array(
'x_trans_id' => 'second_one',
'x_MD5_Hash' => 'EA7A3CD65A85757827F51212CA1486A8',
- ));
+ ), $params);
}
}