$this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']);
}
+ /**
+ * Test that when a transaction fails the pending contribution remains.
+ *
+ * An activity should also be created. CRM-16417.
+ */
+ public function testSubmitPaymentProcessorFailure() {
+ $this->setUpContributionPage();
+ $this->setupPaymentProcessor();
+ $this->createLoggedInUser();
+ $priceFieldID = reset($this->_ids['price_field']);
+ $priceFieldValueID = reset($this->_ids['price_field_value']);
+ $submitParams = array(
+ 'price_' . $priceFieldID => $priceFieldValueID,
+ 'id' => (int) $this->_ids['contribution_page'],
+ 'amount' => 10,
+ 'payment_processor_id' => 1,
+ 'credit_card_number' => '4111111111111111',
+ 'credit_card_type' => 'Visa',
+ 'credit_card_exp_date' => array('M' => 9, 'Y' => 2008),
+ 'cvv2' => 123,
+ );
+
+ $this->callAPISuccess('contribution_page', 'submit', $submitParams);
+ $contribution = $this->callAPISuccessGetSingle('contribution', array(
+ 'contribution_page_id' => $this->_ids['contribution_page'],
+ 'contribution_status_id' => 2,
+ ));
+
+ $this->callAPISuccessGetSingle('activity', array(
+ 'source_record_id' => $contribution['id'],
+ 'activity_type_id' => 'Failed Payment',
+ ));
+
+
+ }
+
/**
* Test submit recurring membership with immediate confirmation (IATS style)
* - we process 2 membership transactions against with a recurring contribution against a contribution page with an immediate