3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Core_Payment_BaseIPNTest
16 class CRM_Core_Payment_BaseIPNTest
extends CiviUnitTestCase
{
18 protected $_financialTypeId;
19 protected $_contributionParams;
20 protected $_contactId;
21 protected $_contributionId;
22 protected $_participantId;
25 protected $_processorId;
26 protected $_contributionRecurParams;
27 protected $_paymentProcessor;
30 * Parameters to create a membership.
34 protected $_membershipParams = [];
39 * @var CRM_Core_Payment_BaseIPN
43 protected $_membershipId;
51 protected $_membershipTypeID;
56 protected $_membershipStatusID;
57 public $DBResetRequired = FALSE;
62 public function setUp() {
64 $this->_processorId
= $this->paymentProcessorAuthorizeNetCreate(['is_test' => 0]);
65 $this->input
= $this->ids
= $this->objects
= [];
66 $this->IPN
= new CRM_Core_Payment_AuthorizeNetIPN($this->input
);
68 $this->_contactId
= $this->individualCreate();
69 $this->ids
['contact'] = $this->_contactId
;
70 $this->_financialTypeId
= 1;
72 $this->_contributionParams
= [
73 'contact_id' => $this->_contactId
,
74 'financial_type_id' => $this->_financialTypeId
,
75 'receive_date' => date('Ymd'),
76 'total_amount' => 150.00,
77 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
79 'contribution_recur_id' => $this->_recurId
,
80 'contribution_status_id' => 2,
82 $contribution = $this->callAPISuccess('contribution', 'create', $this->_contributionParams
);
83 $this->_contributionId
= $contribution['id'];
85 $contribution = new CRM_Contribute_BAO_Contribution();
86 $contribution->id
= $this->_contributionId
;
87 $contribution->find(TRUE);
88 $this->objects
['contribution'] = $contribution;
92 * Tear down after class.
94 public function tearDown() {
95 $this->quickCleanUpFinancialEntities();
96 CRM_Member_PseudoConstant
::membershipType(NULL, TRUE);
97 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
101 * Test the LoadObjects function with recurring membership data.
103 public function testLoadMembershipObjects() {
104 $this->_setUpMembershipObjects();
105 $this->_setUpRecurringContribution();
106 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
107 $this->assertFalse(empty($this->objects
['membership']));
108 $this->assertArrayHasKey($this->_membershipTypeID
, $this->objects
['membership']);
109 $this->assertTrue(is_a($this->objects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
110 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
111 $this->assertFalse(empty($this->objects
['contributionRecur']));
112 $this->assertFalse(empty($this->objects
['paymentProcessor']));
116 * Test the LoadObjects function with recurring membership data.
118 public function testLoadMembershipObjectsNoLeakage() {
119 $this->_setUpMembershipObjects();
120 $this->_setUpRecurringContribution();
121 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
122 $this->assertEquals('Anthony', $this->objects
['contact']->first_name
);
124 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate([
125 'first_name' => 'Donald',
126 'last_name' => 'Duck',
127 'email' => 'the-don@duckville.com',
129 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, ['invoice_id' => 'abc']));
130 $this->_contributionId
= $contribution['id'];
131 $this->_setUpMembershipObjects();
132 $this->input
['invoiceID'] = 'abc';
133 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
134 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
138 * Test the LoadObjects function with recurring membership data.
140 public function testLoadMembershipObjectsLoadAll() {
141 $this->_setUpMembershipObjects();
142 $this->_setUpRecurringContribution();
143 unset($this->ids
['membership']);
144 $contribution = new CRM_Contribute_BAO_Contribution();
145 $contribution->id
= $this->_contributionId
;
146 $contribution->find(TRUE);
147 $contribution->loadRelatedObjects($this->input
, $this->ids
, TRUE);
148 $this->assertFalse(empty($contribution->_relatedObjects
['membership']));
149 $this->assertArrayHasKey($this->_membershipTypeID
, $contribution->_relatedObjects
['membership']);
150 $this->assertTrue(is_a($contribution->_relatedObjects
['membership'][$this->_membershipTypeID
], 'CRM_Member_BAO_Membership'));
151 $this->assertTrue(is_a($contribution->_relatedObjects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
152 $this->assertFalse(empty($contribution->_relatedObjects
['contributionRecur']));
153 $this->assertFalse(empty($contribution->_relatedObjects
['paymentProcessor']));
157 * Test the LoadObjects function with recurring membership data.
159 public function testsendMailMembershipObjects() {
160 $this->_setUpMembershipObjects();
162 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
163 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
164 $this->assertTrue(is_array($msg), "Message returned as an array in line");
165 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
166 $this->assertContains('Membership Type: General', $msg['body']);
170 * Test the LoadObjects function data does not leak.
172 * If more than one iteration takes place the variables should not leak.
174 public function testSendMailMembershipObjectsNoLeakage() {
175 $this->_setUpMembershipObjects();
177 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
178 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
179 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
180 $this->assertContains('Membership Type: General', $msg['body']);
182 $this->ids
['contact'] = $this->_contactId
= $this->individualCreate(['prefix_id' => 'Dr.', 'first_name' => 'Donald', 'last_name' => 'Duck', 'email' => 'the-don@duckville.com']);
183 $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams
, ['invoice_id' => 'abc']));
184 $this->_contributionId
= $contribution['id'];
186 $this->_membershipTypeID
= $this->membershipTypeCreate(['name' => 'Fowl']);
187 $this->_setUpMembershipObjects();
188 $this->input
['invoiceID'] = 'abc';
189 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
190 $this->assertEquals('Donald', $this->objects
['contact']->first_name
);
191 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
192 $this->assertEquals('Dr. Donald Duck II', $msg['to']);
193 $this->assertContains('Membership Type: Fowl', $msg['body']);
197 * Test the LoadObjects function with recurring membership data.
199 public function testsendMailMembershipWithoutLoadObjects() {
200 $this->_setUpMembershipObjects();
202 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
203 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
204 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
205 $this->assertContains('Membership Type: General', $msg['body']);
209 * Test that loadObjects works with participant values.
211 public function testLoadParticipantObjects() {
212 $this->_setUpParticipantObjects();
213 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
214 $this->assertFalse(empty($this->objects
['participant']));
215 $this->assertTrue(is_a($this->objects
['participant'], 'CRM_Event_BAO_Participant'));
216 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
217 $this->assertFalse(empty($this->objects
['event']));
218 $this->assertTrue(is_a($this->objects
['event'], 'CRM_Event_BAO_Event'));
219 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
220 $this->assertFalse(empty($this->objects
['event']->id
));
224 * Test the LoadObjects function with a participant.
226 public function testComposeMailParticipant() {
227 $this->_setUpParticipantObjects();
228 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
230 $this->assertFalse(empty($this->objects
['event']));
231 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
232 $this->assertContains('registration has been received and your status has been updated to Attended.', $msg['body']);
233 $this->assertContains('Annual CiviCRM meet', $msg['html']);
238 public function testComposeMailParticipantObjects() {
239 $this->_setUpParticipantObjects();
241 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
242 $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__
);
243 $this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
244 $this->assertContains('Thank you for your registration', $msg['body']);
248 * Test the LoadObjects function with recurring membership data.
250 public function testsendMailParticipantObjectsCheckLog() {
251 $this->_setUpParticipantObjects();
253 $mut = new CiviMailUtils($this, TRUE);
254 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
255 $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, FALSE);
257 'Thank you for your registration',
258 'Annual CiviCRM meet',
259 'Mr. Anthony Anderson II',
265 * Test the LoadObjects function with recurring membership data.
267 public function testsendMailParticipantObjectsNoMail() {
268 $this->_setUpParticipantObjects();
269 $event = new CRM_Event_BAO_Event();
270 $event->id
= $this->_eventId
;
271 $event->is_email_confirm
= FALSE;
274 $tablesToTruncate = [
275 'civicrm_mailing_spool',
277 $this->quickCleanup($tablesToTruncate, FALSE);
278 $mut = new CiviMailUtils($this, TRUE);
279 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
280 $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, FALSE);
281 $mut->assertMailLogEmpty('no mail should have been send as event set to no confirm');
286 * Test that loadObjects works with participant values.
288 public function testLoadPledgeObjects() {
289 $this->_setUpPledgeObjects();
290 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
291 $this->assertFalse(empty($this->objects
['pledge_payment'][0]));
292 $this->assertTrue(is_a($this->objects
['financialType'], 'CRM_Financial_BAO_FinancialType'));
293 $this->assertTrue(is_a($this->objects
['contribution'], 'CRM_Contribute_BAO_Contribution'));
294 $this->assertTrue(is_a($this->objects
['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment'));
295 $this->assertFalse(empty($this->objects
['pledge_payment'][0]->id
));
296 $this->assertEquals($this->_financialTypeId
, $this->objects
['financialType']->id
);
297 $this->assertEquals($this->_processorId
, $this->objects
['paymentProcessor']['id']);
298 $this->assertEquals($this->_contributionId
, $this->objects
['contribution']->id
);
299 $this->assertEquals($this->_contactId
, $this->objects
['contact']->id
);
300 $this->assertEquals($this->_pledgeId
, $this->objects
['pledge_payment'][0]->pledge_id
);
304 * Test that loadObjects works with participant values.
306 public function testLoadPledgeObjectsInvalidPledgeID() {
307 $this->_setUpPledgeObjects();
308 $this->ids
['pledge_payment'][0] = 0;
309 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
310 $this->assertArrayHasKey('error_message', $result);
311 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
312 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
313 $this->ids
['pledge_payment'][0] = NULL;
314 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
315 $this->assertArrayHasKey('error_message', $result);
316 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
317 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
318 $this->ids
['pledge_payment'][0] = '';
319 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
320 $this->assertArrayHasKey('error_message', $result);
321 $this->assertArrayNotHasKey('pledge_payment', $this->objects
);
322 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
324 $this->ids
['pledge_payment'][0] = 999;
325 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, $this->_processorId
, ['return_error' => 1]);
326 $this->assertArrayHasKey('error_message', $result);
327 $this->assertEquals('Could not find pledge payment record: 999', $result['error_message']);
331 * Test the LoadObjects function with a pledge.
333 public function testsendMailPledge() {
334 $this->_setUpPledgeObjects();
336 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL);
337 $msg = $this->IPN
->sendMail($this->input
, $this->ids
, $this->objects
, $values, FALSE, TRUE);
338 $this->assertContains('Contribution Information', $msg['html']);
342 * Test that an error is returned if required set & no contribution page.
344 public function testRequiredWithoutProcessorID() {
345 $this->_setUpPledgeObjects();
346 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
347 $this->assertArrayHasKey('error_message', $result);
348 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
349 // error is only returned if $required set to True
350 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, ['return_error' => 1]);
351 $this->assertFalse(is_array($result));
352 //check that error is not returned if error checking not set
353 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['log_error' => 1]);
354 $this->assertFalse(is_array($result));
358 * Test that an error is not if required set & no processor ID
360 public function testRequiredWithContributionPage() {
361 $this->_setUpContributionObjects(TRUE);
362 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
363 $this->assertEquals(1, $result['is_error']);
368 * Test that if part of $input the payment processor loads OK.
370 * It's preferable to pass it in as it cannot be correctly calculated.
372 public function testPaymentProcessorLoadsAsParam() {
373 $this->_setUpContributionObjects();
374 $this->input
= array_merge($this->input
, ['payment_processor_id' => $this->_processorId
]);
375 $this->assertTrue($this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]));
379 * Test that an error is returned if required set & contribution page exists
381 public function testRequiredWithContributionPageError() {
382 $this->_setUpContributionObjects();
383 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['return_error' => 1]);
384 $this->assertArrayHasKey('error_message', $result);
385 $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
386 // error is only returned if $required set to True
387 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, NULL, ['return_error' => 1]);
388 $this->assertFalse(is_array($result));
389 //check that error is not returned if error checking not set
390 $result = $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, TRUE, NULL, ['log_error' => 1]);
391 $this->assertFalse(is_array($result));
394 public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
395 $this->_setUpParticipantObjects('Pending from incomplete transaction');
396 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
397 $additionalParticipantId = $this->participantCreate([
398 'event_id' => $this->_eventId
,
399 'registered_by_id' => $this->_participantId
,
400 'status_id' => 'Pending from incomplete transaction',
403 $transaction = new CRM_Core_Transaction();
404 $this->IPN
->cancelled($this->objects
, $transaction);
406 $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
408 'id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
409 'status_id' => 'Cancelled',
411 $this->assertEquals(2, $cancelledParticipantsCount);
413 $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
415 'activity_type_id' => 'Event Registration',
416 'subject' => ['LIKE' => '%Cancelled%'],
417 'source_record_id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
420 $this->assertEquals(2, $cancelledActivatesCount['count']);
423 public function testThatFailedEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
424 $this->_setUpParticipantObjects('Pending from incomplete transaction');
425 $this->IPN
->loadObjects($this->input
, $this->ids
, $this->objects
, FALSE, $this->_processorId
);
426 $additionalParticipantId = $this->participantCreate([
427 'event_id' => $this->_eventId
,
428 'registered_by_id' => $this->_participantId
,
429 'status_id' => 'Pending from incomplete transaction',
432 $transaction = new CRM_Core_Transaction();
433 $this->IPN
->failed($this->objects
, $transaction);
435 $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
437 'id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
438 'status_id' => 'Cancelled',
440 $this->assertEquals(2, $cancelledParticipantsCount);
442 $cancelledActivatesCount = civicrm_api3('Activity', 'get', [
444 'activity_type_id' => 'Event Registration',
445 'subject' => ['LIKE' => '%Cancelled%'],
446 'source_record_id' => ['IN' => [$this->_participantId
, $additionalParticipantId]],
449 $this->assertEquals(2, $cancelledActivatesCount['count']);
453 * Prepare for contribution Test - involving only contribution objects
455 * @param bool $contributionPage
457 public function _setUpContributionObjects($contributionPage = FALSE) {
459 $contribution = new CRM_Contribute_BAO_Contribution();
460 $contribution->id
= $this->_contributionId
;
461 $contribution->find(TRUE);
462 $contributionPageID = NULL;
464 if (!empty($contributionPage)) {
465 $dao = new CRM_Core_DAO();
466 $contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage');
467 $contribution_page->payment_processor
= 1;
468 $contribution_page->save();
469 $contribution->contribution_page_id
= $contributionPageID = $contribution_page->id
;
470 //for unknown reasons trying to do a find & save on a contribution with a receive_date set
471 // doesn't work. This seems of minimal relevance to this test so ignoring
472 // note that in tests it worked sometimes & not others - dependent on which other tests run.
473 // running all CRM_Core tests caused failure as did just the single failing test. But running
474 // just this class succeeds - because it actually doesn't do a mysql update on the following save
476 unset($contribution->receive_date
);
477 $contribution->save();
480 $this->objects
['contribution'] = $contribution;
482 'component' => 'contribute',
483 'contribution_page_id' => $contributionPageID,
484 'total_amount' => 110.00,
485 'invoiceID' => "c8acb91e080ad7777a2adc119c192885",
486 'contactID' => $this->_contactId
,
487 'contributionID' => $this->objects
['contribution']->id
,
492 * Prepare for membership test.
494 public function _setUpMembershipObjects() {
496 if (!$this->_membershipTypeID
) {
497 $this->_membershipTypeID
= $this->membershipTypeCreate();
499 if (!$this->_membershipStatusID
) {
500 $this->_membershipStatusID
= $this->membershipStatusCreate('test status');
503 catch (Exception
$e) {
504 echo $e->getMessage();
506 CRM_Member_PseudoConstant
::membershipType($this->_membershipTypeID
, TRUE);
507 CRM_Member_PseudoConstant
::membershipStatus(NULL, NULL, 'name', TRUE);
508 $this->_membershipParams
= [
509 'contact_id' => $this->_contactId
,
510 'membership_type_id' => $this->_membershipTypeID
,
511 'join_date' => '2009-01-21',
512 'start_date' => '2009-01-21',
513 'end_date' => '2009-12-21',
514 'source' => 'Payment',
516 'status_id' => $this->_membershipStatusID
,
520 $membership = $this->callAPISuccess('membership', 'create', $this->_membershipParams
);
521 if ($this->objects
['contribution']->id
!= $this->_contributionId
) {
522 $contribution = new CRM_Contribute_BAO_Contribution();
523 $contribution->id
= $this->_contributionId
;
524 $contribution->find(TRUE);
525 $this->objects
= ['contribution' => $contribution];
527 $this->_membershipId
= $membership['id'];
528 //we'll create membership payment here because to make setup more re-usable
529 $this->callAPISuccess('membership_payment', 'create', [
530 'contribution_id' => $this->_contributionId
,
531 'membership_id' => $this->_membershipId
,
535 'component' => 'contribute',
536 'total_amount' => 150.00,
537 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
538 'contactID' => $this->_contactId
,
539 'contributionID' => $this->_contributionId
,
540 'membershipID' => $this->_membershipId
,
543 $this->ids
['membership'] = $this->_membershipId
;
546 public function _setUpRecurringContribution() {
547 $this->_contributionRecurParams
= [
548 'contact_id' => $this->_contactId
,
551 'frequency_unit' => 'week',
552 'frequency_interval' => 1,
554 'start_date' => date('Ymd'),
555 'create_date' => date('Ymd'),
556 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
557 'contribution_status_id' => 2,
558 'financial_type_id' => $this->_financialTypeId
,
560 'payment_processor_id' => $this->_processorId
,
562 $this->_recurId
= $this->callAPISuccess('contribution_recur', 'create', $this->_contributionRecurParams
);
563 $this->_recurId
= $this->_recurId
['id'];
564 $this->input
['contributionRecurId'] = $this->_recurId
;
565 $this->ids
['contributionRecur'] = $this->_recurId
;
569 * Set up participant requirements for test.
571 * @param string $participantStatus
572 * The participant to create status
574 public function _setUpParticipantObjects($participantStatus = 'Attended') {
575 $event = $this->eventCreate(['is_email_confirm' => 1]);
577 $this->_eventId
= $event['id'];
578 $this->_participantId
= $this->participantCreate([
579 'event_id' => $this->_eventId
,
580 'contact_id' => $this->_contactId
,
581 'status_id' => $participantStatus,
584 $this->callAPISuccess('participant_payment', 'create', [
585 'contribution_id' => $this->_contributionId
,
586 'participant_id' => $this->_participantId
,
589 $contribution = new CRM_Contribute_BAO_Contribution();
590 $contribution->id
= $this->_contributionId
;
591 $contribution->find();
592 $this->objects
['contribution'] = $contribution;
594 'component' => 'event',
595 'total_amount' => 150.00,
596 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
597 'contactID' => $this->_contactId
,
598 'contributionID' => $contribution->id
,
599 'participantID' => $this->_participantId
,
602 $this->ids
['participant'] = $this->_participantId
;
603 $this->ids
['event'] = $this->_eventId
;
607 * Set up participant requirements for test.
609 public function _setUpPledgeObjects() {
610 $this->_pledgeId
= $this->pledgeCreate(['contact_id' => $this->_contactId
]);
611 //we'll create membership payment here because to make setup more re-usable
612 $pledgePayment = $this->callAPISuccess('pledge_payment', 'create', [
614 'pledge_id' => $this->_pledgeId
,
615 'contribution_id' => $this->_contributionId
,
617 'actual_amount' => 50,
621 'component' => 'contribute',
622 'total_amount' => 150.00,
623 'invoiceID' => "c8acb91e080ad7bd8a2adc119c192885",
624 'contactID' => $this->_contactId
,
625 'contributionID' => $this->_contributionId
,
626 'pledgeID' => $this->_pledgeId
,
629 $this->ids
['pledge_payment'][] = $pledgePayment['id'];