PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.10.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.10.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / v1 / includes / Frontend / Form / FrontendFormManager.php

FrontendFormManager.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.10.1, at v1/includes/Frontend/Form/FrontendFormManager.php

575 lines 22.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Get set Form,fields
5 */
6
7 namespace BitCode\BitForm\Frontend\Form;
8
9 /**
10 * FrontendFormManager class
11 */
12
13 use BitCode\BitForm\Core\Database\FormEntryModel;
14 use BitCode\BitForm\Core\Form\FormManager;
15 use BitCode\BitForm\Core\Form\Validator\FormFieldValidator;
16 use BitCode\BitForm\Core\Integration\IntegrationHandler;
17 use BitCode\BitForm\Core\Util\ApiResponse as UtilApiResponse;
18 use BitCode\BitForm\Core\Util\DateTimeHelper;
19 use BitCode\BitForm\Core\Util\HttpHelper;
20 use BitCode\BitForm\Core\Util\IpTool;
21 use BitCode\BitForm\Core\WorkFlow\WorkFlowRunHelper;
22 use BitCode\BitForm\Frontend\Form\View\FormViewer;
23 use WP_Error;
24
25 final class FrontendFormManager extends FormManager
26 {
27 private $_form_identifier;
28 private $_form_token;
29 private $_form_id;
30
31 // private $_has_upload = false;
32 public function __construct($form_id, $shortCodeCounter = null)
33 {
34 parent::__construct($form_id);
35 $this->_form_identifier = 'bitforms_' . $form_id . '_submit_';
36 $this->_form_identifier .= !empty(get_post()->ID) ? get_post()->ID : '';
37 $this->_form_identifier .= !empty($shortCodeCounter) ? "_$shortCodeCounter" : '';
38 $this->_form_token = wp_create_nonce('bitforms_' . $form_id);
39 $this->_form_id = $form_id;
40 }
41
42 public function getFormIdentifier()
43 {
44 return $this->_form_identifier;
45 }
46
47 public function getFormID()
48 {
49 return $this->_form_id;
50 }
51
52 public function getFormToken()
53 {
54 return $this->_form_token;
55 }
56
57 public function isSubmitted()
58 {
59 return isset($_POST[$this->_form_identifier]) ? true : false;
60 }
61
62 public function getSubmittedFields($submitted_data)
63 {
64 unset($submitted_data[$this->_form_identifier]);
65 return array_keys($submitted_data);
66 }
67
68 public function formView($fields = null, $hasFile = false, $errorMessages = null, $previousValue = null)
69 {
70 $formContents = $this->getFormContent();
71 if (!empty($fields)) {
72 $formContents->fields = is_string($fields) ? json_decode($fields) : $fields;
73 } else {
74 $workFlowRunHelper = new WorkFlowRunHelper($this->form_id);
75 $workFlowreturnedOnLoad = $workFlowRunHelper->executeOnLoad(
76 'create',
77 $formContents->fields
78 );
79 $formContents->fields = empty($workFlowreturnedOnLoad['fields']) ? $formContents->fields : $workFlowreturnedOnLoad['fields'];
80 }
81 $formViewer = new FormViewer($this, $formContents, $errorMessages, $previousValue);
82 return $formViewer->getView($hasFile);
83 }
84
85 private function checkEmptySubmission($data, $file)
86 {
87 $form_fields = $this->getFields();
88 $emptySubmission = true;
89 foreach ($form_fields as $key => $field) {
90 if (!empty($data[$key]) || !empty($file[$key]['name'])) {
91 $emptySubmission = false;
92 break;
93 }
94 }
95 return $emptySubmission;
96 }
97
98 private function getParams()
99 {
100 $url = wp_parse_url(wp_get_referer());
101 $parameter = [];
102 if (isset($url['query'])) {
103 $queries = explode('&', $url['query']);
104 foreach ($queries as $query) {
105 list($field, $value) = explode('=', $query);
106 $parameter[$field] = $value;
107 }
108 }
109 return $parameter;
110 }
111
112 public function handleSubmission()
113 {
114 $validated = $this->beforeSubmittedValidate();
115
116 if (true === $validated) {
117 unset($_POST['$hidden_fields']);
118
119 $redirectPage = '';
120 $regSuccMsg = '';
121
122 $existAuth = (new IntegrationHandler($this->_form_id))->getAllIntegration('wp_user_auth', 'wp_auth', 1);
123 if (!is_wp_error($existAuth) && count($existAuth) > 0) {
124 $parameter = $this->getParams();
125 $existAuthFilter = has_filter('bf_wp_user_auth');
126
127 if (true === $existAuthFilter) {
128 $result = apply_filters('bf_wp_user_auth', $existAuth[0], $_POST, $parameter);
129
130 if (isset($result['auth_type']) && 'register' === $result['auth_type']) {
131 if (!$result['success']) {
132 return new WP_Error('errors', __($result['message'], 'bit-form'));
133 } elseif (isset($result['success'])) {
134 $redirectPage = $result['redirect_url'];
135 $regSuccMsg = $result['message'];
136 $newNonce = wp_create_nonce('bitforms_' . $this->_form_id);
137 }
138 } else {
139 if (!$result['success']) {
140 return new WP_Error('errors', __($result['message'], 'bit-form'));
141 } else {
142 return $result;
143 }
144 }
145 }
146 }
147
148 $saveResponse = $this->saveFormEntry($_POST);
149 if (is_wp_error($saveResponse)) {
150 return $saveResponse;
151 }
152 $captchaV3Settings = $this->getCaptchaV3Settings();
153 if ($captchaV3Settings) {
154 $token = $_POST['g-recaptcha-response'];
155 $integrationHandler = new IntegrationHandler(0);
156 $allFormIntegrations = $integrationHandler->getAllIntegration('app', 'gReCaptchaV3');
157 if (!is_wp_error($allFormIntegrations)) {
158 foreach ($allFormIntegrations as $integration) {
159 if (!is_null($integration->integration_type) && 'gReCaptchaV3' === $integration->integration_type) {
160 $integrationDetails = json_decode($integration->integration_details);
161 $integrationDetails->id = $integration->id;
162 $reCAPTCHA = $integrationDetails;
163 }
164 }
165 }
166 if (!empty($reCAPTCHA->secretKey)) {
167 $gRecaptchaResponse = HttpHelper::post(
168 'https://www.google.com/recaptcha/api/siteverify',
169 ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
170 );
171 if ($captchaV3Settings && !empty($saveResponse['triggerData'])) {
172 $logID = $saveResponse['triggerData']['logID'];
173 $integId = $reCAPTCHA->id;
174 $saveApiResponse = new UtilApiResponse();
175 $saveApiResponse->apiResponse($logID, $integId, ['type_name' => 'ReCaptcha', 'type' => 'v3'], 'success', $gRecaptchaResponse);
176 }
177 }
178 unset($_POST['g-recaptcha-response']);
179 }
180 if (!empty($redirectPage) && empty($saveResponse['redirectPage']) || null === $saveResponse['redirectPage']) {
181 $saveResponse['redirectPage'] = $redirectPage;
182 }
183 if (!empty($regSuccMsg) && isset($saveResponse['dflt_message'])) {
184 $saveResponse['message'] = $regSuccMsg;
185 }
186 $saveResponse = IntegrationHandler::maybeSetCronForIntegration($saveResponse, 'create');
187
188 $responseMsg = is_array($saveResponse) && !empty($saveResponse) ? $saveResponse : __('Form Submitted Successfully', 'bit-form');
189 if (isset($newNonce)) {
190 $responseMsg['new_nonce'] = $newNonce;
191 }
192 $_POST = [];
193
194 return $responseMsg;
195 }
196
197 return $validated;
198 }
199
200 public function validateFormSubmission($submitted_data)
201 {
202 $hidden_fields = isset($submitted_data['hidden_fields']) ? $submitted_data['hidden_fields'] : '';
203 $submitted_fields = $this->getSubmittedFields($submitted_data);
204 $form_fields = $this->getFields();
205 $form_fields_names = array_keys($form_fields);
206 if ($this->isGCLIDEnabled()) {
207 array_push($form_fields_names, 'GCLID');
208 }
209 foreach ($submitted_fields as $key => $field) {
210 if ('hidden_fields' !== $field && !in_array($field, $form_fields_names) || false !== strpos($hidden_fields, $field)) {
211 unset($submitted_data[$field]);
212 }
213 }
214 return $submitted_data;
215 }
216
217 public function beforeSubmittedValidate()
218 {
219 if ($this->verifySubmissionNonce()) {
220 if ($this->isExist()) {
221 $isRestricted = $this->checkSubmissionRestriction();
222 if ($isRestricted && !empty($isRestricted)) {
223 return new WP_Error('spam_detection', $isRestricted[0]);
224 }
225 if ($this->isTrappedInHoneypot()) {
226 return new WP_Error('spam_detection', __('Token verification failed', 'bit-form'));
227 }
228 $captchaSettings = $this->getCaptchaSettings();
229 $captchaV3Settings = $this->getCaptchaV3Settings();
230 if ($captchaSettings || $captchaV3Settings) {
231 $token = $_POST['g-recaptcha-response'];
232 if (!isset($_POST['g-recaptcha-response'])) {
233 return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
234 }
235 $integrationHandler = new IntegrationHandler(0);
236 $allFormIntegrations = $integrationHandler->getAllIntegration('app', $captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3');
237 if (!is_wp_error($allFormIntegrations)) {
238 foreach ($allFormIntegrations as $integration) {
239 if (!is_null($integration->integration_type) && $integration->integration_type === ($captchaSettings ? 'gReCaptcha' : 'gReCaptchaV3')) {
240 $integrationDetails = json_decode($integration->integration_details);
241 $integrationDetails->id = $integration->id;
242 $reCAPTCHA = $integrationDetails;
243 }
244 }
245 }
246 if (!empty($reCAPTCHA->secretKey)) {
247 $gRecaptchaResponse = HttpHelper::post(
248 'https://www.google.com/recaptcha/api/siteverify',
249 ['secret' => $reCAPTCHA->secretKey, 'response' => $token]
250 );
251 $isgReCaptchaVerified = false;
252 if (!is_wp_error($gRecaptchaResponse)) {
253 if (
254 $captchaV3Settings
255 && !empty($gRecaptchaResponse->score)
256 && ((float) $gRecaptchaResponse->score < (float) $captchaV3Settings->score)
257 ) {
258 wp_send_json_error(
259 __(
260 $captchaV3Settings->message,
261 'bit-form'
262 )
263 );
264 }
265
266 $isgReCaptchaVerified = $gRecaptchaResponse->success;
267 }
268 if (!$isgReCaptchaVerified) {
269 return new WP_Error('spam_detection', __('Please verify reCAPTCHA', 'bit-form'));
270 }
271 }
272 }
273 $existAuth = (new IntegrationHandler($this->_form_id))->getAllIntegration('wp_user_auth', 'wp_auth', 1);
274 if (!is_wp_error($existAuth) && count($existAuth) > 0 && is_user_logged_in()) {
275 return new WP_Error('auth_error', __('You are already logged in', 'bit-form'));
276 }
277 $validateForm = $this->validateFormSubmission($_POST);
278 $form_fields = $this->getFields();
279 $formFieldValidator = new FormFieldValidator($form_fields, $_POST, $_FILES);
280 $validUniuqFields = [];
281
282 $existFilter = has_filter('bf_check_duplicate_entry');
283 if (true === $existFilter) {
284 $validUniuqFields = apply_filters('bf_check_duplicate_entry', $form_fields, $_POST);
285 }
286
287 $validateField = $formFieldValidator->validate('create', $this->_form_id);
288 if ($validateForm && $validateField && 0 === count($validUniuqFields)) {
289 return true;
290 } else {
291 $error = __('Please submit form with valid fields', 'bit-form');
292 if (!$validateForm) {
293 $errorMessages = $error;
294 } elseif (count($formFieldValidator->getMessage()) > 0) {
295 $errorMessages = $formFieldValidator->getMessage();
296 } else {
297 $errorMessages = 0 === count($validUniuqFields) ? $error : $validUniuqFields;
298 }
299 return new WP_Error('validation_error', $errorMessages);
300 }
301 }
302 return new WP_Error('unknown_form', __('Form does not exist', 'bit-form'));
303 } else {
304 return new WP_Error('token_expired', __('Token expired', 'bit-form'));
305 }
306 }
307
308 public function verifySubmissionNonce()
309 {
310 if (!isset($_POST['bitforms_token'])) {
311 return false;
312 }
313 $token = sanitize_text_field($_POST['bitforms_token']);
314 unset($_POST['_ajax_nonce'], $_POST['action'], $_POST['bitforms_id'], $_POST['bitforms_token']);
315 if (!is_user_logged_in()) {
316 return true;
317 }
318 return wp_verify_nonce($token, "bitforms_{$this->form_id}");
319 }
320
321 public function setViewCount()
322 {
323 if (!current_user_can('manage_options')) {
324 $update_status = $this->formModel->update(
325 [
326 'views' => intval(static::$form[0]->views) + 1
327 ],
328 [
329 'id' => $this->form_id
330 ]
331 );
332 }
333 }
334
335 public function checkSubmissionRestriction()
336 {
337 $formContents = $this->getFormContent();
338 $fromRestrictionSetitingsEnabled = empty($formContents->additional->enabled) ? [] : $formContents->additional->enabled;
339 $fromRestrictionSetitings = empty($formContents->additional->settings) ? null : $formContents->additional->settings;
340 if (is_null($formContents->additional->enabled) || is_null($formContents->additional->settings)) {
341 return false;
342 }
343 $restrictionMessage = [];
344 $ipTool = new IpTool();
345 $ipAddress = $ipTool->getIP();
346 foreach ($fromRestrictionSetitingsEnabled as $restrictionKey => $isEnabled) {
347 if ($isEnabled) {
348 if ('entry_limit' === $restrictionKey && isset($fromRestrictionSetitings->{$restrictionKey})) {
349 $formEntry = new FormEntryModel();
350 $countResult = $formEntry->count(
351 [
352 'form_id' => $this->form_id
353 ]
354 );
355 $count = !empty($countResult[0]) && !empty($countResult[0]->count) ? $countResult[0]->count : false;
356 if ($count && $count >= intval($fromRestrictionSetitings->{$restrictionKey})) {
357 $restrictionMessage[] = __('Sorry!! Entry limit exceeded', 'bit-form');
358 }
359 }
360 if ('onePerIp' === $restrictionKey) {
361 $formEntry = new FormEntryModel();
362 $countResult = $formEntry->count(
363 [
364 'form_id' => $this->form_id,
365 'user_ip' => ip2long($ipAddress)
366 ]
367 );
368 $count = !empty($countResult[0]) && !empty($countResult[0]->count) ? $countResult[0]->count : false;
369
370 if ($count && $count > 0) {
371 $restrictionMessage[] = __('Sorry!! You have already submitted', 'bit-form');
372 }
373 }
374 if ('is_login' === $restrictionKey && 0 === get_current_user_id()) {
375 $restrictionMessage[] = __($fromRestrictionSetitings->is_login->message, 'bit-form');
376 }
377 if ('empty_submission' === $restrictionKey) {
378 $isEmpty = $this->checkEmptySubmission($_POST, $_FILES);
379 if ($isEmpty) {
380 $restrictionMessage[] = __($fromRestrictionSetitings->empty_submission->message, 'bit-form');
381 }
382 }
383 if ('restrict_form' === $restrictionKey && isset($fromRestrictionSetitings->{$restrictionKey})) {
384 $day = empty($fromRestrictionSetitings->{$restrictionKey}->day) ? null : $fromRestrictionSetitings->{$restrictionKey}->day;
385 $date = empty($fromRestrictionSetitings->{$restrictionKey}->date) ? null : $fromRestrictionSetitings->{$restrictionKey}->date;
386 $time = empty($fromRestrictionSetitings->{$restrictionKey}->time) ? null : $fromRestrictionSetitings->{$restrictionKey}->time;
387
388 $isdayOk = $isdateOk = $istimeOk = true;
389 $dayNotOkMsg = $dateNotOkMsg = $timeNotOkMsg = '';
390 $dateTimeHelper = new DateTimeHelper();
391 if (
392 !empty($day)
393 && is_array($day)
394 && (in_array('Friday', $day)
395 || in_array('Saturday', $day)
396 || in_array('Sunday', $day)
397 || in_array('Monday', $day)
398 || in_array('Tuesday', $day)
399 || in_array('Wednesday', $day)
400 || in_array('Thursday', $day))
401 && (!in_array($dateTimeHelper->getDay('full-name'), $day))
402 ) {
403 $isdayOk = false;
404 $dayMsgVarsFormat = '';
405 foreach ($day as $dayIndex => $dayValue) {
406 if ($dayIndex > 0) {
407 $dayMsgVarsFormat .= ', ';
408 }
409 $dayMsgVarsFormat .= '%s';
410 }
411 $dayNotOkMsg = vsprintf(__("in $dayMsgVarsFormat", 'bit-form'), $day);
412 }
413 if (
414 !empty($day)
415 && is_array($day)
416 && (in_array('Custom', $day))
417 ) {
418 $startDate = empty($date->from) ? '00-00-0000' : $date->from;
419 $endDate = empty($date->to) ? '00-00-0000' : $date->to;
420 if (!empty($date->from) && false !== strpos($startDate, 'T')) {
421 $startDate = $dateTimeHelper->getDate($startDate, false, null, 'm-d-Y');
422 }
423 if (!empty($date->to) && false !== strpos($endDate, 'T')) {
424 $endDate = $dateTimeHelper->getDate($endDate, false, null, 'm-d-Y');
425 }
426 $currentDate = $dateTimeHelper->getDate(null, null, null, 'm-d-Y');
427 if (!($currentDate >= $startDate && $currentDate <= $endDate)) {
428 $isdateOk = false;
429 $dateNotOkMsg = sprintf(__('within %s to %s', 'bit-form'), $startDate, $endDate);
430 }
431 }
432
433 if (!empty($time)) {
434 $startTime = empty($time->from) ? '00:00' : $time->from;
435 $endTime = empty($time->to) ? '23:59.999' : $time->to;
436 $currentTime = $dateTimeHelper->getTime(null, null, null, 'H:i');
437 if (!($currentTime >= $startTime && $currentTime <= $endTime)) {
438 $istimeOk = false;
439 $startTime = $dateTimeHelper->getTime($startTime, 'H:i', null);
440 $endTime = $dateTimeHelper->getTime($endTime, 'H:i', null);
441 $isTimeOk = false;
442 $timeNotOkMsg = sprintf(__('%s to %s', 'bit-form'), $startTime, $endTime);
443 }
444 }
445
446 if (!($isdateOk && $isdayOk && $istimeOk)) {
447 if (!$isdayOk) {
448 $restrictionMessage[] = !empty($timeNotOkMsg) ? sprintf(__('Form is available %s From %s', 'bit-form'), $dayNotOkMsg, $timeNotOkMsg) :
449 sprintf(__('Form is available %s', 'bit-form'), $dayNotOkMsg, $timeNotOkMsg);
450 } elseif (!$isdateOk) {
451 $restrictionMessage[] = !empty($timeNotOkMsg) ? sprintf(__('Form is available %s From %s', 'bit-form'), $dateNotOkMsg, $timeNotOkMsg) :
452 sprintf(__('Form is available %s', 'bit-form'), $dateNotOkMsg, $timeNotOkMsg);
453 } elseif (!$istimeOk) {
454 $restrictionMessage[] = sprintf(__('Form is available on %s', 'bit-form'), $timeNotOkMsg);
455 }
456 }
457 }
458 if ('blocked_ip' === $restrictionKey && isset($fromRestrictionSetitings->{$restrictionKey})) {
459 $isIpBlocked = false;
460 foreach ($fromRestrictionSetitings->{$restrictionKey} as $ipIndex => $ipDetails) {
461 if (!empty($ipDetails->status) && $ipDetails->status && !empty($ipDetails->ip) && $ipDetails->ip === $ipAddress) {
462 $isIpBlocked = true;
463 break;
464 }
465 }
466 if ($isIpBlocked) {
467 $restrictionMessage[] = sprintf(__('Sorry!! Your IP address is %s, Blocked from submitting the form', 'bit-form'), $ipAddress);
468 }
469 }
470 if ('private_ip' === $restrictionKey && isset($fromRestrictionSetitings->{$restrictionKey})) {
471 $isIpWhiteListed = false;
472 foreach ($fromRestrictionSetitings->{$restrictionKey} as $ipIndex => $ipDetails) {
473 if (!empty($ipDetails->status) && $ipDetails->status && !empty($ipDetails->ip) && $ipDetails->ip === $ipAddress) {
474 $isIpWhiteListed = true;
475 break;
476 }
477 }
478 if (!$isIpWhiteListed) {
479 $restrictionMessage[] = sprintf(__('Sorry!! Your IP address is %s, Blocked from submitting the form', 'bit-form'), $ipAddress);
480 }
481 }
482 }
483 }
484 return $restrictionMessage;
485 }
486
487 public function honeypotTrap()
488 {
489 if ($this->isHoneypotActive()) {
490 $time = \time();
491 $token = base64_encode(base64_encode($time . '.' . wp_hash(wp_get_session_token() . $time)));
492 $script = "document.addEventListener('DOMContentLoaded',(event)=>{ let frm=document.getElementById('form-{$this->_form_identifier}'),token=document.createElement('input');token.type='hidden',token.name='token',token.value='$token',frm.prepend(token);let nam=document.createElement('input');nam.type='text',nam.className='vis-n',nam.name='{$token}.name',frm.prepend(nam);let em=document.createElement('input');em.type='email',em.className='vis-n',em.name='{$token}.email',frm.prepend(em);let msg=document.createElement('textarea');msg.className='vis-n',msg.name='{$token}.message',frm.prepend(msg);})";
493 wp_add_inline_script('bitforms-frontend-script', $script, 'after');
494 }
495 }
496
497 /**
498 * Will check if form is submitted by a bot
499 *
500 * @return Boolean true - if submitted by bot else false
501 */
502 public function isTrappedInHoneypot()
503 {
504 if (!$this->isHoneypotActive()) {
505 return false;
506 }
507
508 if (empty($_POST['token'])) {
509 return true;
510 } else {
511 $token = $_POST['token'];
512 }
513
514 $dtoken = explode('.', base64_decode(base64_decode($token)))[1];
515 $time = explode('.', base64_decode(base64_decode($token)))[0];
516
517 if (time() - $time < 6 || false === hash_equals($dtoken, wp_hash(wp_get_session_token() . $time))) {
518 return true;
519 }
520 if (
521 !empty($_POST[$token . '.name'])
522 || !empty($_POST[$token . '_name'])
523 || !empty($_POST[$token . '.email'])
524 || !empty($_POST[$token . '_email'])
525 || !empty($_POST[$token . '.message'])
526 || !empty($_POST[$token . '_message'])
527 ) {
528 return true;
529 }
530 unset($_POST['token'], $_POST[$token . 'name'], $_POST[$token . 'email'], $_POST[$token . 'message']);
531 return false;
532 }
533
534 public function isHoneypotActive()
535 {
536 $formContents = $this->getFormContent();
537 $enabled = empty($formContents->additional->enabled) ? null : $formContents->additional->enabled;
538 if (!empty($enabled->honeypot) && $enabled->honeypot) {
539 return true;
540 }
541 return false;
542 }
543
544 public function checkPaymentFields()
545 {
546 $formContents = $this->getFormContent();
547 $fields = $formContents->fields;
548
549 $payments = [];
550 foreach ($fields as $fldData) {
551 if ('paypal' === $fldData->typ && property_exists($fldData, 'payIntegID')) {
552 $payments['paypalKey'] = $this->getClientKey($fldData->payIntegID, 'clientID');
553 } elseif ('razorpay' === $fldData->typ && property_exists($fldData->options, 'payIntegID')) {
554 $payments['razorpayKey'] = $this->getClientKey($fldData->options->payIntegID, 'apiKey');
555 }
556 }
557
558 return $payments;
559 }
560
561 private function getClientKey($integID, $keyName)
562 {
563 $client = '';
564 if (!empty($integID)) {
565 $integrationHandler = new IntegrationHandler(0);
566 $integration = $integrationHandler->getAIntegration($integID, 'app', 'payments');
567 if (!is_wp_error($integration)) {
568 $integration_details = json_decode($integration[0]->integration_details);
569 $client = base64_encode($integration_details->{$keyName});
570 }
571 }
572 return $client;
573 }
574 }
575