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
{
37 protected $_individualId;
39 protected $_financialTypeId = 1;
41 protected $_apiversion;
48 public function setUp() {
51 $this->_apiversion
= 3;
52 $this->_individualId
= $this->individualCreate();
53 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= [];
57 * Clean up after each test.
61 public function tearDown() {
62 $this->quickCleanUpFinancialEntities();
63 $this->quickCleanup(['civicrm_uf_match']);
64 unset(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
);
69 * Test Get Payment api.
71 public function testGetPayment() {
73 'contact_id' => $this->_individualId
,
74 'receive_date' => '2010-01-20',
75 'total_amount' => 100.00,
76 'financial_type_id' => $this->_financialTypeId
,
78 'contribution_status_id' => 1,
80 $contribution = $this->callAPISuccess('contribution', 'create', $p);
83 'contribution_id' => $contribution['id'],
84 'check_permissions' => TRUE,
86 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['access CiviCRM', 'administer CiviCRM'];
87 $payment = $this->callAPIFailure('payment', 'get', $params, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and access CiviContribute');
89 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviContribute');
90 $payment = $this->callAPISuccess('payment', 'get', $params);
92 $payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__
, __FILE__
);
93 $this->assertEquals(1, $payment['count']);
96 $contribution['id'] => [
97 'total_amount' => 100,
99 'trxn_date' => '2010-01-20 00:00:00',
100 'contribution_id' => $contribution['id'],
104 $this->checkPaymentResult($payment, $expectedResult);
105 $this->callAPISuccess('Contribution', 'Delete', [
106 'id' => $contribution['id'],
111 * Test email receipt for partial payment.
113 public function testPaymentEmailReceipt() {
114 $mut = new CiviMailUtils($this);
115 list($lineItems, $contribution) = $this->createParticipantWithContribution();
116 $event = $this->callAPISuccess('Event', 'get', []);
117 $this->addLocationToEvent($event['id']);
119 'contribution_id' => $contribution['id'],
120 'total_amount' => 50,
121 'check_number' => '345',
122 'trxn_date' => '2018-08-13 17:57:56',
124 $payment = $this->callAPISuccess('payment', 'create', $params);
125 $this->checkPaymentResult($payment, [
127 'from_financial_account_id' => 7,
128 'to_financial_account_id' => 6,
129 'total_amount' => 50,
135 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
136 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
139 'Total Fees: $ 300.00',
140 'This Payment Amount: $ 50.00',
141 //150 was paid in the 1st payment.
142 'Balance Owed: $ 100.00',
143 'Event Information and Location',
146 'Transaction Date: August 13th, 2018 5:57 PM',
151 $mut->clearMessages();
155 * Test email receipt for partial payment.
157 * @throws \CRM_Core_Exception
159 public function testPaymentEmailReceiptFullyPaid() {
160 $mut = new CiviMailUtils($this);
161 list($lineItems, $contribution) = $this->createParticipantWithContribution();
164 'contribution_id' => $contribution['id'],
165 'total_amount' => 150,
167 $payment = $this->callAPISuccess('payment', 'create', $params);
169 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
170 $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet', 'Registration Confirmation - Annual CiviCRM meet']);
173 'A payment has been received.',
174 'Total Fees: $ 300.00',
175 'This Payment Amount: $ 150.00',
176 'Balance Owed: $ 0.00',
177 'Thank you for completing payment.',
180 $mut->clearMessages();
184 * Test email receipt for partial payment.
186 * @dataProvider getThousandSeparators
188 * @param string $thousandSeparator
190 public function testRefundEmailReceipt($thousandSeparator) {
191 $this->setCurrencySeparators($thousandSeparator);
192 $decimalSeparator = ($thousandSeparator === ',' ?
'.' : ',');
193 $mut = new CiviMailUtils($this);
194 list($lineItems, $contribution) = $this->createParticipantWithContribution();
195 $this->callAPISuccess('payment', 'create', [
196 'contribution_id' => $contribution['id'],
197 'total_amount' => 50,
198 'check_number' => '345',
199 'trxn_date' => '2018-08-13 17:57:56',
202 $payment = $this->callAPISuccess('payment', 'create', [
203 'contribution_id' => $contribution['id'],
204 'total_amount' => -30,
205 'trxn_date' => '2018-11-13 12:01:56',
206 'sequential' => TRUE,
210 'from_financial_account_id' => 7,
211 'to_financial_account_id' => 6,
212 'total_amount' => -30,
213 'status_id' => CRM_Core_PseudoConstant
::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Refunded'),
216 foreach ($expected as $key => $value) {
217 $this->assertEquals($expected[$key], $payment[$key], 'mismatch on key ' . $key);
220 $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
221 $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
224 'A refund has been issued based on changes in your registration selections.',
225 'Total Fees: $ 300' . $decimalSeparator . '00',
226 'Refund Amount: $ -30' . $decimalSeparator . '00',
227 'Event Information and Location',
229 'Transaction Date: November 13th, 2018 12:01 PM',
230 'You Paid: $ 170' . $decimalSeparator . '00',
233 $mut->clearMessages();
237 * Test create payment api with no line item in params
239 public function testCreatePaymentNoLineItems() {
240 list($lineItems, $contribution) = $this->createParticipantWithContribution();
242 //Create partial payment
244 'contribution_id' => $contribution['id'],
245 'total_amount' => 50,
247 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
);
250 'from_financial_account_id' => 7,
251 'to_financial_account_id' => 6,
252 'total_amount' => 50,
257 $this->checkPaymentResult($payment, $expectedResult);
259 // Check entity financial trxn created properly
261 'entity_id' => $contribution['id'],
262 'entity_table' => 'civicrm_contribution',
263 'financial_trxn_id' => $payment['id'],
266 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
268 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
271 'entity_table' => 'civicrm_financial_item',
272 'financial_trxn_id' => $payment['id'],
274 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
275 $amounts = [33.33, 16.67];
276 foreach ($eft['values'] as $value) {
277 $this->assertEquals($value['amount'], array_pop($amounts));
280 // Now create payment to complete total amount of contribution
282 'contribution_id' => $contribution['id'],
283 'total_amount' => 100,
285 $payment = $this->callAPISuccess('payment', 'create', $params);
288 'from_financial_account_id' => 7,
289 'to_financial_account_id' => 6,
290 'total_amount' => 100,
295 $this->checkPaymentResult($payment, $expectedResult);
297 'entity_table' => 'civicrm_financial_item',
298 'financial_trxn_id' => $payment['id'],
300 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
301 $amounts = [66.67, 33.33];
302 foreach ($eft['values'] as $value) {
303 $this->assertEquals($value['amount'], array_pop($amounts));
305 // Check contribution for completed status
306 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
308 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
309 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
310 $paymentParticipant = [
311 'contribution_id' => $contribution['id'],
313 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
314 $participant = $this->callAPISuccess('participant', 'get', ['id' => $participantPayment['participant_id']]);
315 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
316 $this->callAPISuccess('Contribution', 'Delete', [
317 'id' => $contribution['id'],
322 * Function to assert db values
324 public function checkPaymentResult($payment, $expectedResult) {
325 foreach ($expectedResult[$payment['id']] as $key => $value) {
326 $this->assertEquals($payment['values'][$payment['id']][$key], $value, 'mismatch on ' . $key);
331 * Test create payment api with line item in params
333 public function testCreatePaymentLineItems() {
334 list($lineItems, $contribution) = $this->createParticipantWithContribution();
335 $lineItems = $this->callAPISuccess('LineItem', 'get', ['contribution_id' => $contribution['id']]);
337 //Create partial payment by passing line item array is params
339 'contribution_id' => $contribution['id'],
340 'total_amount' => 50,
343 foreach ($lineItems['values'] as $id => $ignore) {
344 $params['line_item'][] = [$id => array_pop($amounts)];
346 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Payment with line item', 'CreatePaymentWithLineItems');
349 'from_financial_account_id' => 7,
350 'to_financial_account_id' => 6,
351 'total_amount' => 50,
356 $this->checkPaymentResult($payment, $expectedResult);
358 // Check entity financial trxn created properly
360 'entity_id' => $contribution['id'],
361 'entity_table' => 'civicrm_contribution',
362 'financial_trxn_id' => $payment['id'],
365 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
367 $this->assertEquals($eft['values'][$eft['id']]['amount'], 50);
370 'entity_table' => 'civicrm_financial_item',
371 'financial_trxn_id' => $payment['id'],
373 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
375 foreach ($eft['values'] as $value) {
376 $this->assertEquals($value['amount'], array_pop($amounts));
379 // Now create payment to complete total amount of contribution
381 'contribution_id' => $contribution['id'],
382 'total_amount' => 100,
385 foreach ($lineItems['values'] as $id => $ignore) {
386 $params['line_item'][] = [$id => array_pop($amounts)];
388 $payment = $this->callAPISuccess('payment', 'create', $params);
391 'from_financial_account_id' => 7,
392 'to_financial_account_id' => 6,
393 'total_amount' => 100,
398 $this->checkPaymentResult($payment, $expectedResult);
400 'entity_table' => 'civicrm_financial_item',
401 'financial_trxn_id' => $payment['id'],
403 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
405 foreach ($eft['values'] as $value) {
406 $this->assertEquals($value['amount'], array_pop($amounts));
408 // Check contribution for completed status
409 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
411 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
412 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 300.00);
413 $paymentParticipant = [
414 'contribution_id' => $contribution['id'],
416 $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $paymentParticipant);
417 $participant = $this->callAPISuccess('participant', 'get', ['id' => $participantPayment['participant_id']]);
418 $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Registered');
419 $this->callAPISuccess('Contribution', 'Delete', [
420 'id' => $contribution['id'],
425 * Test cancel payment api
427 public function testCancelPayment() {
428 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
429 list($lineItems, $contribution) = $this->createParticipantWithContribution();
432 'contribution_id' => $contribution['id'],
435 $payment = $this->callAPISuccess('payment', 'get', $params);
436 $this->assertEquals(1, $payment['count']);
439 'id' => $payment['id'],
440 'check_permissions' => TRUE,
442 $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');
444 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
446 $this->callAPIAndDocument('payment', 'cancel', $cancelParams, __FUNCTION__
, __FILE__
);
448 $payment = $this->callAPISuccess('payment', 'get', $params);
449 $this->assertEquals(2, $payment['count']);
450 $amounts = [-150.00, 150.00];
451 foreach ($payment['values'] as $value) {
452 $this->assertEquals($value['total_amount'], array_pop($amounts), 'Mismatch total amount');
455 $this->callAPISuccess('Contribution', 'Delete', [
456 'id' => $contribution['id'],
461 * Test delete payment api
463 public function testDeletePayment() {
464 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
465 list($lineItems, $contribution) = $this->createParticipantWithContribution();
468 'contribution_id' => $contribution['id'],
471 $payment = $this->callAPISuccess('payment', 'get', $params);
472 $this->assertEquals(1, $payment['count']);
475 'id' => $payment['id'],
476 'check_permissions' => TRUE,
478 $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');
480 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'delete in CiviContribute');
481 $this->callAPIAndDocument('payment', 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
483 $payment = $this->callAPISuccess('payment', 'get', $params);
484 $this->assertEquals(0, $payment['count']);
486 $this->callAPISuccess('Contribution', 'Delete', [
487 'id' => $contribution['id'],
492 * Test update payment api
494 public function testUpdatePayment() {
495 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute', 'edit contributions'];
496 list($lineItems, $contribution) = $this->createParticipantWithContribution();
498 //Create partial payment by passing line item array is params
500 'contribution_id' => $contribution['id'],
501 'total_amount' => 50,
504 $payment = $this->callAPISuccess('payment', 'create', $params);
507 'from_financial_account_id' => 7,
508 'to_financial_account_id' => 6,
509 'total_amount' => 50,
514 $this->checkPaymentResult($payment, $expectedResult);
517 'entity_table' => 'civicrm_financial_item',
518 'financial_trxn_id' => $payment['id'],
520 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
521 $amounts = [33.33, 16.67];
522 foreach ($eft['values'] as $value) {
523 $this->assertEquals($value['amount'], array_pop($amounts));
525 CRM_Core_Config
::singleton()->userPermissionClass
->permissions
= ['administer CiviCRM', 'access CiviContribute'];
527 // update the amount for payment
529 'contribution_id' => $contribution['id'],
530 'total_amount' => 100,
531 'id' => $payment['id'],
532 'check_permissions' => TRUE,
534 $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');
536 array_push(CRM_Core_Config
::singleton()->userPermissionClass
->permissions
, 'access CiviCRM', 'edit contributions');
537 $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__
, __FILE__
, 'Update Payment', 'UpdatePayment');
539 // Check for proportional cancelled payment against lineitems.
541 'entity_table' => 'civicrm_financial_item',
542 'financial_trxn_id' => $payment['id'] - 1,
545 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $minParams);
546 $amounts = [-33.33, -16.67];
548 foreach ($eft['values'] as $value) {
549 $this->assertEquals($value['amount'], array_pop($amounts));
552 // Check for proportional updated payment against lineitems.
554 'entity_table' => 'civicrm_financial_item',
555 'financial_trxn_id' => $payment['id'],
557 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
558 $amounts = [66.67, 33.33];
559 foreach ($eft['values'] as $value) {
560 $this->assertEquals($value['amount'], array_pop($amounts));
564 'contribution_id' => $contribution['id'],
566 $payment = $this->callAPISuccess('payment', 'get', $params);
567 $amounts = [100.00, -50.00, 50.00, 150.00];
568 foreach ($payment['values'] as $value) {
569 $amount = array_pop($amounts);
570 $this->assertEquals($value['total_amount'], $amount, 'Mismatch total amount');
572 // Check entity financial trxn created properly
574 'entity_id' => $contribution['id'],
575 'entity_table' => 'civicrm_contribution',
576 'financial_trxn_id' => $value['id'],
578 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
579 $this->assertEquals($eft['values'][$eft['id']]['amount'], $amount);
582 $this->callAPISuccess('Contribution', 'Delete', [
583 'id' => $contribution['id'],
588 * Test create payment api for paylater contribution
590 public function testCreatePaymentPayLater() {
591 $this->createLoggedInUser();
592 $contributionParams = [
593 'total_amount' => 100,
595 'contact_id' => $this->_individualId
,
596 'financial_type_id' => 1,
597 'contribution_status_id' => 2,
600 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
601 //add payment for pay later transaction
603 'contribution_id' => $contribution['id'],
604 'total_amount' => 100,
606 $payment = $this->callAPISuccess('Payment', 'create', $params);
609 'from_financial_account_id' => 7,
610 'to_financial_account_id' => 6,
611 'total_amount' => 100,
616 $this->checkPaymentResult($payment, $expectedResult);
617 // Check entity financial trxn created properly
619 'entity_id' => $contribution['id'],
620 'entity_table' => 'civicrm_contribution',
621 'financial_trxn_id' => $payment['id'],
623 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
624 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
626 'entity_table' => 'civicrm_financial_item',
627 'financial_trxn_id' => $payment['id'],
629 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
630 $this->assertEquals($eft['values'][$eft['id']]['amount'], 100);
631 // Check contribution for completed status
632 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
633 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed');
634 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
635 $this->callAPISuccess('Contribution', 'Delete', [
636 'id' => $contribution['id'],
641 * Test create payment api for pay later contribution with partial payment.
645 public function testCreatePaymentPayLaterPartialPayment() {
646 $this->createLoggedInUser();
647 $contributionParams = [
648 'total_amount' => 100,
650 'contact_id' => $this->_individualId
,
651 'financial_type_id' => 1,
652 'contribution_status_id' => 2,
655 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
656 //Create partial payment
658 'contribution_id' => $contribution['id'],
659 'total_amount' => 60,
661 $payment = $this->callAPISuccess('Payment', 'create', $params);
664 'total_amount' => 60,
669 $this->checkPaymentResult($payment, $expectedResult);
670 // Check entity financial trxn created properly
672 'entity_id' => $contribution['id'],
673 'entity_table' => 'civicrm_contribution',
674 'financial_trxn_id' => $payment['id'],
676 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
677 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
679 'entity_table' => 'civicrm_financial_item',
680 'financial_trxn_id' => $payment['id'],
682 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
683 $this->assertEquals($eft['values'][$eft['id']]['amount'], 60);
684 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
685 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Partially paid');
686 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
687 //Create full payment
689 'contribution_id' => $contribution['id'],
690 'total_amount' => 40,
692 // Rename the 'completed' status label first to check that we are not using the labels!
693 $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Unicorn']]);
694 $payment = $this->callAPISuccess('Payment', 'create', $params);
697 'from_financial_account_id' => 7,
698 'to_financial_account_id' => 6,
699 'total_amount' => 40,
704 $this->checkPaymentResult($payment, $expectedResult);
705 // Check entity financial trxn created properly
707 'entity_id' => $contribution['id'],
708 'entity_table' => 'civicrm_contribution',
709 'financial_trxn_id' => $payment['id'],
711 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
712 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
714 'entity_table' => 'civicrm_financial_item',
715 'financial_trxn_id' => $payment['id'],
717 $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $params);
718 $this->assertEquals($eft['values'][$eft['id']]['amount'], 40);
719 // Check contribution for completed status
720 $contribution = $this->callAPISuccess('contribution', 'get', ['id' => $contribution['id']]);
721 $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Unicorn');
722 $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00);
723 $this->callAPISuccess('Contribution', 'Delete', [
724 'id' => $contribution['id'],
726 $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Completed']]);
727 $this->callAPISuccessGetCount('Activity', ['target_contact_id' => $this->_individualId
, 'activity_type_id' => 'Payment'], 2);
731 * Add a location to our event.
733 * @param int $eventID
735 protected function addLocationToEvent($eventID) {
737 'name' => 'event place',
738 'street_address' => 'streety street',
739 'location_type_id' => 1,
742 // api requires contact_id - perhaps incorrectly but use add to get past that.
743 $address = CRM_Core_BAO_Address
::add($addressParams);
745 $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id
]);
746 $this->callAPISuccess('Event', 'create', [
748 'loc_block_id' => $location['id'],
749 'is_show_location' => TRUE,