3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Test APIv3 civicrm_contribute_* functions
31 * @package CiviCRM_APIv3
32 * @subpackage API_Contribution
35 class api_v3_PaymentTest
extends CiviUnitTestCase
{
38 * Assume empty database with just civicrm_data.
40 protected $_individualId;
41 protected $_financialTypeId = 1;
42 protected $_apiversion;
48 public function setUp() {
51 $this->_apiversion
= 3;
52 $this->_individualId
= $this->individualCreate();
53 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array();
57 * Clean up after each test.
59 public function tearDown() {
60 $this->quickCleanUpFinancialEntities();
61 $this->quickCleanup(array('civicrm_uf_match'));
62 unset(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
);
66 * Test Get Payment api.
68 public function testGetPayment() {
70 'contact_id' => $this->_individualId
,
71 'receive_date' => '2010-01-20',
72 'total_amount' => 100.00,
73 'financial_type_id' => $this->_financialTypeId
,
75 'contribution_status_id' => 1,
77 $contribution = $this->callAPISuccess('contribution', 'create', $p);
80 'contribution_id' => $contribution['id'],
81 'check_permissions' => TRUE,
83 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array('access CiviCRM', 'administer CiviCRM');
84 $payment = $this->callAPIFailure('payment', 'get', $params, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and access CiviContribute');
86 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviContribute');
87 $payment = $this->callAPISuccess('payment', 'get', $params);
89 $payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__
, __FILE__
);
90 $this->assertEquals(1, $payment['count']);
92 $expectedResult = array(
93 $contribution['id'] => array(
94 'total_amount' => 100,
96 'trxn_date' => '2010-01-20 00:00:00',
97 'contribution_id' => $contribution['id'],
101 $this->checkPaymentResult($payment, $expectedResult);
102 $this->callAPISuccess('Contribution', 'Delete', array(
103 'id' => $contribution['id'],
108 * Test email receipt for partial payment.
110 public function testPaymentEmailReceipt() {
111 $mut = new CiviMailUtils($this);
112 list($lineItems, $contribution) = $this->createParticipantWithContribution();
113 $event = $this->callAPISuccess('Event', 'get', []);
114 $this->addLocationToEvent($event['id']);
116 'contribution_id' => $contribution['id'],
117 'total_amount' => 50,
118 'check_number' => '345',
119 'trxn_date' => '2018-08-13 17:57:56',
121 $payment = $this->callAPISuccess('payment', 'create', $params);
122 $this->checkPaymentResult($payment, [
124 'from_financial_account_id' => 7,
125 'to_financial_account_id' => 6,
126 'total_amount' => 50,
132 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
133 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
134 $mut->checkMailLog(array(
136 'Total Fees: $ 300.00',
137 'This Payment Amount: $ 50.00',
138 'Balance Owed: $ 100.00', //150 was paid in the 1st payment.
139 'Event Information and Location',
142 'Transaction Date: August 13th, 2018 5:57 PM',
147 $mut->clearMessages();
151 * Test email receipt for partial payment.
153 public function testPaymentEmailReceiptFullyPaid() {
154 $mut = new CiviMailUtils($this);
155 list($lineItems, $contribution) = $this->createParticipantWithContribution();
158 'contribution_id' => $contribution['id'],
159 'total_amount' => 150,
161 $payment = $this->callAPISuccess('payment', 'create', $params);
163 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
164 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
165 $mut->checkMailLog(array(
167 'A payment has been received.',
168 'Total Fees: $ 300.00',
169 'This Payment Amount: $ 150.00',
170 'Balance Owed: $ 0.00',
171 'Thank you for completing payment.',
174 $mut->clearMessages();
178 * Test email receipt for partial payment.
180 * @dataProvider getThousandSeparators
182 * @param string $thousandSeparator
184 public function testRefundEmailReceipt($thousandSeparator) {
185 $this->setCurrencySeparators($thousandSeparator);
186 $decimalSeparator = ($thousandSeparator === ',' ?
'.' : ',');
187 $mut = new CiviMailUtils($this);
188 list($lineItems, $contribution) = $this->createParticipantWithContribution();
189 $this->callAPISuccess('payment', 'create', [
190 'contribution_id' => $contribution['id'],
191 'total_amount' => 50,
192 'check_number' => '345',
193 'trxn_date' => '2018-08-13 17:57:56',
196 $payment = $this->callAPISuccess('payment', 'create', [
197 'contribution_id' => $contribution['id'],
198 'total_amount' => -30,
199 'trxn_date' => '2018-11-13 12:01:56',
200 'sequential' => TRUE,
204 'from_financial_account_id' => 7,
205 'to_financial_account_id' => 6,
206 'total_amount' => -30,
210 foreach ($expected as $key => $value) {
211 $this->assertEquals($expected[$key], $payment[$key], 'mismatch on key ' . $key);
214 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
215 $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
216 $mut->checkMailLog(array(
218 'A refund has been issued based on changes in your registration selections.',
219 'Total Fees: $ 300' . $decimalSeparator . '00',
220 'Refund Amount: $ -30' . $decimalSeparator . '00',
221 'Event Information and Location',
223 'Transaction Date: November 13th, 2018 12:01 PM',
224 'You Paid: $ 170' . $decimalSeparator . '00',
227 $mut->clearMessages();
231 * Test create payment api with no line item in params
233 public function testCreatePaymentNoLineItems() {
234 list($lineItems, $contribution) = $this->createParticipantWithContribution();
236 //Create partial payment
238 'contribution_id' => $contribution['id'],
239 'total_amount' => 50,
241 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
);
242 $expectedResult = array(
243 $payment['id'] => array(
244 'from_financial_account_id' => 7,
245 'to_financial_account_id' => 6,
246 'total_amount' => 50,
251 $this->checkPaymentResult($payment, $expectedResult);
253 // Check entity financial trxn created properly
255 'entity_id' => $contribution['id'],
256 'entity_table' => 'civicrm_contribution',
257 'financial_trxn_id' => $payment['id'],
260 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
262 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
265 'entity_table' => 'civicrm_financial_item',
266 'financial_trxn_id' => $payment['id'],
268 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
269 $amounts = array(33.33, 16.67);
270 foreach ($eft['values'] as $value) {
271 $this->assertEquals($value['amount'], array_pop($amounts));
274 // Now create payment to complete total amount of contribution
276 'contribution_id' => $contribution['id'],
277 'total_amount' => 100,
279 $payment = $this->callAPISuccess('payment', 'create', $params);
280 $expectedResult = array(
281 $payment['id'] => array(
282 'from_financial_account_id' => 7,
283 'to_financial_account_id' => 6,
284 'total_amount' => 100,
289 $this->checkPaymentResult($payment, $expectedResult);
291 'entity_table' => 'civicrm_financial_item',
292 'financial_trxn_id' => $payment['id'],
294 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
295 $amounts = array(66.67, 33.33);
296 foreach ($eft['values'] as $value) {
297 $this->assertEquals($value['amount'], array_pop($amounts));
299 // Check contribution for completed status
300 $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id']));
302 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
303 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
304 $paymentParticipant = array(
305 'contribution_id' => $contribution['id'],
307 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
308 $participant = $this->callAPISuccess('participant', 'get', array('id' => $participantPayment['participant_id']));
309 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
310 $this->callAPISuccess('Contribution', 'Delete', array(
311 'id' => $contribution['id'],
316 * Function to assert db values
318 public function checkPaymentResult($payment, $expectedResult) {
319 foreach ($expectedResult[$payment['id']] as $key => $value) {
320 $this->assertEquals($payment['values'][$payment['id']][$key], $value);
325 * Test create payment api with line item in params
327 public function testCreatePaymentLineItems() {
328 list($lineItems, $contribution) = $this->createParticipantWithContribution();
329 $lineItems = $this->callAPISuccess('LineItem', 'get', array('contribution_id' => $contribution['id']));
331 //Create partial payment by passing line item array is params
333 'contribution_id' => $contribution['id'],
334 'total_amount' => 50,
336 $amounts = array(40, 10);
337 foreach ($lineItems['values'] as $id => $ignore) {
338 $params['line_item'][] = array($id => array_pop($amounts));
340 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Payment with line item', 'CreatePaymentWithLineItems');
341 $expectedResult = array(
342 $payment['id'] => array(
343 'from_financial_account_id' => 7,
344 'to_financial_account_id' => 6,
345 'total_amount' => 50,
350 $this->checkPaymentResult($payment, $expectedResult);
352 // Check entity financial trxn created properly
354 'entity_id' => $contribution['id'],
355 'entity_table' => 'civicrm_contribution',
356 'financial_trxn_id' => $payment['id'],
359 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
361 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
364 'entity_table' => 'civicrm_financial_item',
365 'financial_trxn_id' => $payment['id'],
367 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
368 $amounts = array(40, 10);
369 foreach ($eft['values'] as $value) {
370 $this->assertEquals($value['amount'], array_pop($amounts));
373 // Now create payment to complete total amount of contribution
375 'contribution_id' => $contribution['id'],
376 'total_amount' => 100,
378 $amounts = array(80, 20);
379 foreach ($lineItems['values'] as $id => $ignore) {
380 $params['line_item'][] = array($id => array_pop($amounts));
382 $payment = $this->callAPISuccess('payment', 'create', $params);
383 $expectedResult = array(
384 $payment['id'] => array(
385 'from_financial_account_id' => 7,
386 'to_financial_account_id' => 6,
387 'total_amount' => 100,
392 $this->checkPaymentResult($payment, $expectedResult);
394 'entity_table' => 'civicrm_financial_item',
395 'financial_trxn_id' => $payment['id'],
397 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
398 $amounts = array(80, 20);
399 foreach ($eft['values'] as $value) {
400 $this->assertEquals($value['amount'], array_pop($amounts));
402 // Check contribution for completed status
403 $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id']));
405 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
406 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
407 $paymentParticipant = array(
408 'contribution_id' => $contribution['id'],
410 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
411 $participant = $this->callAPISuccess('participant', 'get', array('id' => $participantPayment['participant_id']));
412 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
413 $this->callAPISuccess('Contribution', 'Delete', array(
414 'id' => $contribution['id'],
419 * Test cancel payment api
421 public function testCancelPayment() {
422 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array('administer CiviCRM', 'access CiviContribute');
423 list($lineItems, $contribution) = $this->createParticipantWithContribution();
426 'contribution_id' => $contribution['id'],
429 $payment = $this->callAPISuccess('payment', 'get', $params);
430 $this->assertEquals(1, $payment['count']);
432 $cancelParams = array(
433 'id' => $payment['id'],
434 'check_permissions' => TRUE,
436 $payment = $this->callAPIFailure('payment', 'cancel', $cancelParams, 'API permission check failed for Payment/cancel call; insufficient permission: require access CiviCRM and access CiviContribute and edit contributions');
438 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
440 $this->callAPIAndDocument('payment', 'cancel', $cancelParams, __FUNCTION__
, __FILE__
);
442 $payment = $this->callAPISuccess('payment', 'get', $params);
443 $this->assertEquals(2, $payment['count']);
444 $amounts = array(-150.00, 150.00);
445 foreach ($payment['values'] as $value) {
446 $this->assertEquals($value['total_amount'], array_pop($amounts), 'Mismatch total amount');
449 $this->callAPISuccess('Contribution', 'Delete', array(
450 'id' => $contribution['id'],
455 * Test delete payment api
457 public function testDeletePayment() {
458 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array('administer CiviCRM', 'access CiviContribute');
459 list($lineItems, $contribution) = $this->createParticipantWithContribution();
462 'contribution_id' => $contribution['id'],
465 $payment = $this->callAPISuccess('payment', 'get', $params);
466 $this->assertEquals(1, $payment['count']);
468 $deleteParams = array(
469 'id' => $payment['id'],
470 'check_permissions' => TRUE,
472 $payment = $this->callAPIFailure('payment', 'delete', $deleteParams, 'API permission check failed for Payment/delete call; insufficient permission: require access CiviCRM and access CiviContribute and delete in CiviContribute');
474 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'delete in CiviContribute');
475 $this->callAPIAndDocument('payment', 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
477 $payment = $this->callAPISuccess('payment', 'get', $params);
478 $this->assertEquals(0, $payment['count']);
480 $this->callAPISuccess('Contribution', 'Delete', array(
481 'id' => $contribution['id'],
486 * Test update payment api
488 public function testUpdatePayment() {
489 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array('administer CiviCRM', 'access CiviContribute', 'edit contributions');
490 list($lineItems, $contribution) = $this->createParticipantWithContribution();
492 //Create partial payment by passing line item array is params
494 'contribution_id' => $contribution['id'],
495 'total_amount' => 50,
498 $payment = $this->callAPISuccess('payment', 'create', $params);
499 $expectedResult = array(
500 $payment['id'] => array(
501 'from_financial_account_id' => 7,
502 'to_financial_account_id' => 6,
503 'total_amount' => 50,
508 $this->checkPaymentResult($payment, $expectedResult);
511 'entity_table' => 'civicrm_financial_item',
512 'financial_trxn_id' => $payment['id'],
514 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
515 $amounts = array(33.33, 16.67);
516 foreach ($eft['values'] as $value) {
517 $this->assertEquals($value['amount'], array_pop($amounts));
519 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= array('administer CiviCRM', 'access CiviContribute');
521 // update the amount for payment
523 'contribution_id' => $contribution['id'],
524 'total_amount' => 100,
525 'id' => $payment['id'],
526 'check_permissions' => TRUE,
528 $payment = $this->callAPIFailure('payment', 'create', $params, 'API permission check failed for Payment/create call; insufficient permission: require access CiviCRM and access CiviContribute and edit contributions');
530 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
531 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Update Payment', 'UpdatePayment');
533 // Check for proportional cancelled payment against lineitems.
535 'entity_table' => 'civicrm_financial_item',
536 'financial_trxn_id' => $payment['id'] - 1,
539 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $minParams);
540 $amounts = array(-33.33, -16.67);
542 foreach ($eft['values'] as $value) {
543 $this->assertEquals($value['amount'], array_pop($amounts));
546 // Check for proportional updated payment against lineitems.
548 'entity_table' => 'civicrm_financial_item',
549 'financial_trxn_id' => $payment['id'],
551 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
552 $amounts = array(66.67, 33.33);
553 foreach ($eft['values'] as $value) {
554 $this->assertEquals($value['amount'], array_pop($amounts));
558 'contribution_id' => $contribution['id'],
560 $payment = $this->callAPISuccess('payment', 'get', $params);
561 $amounts = array(100.00, -50.00, 50.00, 150.00);
562 foreach ($payment['values'] as $value) {
563 $amount = array_pop($amounts);
564 $this->assertEquals($value['total_amount'], $amount, 'Mismatch total amount');
566 // Check entity financial trxn created properly
568 'entity_id' => $contribution['id'],
569 'entity_table' => 'civicrm_contribution',
570 'financial_trxn_id' => $value['id'],
572 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
573 $this->assertEquals($eft['values'][$eft['id']]['amount'], $amount);
576 $this->callAPISuccess('Contribution', 'Delete', array(
577 'id' => $contribution['id'],
582 * Test create payment api for paylater contribution
584 public function testCreatePaymentPayLater() {
585 $this->createLoggedInUser();
586 $contributionParams = array(
587 'total_amount' => 100,
589 'contact_id' => $this->_individualId
,
590 'financial_type_id' => 1,
591 'contribution_status_id' => 2,
594 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
595 //add payment for pay later transaction
597 'contribution_id' => $contribution['id'],
598 'total_amount' => 100,
600 $payment = $this->callAPISuccess('Payment', 'create', $params);
601 $expectedResult = array(
602 $payment['id'] => array(
603 'from_financial_account_id' => 7,
604 'to_financial_account_id' => 6,
605 'total_amount' => 100,
610 $this->checkPaymentResult($payment, $expectedResult);
611 // Check entity financial trxn created properly
613 'entity_id' => $contribution['id'],
614 'entity_table' => 'civicrm_contribution',
615 'financial_trxn_id' => $payment['id'],
617 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
618 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
620 'entity_table' => 'civicrm_financial_item',
621 'financial_trxn_id' => $payment['id'],
623 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
624 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
625 // Check contribution for completed status
626 $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id']));
627 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
628 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
629 $this->callAPISuccess('Contribution', 'Delete', array(
630 'id' => $contribution['id'],
635 * Test create payment api for paylater contribution with partial payment.
637 public function testCreatePaymentPayLaterPartialPayment() {
638 $this->createLoggedInUser();
639 $contributionParams = array(
640 'total_amount' => 100,
642 'contact_id' => $this->_individualId
,
643 'financial_type_id' => 1,
644 'contribution_status_id' => 2,
647 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
648 //Create partial payment
650 'contribution_id' => $contribution['id'],
651 'total_amount' => 60,
653 $payment = $this->callAPISuccess('Payment', 'create', $params);
654 $expectedResult = array(
655 $payment['id'] => array(
656 'total_amount' => 60,
661 $this->checkPaymentResult($payment, $expectedResult);
662 // Check entity financial trxn created properly
664 'entity_id' => $contribution['id'],
665 'entity_table' => 'civicrm_contribution',
666 'financial_trxn_id' => $payment['id'],
668 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
669 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
671 'entity_table' => 'civicrm_financial_item',
672 'financial_trxn_id' => $payment['id'],
674 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
675 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
676 $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id']));
677 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Partially paid');
678 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
679 //Create full payment
681 'contribution_id' => $contribution['id'],
682 'total_amount' => 40,
684 $payment = $this->callAPISuccess('Payment', 'create', $params);
685 $expectedResult = array(
686 $payment['id'] => array(
687 'from_financial_account_id' => 7,
688 'to_financial_account_id' => 6,
689 'total_amount' => 40,
694 $this->checkPaymentResult($payment, $expectedResult);
695 // Check entity financial trxn created properly
697 'entity_id' => $contribution['id'],
698 'entity_table' => 'civicrm_contribution',
699 'financial_trxn_id' => $payment['id'],
701 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
702 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
704 'entity_table' => 'civicrm_financial_item',
705 'financial_trxn_id' => $payment['id'],
707 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
708 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
709 // Check contribution for completed status
710 $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id']));
711 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
712 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
713 $this->callAPISuccess('Contribution', 'Delete', array(
714 'id' => $contribution['id'],
719 * Add a location to our event.
721 * @param int $eventID
723 protected function addLocationToEvent($eventID) {
725 'name' => 'event place',
726 'street_address' => 'streety street',
727 'location_type_id' => 1,
730 // api requires contact_id - perhaps incorrectly but use add to get past that.
731 $address = CRM_Core_BAO_Address
::add($addressParams);
733 $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id
]);
734 $this->callAPISuccess('Event', 'create', [
736 'loc_block_id' => $location['id'],
737 'is_show_location' => TRUE,