PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 0.0.7
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v0.0.7
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / includes / Admin / Elementor / Better_Payment_Widget.php

Better_Payment_Widget.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 0.0.7, at includes/Admin/Elementor/Better_Payment_Widget.php

2,420 lines 95.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Admin\Elementor;
4
5 use Better_Payment\Lite\Admin\Better_Payment_DB;
6 use Better_Payment\Lite\Classes\Better_Payment_Handler;
7 use \Elementor\Controls_Manager as Controls_Manager;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
9 use Elementor\Group_Control_Background;
10 use Elementor\Group_Control_Border;
11 use Elementor\Group_Control_Box_Shadow;
12 use Elementor\Group_Control_Typography;
13 use \Elementor\Repeater;
14 use Elementor\Utils;
15 use \Elementor\Widget_Base as Widget_Base;
16
17 /**
18 * Exit if accessed directly
19 */
20 if (!defined('ABSPATH')) {
21 exit;
22 }
23
24 /**
25 * The elementor widget class
26 *
27 * @since 0.0.1
28 */
29 class Better_Payment_Widget extends Widget_Base {
30
31 private $better_payment_global_settings = [];
32
33 public function get_name() {
34 return 'better-payment';
35 }
36
37 public function get_title() {
38 return esc_html__( 'Better Payment', 'better-payment' );
39 }
40
41 public function get_icon() {
42 return 'bp-icon bp-logo';
43 }
44
45 public function get_keywords() {
46 return [
47 'payment', 'better-payment' ,'paypal', 'stripe', 'sell', 'donate', 'transaction', 'online-transaction'
48 ];
49 }
50
51 public function get_style_depends() {
52 return apply_filters( 'better_payment/elementor/editor/get_style_depends', [ 'better-payment-el', 'bp-icon-front', 'better-payment-style', 'better-payment-common-style', 'better-payment-admin-style' ] );
53 }
54
55 public function get_script_depends() {
56 return apply_filters( 'better_payment/elementor/editor/get_script_depends', [ 'better-payment-common-script', 'better-payment' ] );
57 }
58
59 protected function register_controls() {
60 $this->better_payment_global_settings = Better_Payment_DB::get_settings();
61
62 $this->start_controls_section(
63 'better_payment_form_setting',
64 [
65 'label' => esc_html__( 'Payment Settings', 'better-payment' ),
66 ]
67 );
68
69 do_action('better_payment/elementor/editor/layouts_payment_settings_section', $this);
70
71 $this->add_control(
72 'better_payment_form_layout',
73 [
74 'label' => esc_html__( 'Form Layout', 'better-payment' ),
75 'type' => Controls_Manager::SELECT,
76 'default' => 'layout-1',
77 'options' => [
78 'layout-1' => 'Layout 1',
79 'layout-2' => 'Layout 2',
80 'layout-3' => 'Layout 3',
81 ],
82 ]
83 );
84
85 $this->add_control(
86 'better_payment_form_payment_source',
87 [
88 'label' => esc_html__( 'Payment Source', 'better-payment' ),
89 'type' => Controls_Manager::SELECT,
90 'default' => 'manual',
91 'options' => [
92 'manual' => 'Manual',
93 'woocommerce' => 'WooCommerce',
94 ],
95 ]
96 );
97
98 $this->add_control( 'better_payment_form_payment_source_notice', [
99 'type' => Controls_Manager::RAW_HTML,
100 'raw' => sprintf( __( '<a href="%1$s" target="_blank"><strong>WooCommerce</strong></a> is not installed/activated on your site. Please install and activate <a href="%1$s" target="_blank"><strong>WooCommerce</strong></a> first.', 'better-payment' ), esc_url('plugin-install.php?s=woocommerce&tab=search&type=term') ),
101 'content_classes' => 'eael-warning',
102 'condition' => [
103 'better_payment_form_payment_source' => 'woocommerce' . ( ! class_exists('woocommerce') ? '' : 'exist' ),
104 ],
105 ] );
106
107 $this->add_control(
108 'better_payment_form_woocommerce_product_section',
109 [
110 'label' => __( 'Product', 'better-payment' ),
111 'type' => Controls_Manager::HIDDEN,
112 'condition' => [
113 'better_payment_form_payment_source' => 'woocommerce',
114 ],
115 ]
116 );
117
118 $this->add_control( "better_payment_form_woocommerce_product_id", [
119 'label' => __( 'Choose a Product', 'better-payment' ),
120 'description' => __( 'Enter Product IDs separated by a comma', 'better-payment' ),
121 'type' => 'better-payment-select2',
122 'label_block' => true,
123 'multiple' => false,
124 'source_type' => 'product',
125 'source_name' => 'post_type',
126 'placeholder' => __( 'Search By', 'better-payment' ),
127 'condition' => [
128 'better_payment_form_payment_source' => 'woocommerce',
129 ],
130 'separator' => 'after',
131 'default' => __( '1', 'better-payment' ),
132 'dynamic' => [
133 'active' => false,
134 ],
135 ] );
136
137 $this->add_control(
138 'better_payment_form_title',
139 [
140 'label' => __( 'Form Title', 'better-payment' ),
141 'type' => Controls_Manager::HIDDEN,
142 'dynamic' => [
143 'active' => true,
144 ],
145 'label_block' => true,
146 'default' => __( 'Form Title', 'better-payment' )
147 ]
148 );
149
150 $this->add_control(
151 'better_payment_form_paypal_enable',
152 [
153 'label' => __( 'Enable PayPal', 'better-payment' ),
154 'type' => Controls_Manager::SWITCHER,
155 'label_on' => __( 'Yes', 'better-payment' ),
156 'label_off' => __( 'No', 'better-payment' ),
157 'return_value' => 'yes',
158 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_general_general_paypal']), //yes or no
159 'separator' => 'before',
160 ]
161 );
162
163 $this->add_control( 'better_payment_form_paypal_enable_notice', [
164 'type' => Controls_Manager::RAW_HTML,
165 'raw' => sprintf( __( 'Whoops! It seems like you haven\'t configured <b>PayPal (Business Email) Settings</b>. Make sure to configure these settings before you publish the form.', 'better-payment' ) ),
166 'content_classes' => 'eael-warning',
167 'condition' => [
168 'better_payment_form_paypal_enable' => 'yes',
169 'better_payment_paypal_business_email' => '',
170 ],
171 ] );
172
173 $this->add_control(
174 'better_payment_form_stripe_enable',
175 [
176 'label' => __( 'Enable Stripe', 'better-payment' ),
177 'type' => Controls_Manager::SWITCHER,
178 'label_on' => __( 'Yes', 'better-payment' ),
179 'label_off' => __( 'No', 'better-payment' ),
180 'return_value' => 'yes',
181 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_general_general_stripe']), //yes or no
182 ]
183 );
184
185 $this->add_control( 'better_payment_form_stripe_enable_notice', [
186 'type' => Controls_Manager::RAW_HTML,
187 'raw' => sprintf( __( 'Whoops! It seems like you haven\'t configured <b>Stripe (Public and Secret Key) Settings</b>. Make sure to configure these settings before you publish the form.', 'better-payment' ) ),
188 'content_classes' => 'eael-warning',
189 'conditions' => [
190 'relation' => 'and',
191 'terms' => [
192 [
193 'name' => 'better_payment_form_stripe_enable',
194 'value' => 'yes',
195 ],
196 [
197 'relation' => 'or',
198 'terms' => [
199 [
200 'name' => 'better_payment_stripe_public_key',
201 'value' => '',
202 ],
203 [
204 'name' => 'better_payment_stripe_secret_key',
205 'value' => '',
206 ],
207 ],
208 ],
209 ],
210 ],
211 ] );
212
213 $this->add_control(
214 'better_payment_form_email_enable',
215 [
216 'label' => __( 'Enable Email Notification', 'better-payment' ),
217 'type' => Controls_Manager::SWITCHER,
218 'label_on' => __( 'Yes', 'better-payment' ),
219 'label_off' => __( 'No', 'better-payment' ),
220 'return_value' => 'yes',
221 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_general_general_email']), //yes or no
222 ]
223 );
224
225 $better_payment_helper = new \Better_Payment\Lite\Classes\Better_Payment_Helper();
226 $better_payment_general_currency = $this->better_payment_global_settings['better_payment_settings_general_general_currency'];
227
228 $better_payment_general_currency_woocommerce = $better_payment_general_currency;
229 if( class_exists('woocommerce') ) {
230 $better_payment_general_currency_woocommerce = get_woocommerce_currency() ? get_woocommerce_currency() : $better_payment_general_currency_woocommerce;
231 }
232
233 $this->add_control(
234 'better_payment_form_currency_use_woocommerce',
235 [
236 'label' => esc_html__( 'Use WooCommerce Currency?', 'better-payment' ),
237 'type' => Controls_Manager::SWITCHER,
238 'label_on' => __( 'Yes', 'better-payment' ),
239 'label_off' => __( 'No', 'better-payment' ),
240 'return_value' => 'yes',
241 'default' => '',
242 'condition' => [
243 'better_payment_form_payment_source' => 'woocommerce',
244 ],
245 ]
246 );
247
248 $this->add_control(
249 'better_payment_form_currency',
250 [
251 'label' => esc_html__( 'Currency', 'better-payment' ),
252 'type' => Controls_Manager::SELECT,
253 'default' => esc_html($better_payment_general_currency), //USD
254 'options' => $better_payment_helper->get_currency_list(),
255 'conditions' => [
256 'relation' => 'or',
257 'terms' => [
258 [
259 'relation' => 'and',
260 'terms' => [
261 [
262 'name' => 'better_payment_form_paypal_enable',
263 'value' => 'yes',
264 ],
265 [
266 'name' => 'better_payment_form_payment_source',
267 'value' => 'manual',
268 ],
269 ],
270 ],
271
272 [
273 'relation' => 'and',
274 'terms' => [
275 [
276 'name' => 'better_payment_form_stripe_enable',
277 'value' => 'yes',
278 ],
279 [
280 'name' => 'better_payment_form_payment_source',
281 'value' => 'manual',
282 ],
283 ],
284 ],
285
286 [
287 'relation' => 'and',
288 'terms' => [
289 [
290 'name' => 'better_payment_form_paypal_enable',
291 'value' => 'yes',
292 ],
293 [
294 'name' => 'better_payment_form_currency_use_woocommerce',
295 'value' => '',
296 ],
297 ],
298 ],
299
300 [
301 'relation' => 'and',
302 'terms' => [
303 [
304 'name' => 'better_payment_form_stripe_enable',
305 'value' => 'yes',
306 ],
307 [
308 'name' => 'better_payment_form_currency_use_woocommerce',
309 'value' => '',
310 ],
311 ],
312 ],
313
314 ],
315 ],
316 ]
317 );
318
319 $this->add_control(
320 'better_payment_form_currency_woocommerce',
321 [
322 'label' => esc_html__( 'WooCommerce Currency', 'better-payment' ),
323 'type' => Controls_Manager::SELECT,
324 'default' => $better_payment_general_currency_woocommerce,
325 'options' => [
326 $better_payment_general_currency_woocommerce => $better_payment_general_currency_woocommerce,
327 ],
328 'condition' => [
329 'better_payment_form_payment_source' => 'woocommerce',
330 'better_payment_form_currency_use_woocommerce' => 'yes',
331
332 ]
333 ]
334 );
335
336 $this->add_control(
337 'better_payment_form_currency_notice',
338 [
339 'type' => Controls_Manager::RAW_HTML,
340 'raw' => sprintf( __( 'Supported by %sStripe%s only', 'better-payment' ), '<strong>', '</strong>' ),
341 'content_classes' => 'eael-warning',
342 'conditions' => [
343 'relation' => 'and',
344 'terms' => [
345 [
346 'name' => 'better_payment_form_paypal_enable',
347 'value' => 'yes',
348 ],
349 [
350 'relation' => 'or',
351 'terms' => [
352 [
353 'name' => 'better_payment_form_currency',
354 'value' => 'AED',
355 ],
356 [
357 'name' => 'better_payment_form_currency',
358 'value' => 'ZAR',
359 ],
360 ],
361 ]
362 ],
363 ]
364 ]
365 );
366
367 $this->add_control(
368 'better_payment_form_currency_alignment',
369 [
370 'label' => esc_html__( 'Currency Alignment', 'better-payment' ),
371 'type' => Controls_Manager::CHOOSE,
372 'options' => [
373 'left' => [
374 'title' => esc_html__( 'Left', 'better-payment' ),
375 'icon' => 'eicon-text-align-left',
376 ],
377 'right' => [
378 'title' => esc_html__( 'Right', 'better-payment' ),
379 'icon' => 'eicon-text-align-right',
380 ],
381 ],
382 ]
383 );
384
385 $this->end_controls_section();
386
387 $this->form_element_settings();
388 $this->paypal_form_setting();
389 $this->stripe_form_setting();
390 $this->email_element_settings();
391
392 $this->success_message_setting();
393 $this->error_message_setting();
394
395 $this->form_style();
396 }
397
398 public function form_element_settings() {
399 $this->start_controls_section(
400 'better_payment_form_element',
401 [
402 'label' => esc_html__( 'Form Settings', 'better-payment' ),
403 'conditions' => [
404 'relation' => 'or',
405 'terms' => [
406 [
407 'name' => 'better_payment_form_paypal_enable',
408 'value' => 'yes',
409 ],
410 [
411 'name' => 'better_payment_form_stripe_enable',
412 'value' => 'yes',
413 ],
414 ]
415 ]
416 ]
417 );
418
419 do_action('better_payment/elementor/editor/layouts_form_settings_section', $this);
420
421 $form_fields_repeater = new Repeater();
422
423 $form_fields_repeater->add_control(
424 'better_payment_field_name_heading',
425 [
426 'label' => __( 'Field Name', 'better-payment' ),
427 'type' => Controls_Manager::TEXT,
428 'default' => __( 'Field Name', 'better-payment' ),
429 'label_block' => false,
430 'ai' => [
431 'active' => false,
432 ],
433 ]
434 );
435
436 $form_fields_repeater->add_control(
437 'better_payment_field_name_placeholder',
438 [
439 'label' => __( 'Placeholder Text', 'better-payment' ),
440 'type' => Controls_Manager::TEXT,
441 'default' => __( 'Field Name', 'better-payment' ),
442 'label_block' => false,
443 'ai' => [
444 'active' => false,
445 ],
446 ]
447 );
448
449 $form_fields_repeater->add_control(
450 'better_payment_field_type',
451 [
452 'label' => __( 'Field Type', 'better-payment' ),
453 'type' => Controls_Manager::SELECT,
454 'default' => 'text',
455 'options' => [
456 'text' => __( 'Text', 'better-payment' ),
457 'email' => __( 'Email', 'better-payment' ),
458 'number' => __( 'Number', 'better-payment' ),
459 // 'password' => __( 'Password', 'better-payment' ),
460 // 'textarea' => __( 'Textarea', 'better-payment' ),
461 // 'select' => __( 'Select', 'better-payment' ),
462 // 'checkbox' => __( 'Checkbox', 'better-payment' ),
463 // 'radio' => __( 'Radio', 'better-payment' ),
464 // 'date' => __( 'Date', 'better-payment' ),
465 // 'time' => __( 'Time', 'better-payment' ),
466 // 'datetime' => __( 'Date Time', 'better-payment' ),
467 // 'file' => __( 'File', 'better-payment' ),
468 // 'hidden' => __( 'Hidden', 'better-payment' ),
469 ],
470 'label_block' => false,
471 ]
472 );
473
474 $form_fields_repeater->add_control(
475 'better_payment_primary_field_type',
476 [
477 'label' => __( 'Primary Field Type', 'better-payment' ),
478 'description' => __( 'If this is a primary field (first name, last name, email etc), then please select one.', 'better-payment' ),
479 'type' => Controls_Manager::SELECT,
480 'default' => 'primary_none',
481 'options' => [
482 'primary_first_name' => __( 'First Name', 'better-payment' ),
483 'primary_last_name' => __( 'Last Name', 'better-payment' ),
484 'primary_email' => __( 'Email', 'better-payment' ),
485 'primary_payment_amount' => __( 'Payment Amount', 'better-payment' ),
486 'primary_none' => __( 'None', 'better-payment' ),
487 ],
488 'label_block' => false,
489 ]
490 );
491
492 $form_fields_repeater->add_control(
493 'better_payment_field_icon',
494 [
495 'label' => esc_html__( 'Icon', 'better-payment' ),
496 'description' => esc_html__( 'Select an icon for this field (not applicable for primary field - Payment Amount).', 'better-payment' ),
497 'type' => Controls_Manager::ICONS,
498
499 ]
500 );
501
502 $form_fields_repeater->add_control(
503 'better_payment_field_name_show',
504 [
505 'label' => __( 'Show', 'better-payment' ),
506 'type' => Controls_Manager::SWITCHER,
507 'label_on' => __( 'Yes', 'better-payment' ),
508 'label_off' => __( 'No', 'better-payment' ),
509 'return_value' => 'yes',
510 'default' => 'yes',
511
512 ]
513 );
514
515 $form_fields_repeater->add_control(
516 'better_payment_field_name_show_notice',
517 [
518 'type' => Controls_Manager::RAW_HTML,
519 'raw' => sprintf(
520 esc_html__( 'Field is hidden if payment source is WooCommerce.', 'better-payment' ),
521 ),
522 'content_classes' => 'elementor-descriptor',
523 'condition' => [
524 'better_payment_primary_field_type' => 'primary_payment_amount'
525 ],
526 ]
527 );
528
529 $form_fields_repeater->add_control(
530 'better_payment_field_name_required',
531 [
532 'label' => __( 'Required', 'better-payment' ),
533 'type' => Controls_Manager::SWITCHER,
534 'label_on' => __( 'Yes', 'better-payment' ),
535 'label_off' => __( 'No', 'better-payment' ),
536 'return_value' => 'yes',
537 'default' => 'no',
538 'condition' => [
539 'better_payment_field_name_show' => 'yes'
540 ],
541 ]
542 );
543
544 $form_fields_repeater->add_control(
545 'better_payment_field_name_display_inline',
546 [
547 'label' => __( 'Display Inline?', 'better-payment' ),
548 'type' => Controls_Manager::SWITCHER,
549 'label_on' => __( 'Yes', 'better-payment' ),
550 'label_off' => __( 'No', 'better-payment' ),
551 'return_value' => 'inline-block',
552 'default' => 'block',
553 'condition' => [
554 'better_payment_field_name_show' => 'yes'
555 ],
556 'selectors' => [
557 '{{WRAPPER}} .better-payment-form-layout form {{CURRENT_ITEM}}.bp-form__group' => 'display: {{VALUE}};',
558 '{{WRAPPER}} .better-payment-form {{CURRENT_ITEM}}.better-payment-field-advanced-layout' => 'display: {{VALUE}};',
559
560 ]
561 ]
562 );
563
564 $form_fields_repeater->add_control(
565 'better_payment_field_name_display_inline_width',
566 [
567 'label' => __( 'Column Width', 'better-payment' ),
568 'type' => Controls_Manager::SLIDER,
569 'size_units' => [ '%', 'px', 'em' ],
570 'range' => [
571 '%' => [
572 'min' => 1,
573 'max' => 100,
574 ],
575 'px' => [
576 'min' => 10,
577 'max' => 1500,
578 ],
579 'em' => [
580 'min' => 1,
581 'max' => 80,
582 ],
583 ],
584 'condition' => [
585 'better_payment_field_name_show' => 'yes',
586 'better_payment_field_name_display_inline' => 'inline-block'
587 ],
588 'selectors' => [
589 '{{WRAPPER}} .better-payment-form-layout form {{CURRENT_ITEM}}.bp-form__group' => 'width: {{SIZE}}{{UNIT}};',
590 '{{WRAPPER}} .better-payment-form {{CURRENT_ITEM}}.better-payment-field-advanced-layout' => 'width: {{SIZE}}{{UNIT}};',
591 ],
592 'description' => __( 'Set the width of the column. Use less than 50% to make fields inline', 'better-payment' ),
593 ]
594 );
595
596 $this->add_control(
597 'better_payment_form_fields',
598 [
599 'label' => esc_html__( 'Form Fields', 'better-payment' ),
600 'type' => \Elementor\Controls_Manager::REPEATER,
601 'fields' => $form_fields_repeater->get_controls(),
602 'default' => [
603 [
604 'better_payment_field_name_heading' => esc_html__( 'First Name', 'better-payment' ),
605 'better_payment_field_name_placeholder' => esc_html__( 'First Name', 'better-payment' ),
606 'better_payment_field_type' => 'text',
607 'better_payment_primary_field_type' => 'primary_first_name',
608 'better_payment_field_name_show' => 'yes',
609 'better_payment_field_name_required' => 'no',
610 ],
611 [
612 'better_payment_field_name_heading' => esc_html__( 'Last Name', 'better-payment' ),
613 'better_payment_field_name_placeholder' => esc_html__( 'Last Name', 'better-payment' ),
614 'better_payment_field_type' => 'text',
615 'better_payment_primary_field_type' => 'primary_last_name',
616 'better_payment_field_name_show' => 'yes',
617 'better_payment_field_name_required' => 'no',
618 ],
619 [
620 'better_payment_field_name_heading' => esc_html__( 'Email Address', 'better-payment' ),
621 'better_payment_field_name_placeholder' => esc_html__( 'Email Address', 'better-payment' ),
622 'better_payment_field_type' => 'email',
623 'better_payment_primary_field_type' => 'primary_email',
624 'better_payment_field_name_show' => 'yes',
625 'better_payment_field_name_required' => 'yes',
626 ],
627 [
628 'better_payment_field_name_heading' => esc_html__( 'Payment Amount', 'better-payment' ),
629 'better_payment_field_name_placeholder' => esc_html__( 'Payment Amount', 'better-payment' ),
630 'better_payment_field_type' => 'number',
631 'better_payment_primary_field_type' => 'primary_payment_amount',
632 'better_payment_field_name_show' => 'yes',
633 'better_payment_field_name_required' => 'yes',
634 ],
635 ],
636 'title_field' => '{{{ better_payment_field_name_heading }}}',
637 ]
638 );
639
640 $repeater = new Repeater();
641
642
643 $repeater->add_control(
644 'better_payment_amount_val',
645 [
646 'label' => esc_html__( 'Payment Amount', 'better-payment' ),
647 'type' => Controls_Manager::NUMBER,
648 'min' => 1,
649 ]
650 );
651
652 $this->add_control(
653 'better_payment_show_amount_list',
654 [
655 'label' => __( 'Show Amount List', 'better-payment' ),
656 'type' => Controls_Manager::SWITCHER,
657 'label_on' => __( 'Yes', 'better-payment' ),
658 'label_off' => __( 'No', 'better-payment' ),
659 'return_value' => 'yes',
660 'default' => 'no',
661 'condition' => [
662 'better_payment_form_payment_source!' => 'woocommerce',
663 ],
664 ]
665 );
666
667 $this->add_control(
668 'better_payment_amount',
669 [
670 'label' => esc_html__( 'Amount List', 'better-payment' ),
671 'type' => Controls_Manager::REPEATER,
672 'default' => [
673 [
674 'better_payment_amount_val' => 5
675 ],
676 [
677 'better_payment_amount_val' => 10
678 ],
679 [
680 'better_payment_amount_val' => 15
681 ],
682 [
683 'better_payment_amount_val' => 20
684 ],
685 ],
686 'fields' => $repeater->get_controls(),
687 'title_field' => '<i class="{{ better_payment_amount_val }}" aria-hidden="true"></i> {{{ better_payment_amount_val }}}',
688 'condition' => [
689 'better_payment_show_amount_list' => 'yes',
690 'better_payment_form_payment_source!' => 'woocommerce',
691 ],
692 ]
693 );
694
695 $this->add_control(
696 'better_payment_form_transaction_details_section',
697 [
698 'label' => esc_html__( 'Transaction Details', 'better-payment' ),
699 'type' => Controls_Manager::HEADING,
700 'separator' => 'before',
701 ]
702 );
703
704 $this->add_control(
705 'better_payment_form_transaction_details_heading',
706 [
707 'label' => esc_html__( 'Heading Text', 'better-payment' ),
708 'type' => Controls_Manager::TEXT,
709 'default' => __( 'Transaction Details', 'better-payment' ),
710 'label_block' => true,
711 'ai' => [
712 'active' => false,
713 ],
714 ]
715 );
716
717 $this->add_control(
718 'better_payment_form_transaction_details_sub_heading',
719 [
720 'label' => esc_html__( 'Sub Heading Text', 'better-payment' ),
721 'type' => Controls_Manager::TEXT,
722 'default' => __( 'Total payment of your product in the following:', 'better-payment' ),
723 'label_block' => true,
724 'ai' => [
725 'active' => false,
726 ],
727 ]
728 );
729
730 $this->add_control(
731 'better_payment_form_transaction_details_product_title',
732 [
733 'label' => esc_html__( 'Product Title Text', 'better-payment' ),
734 'type' => Controls_Manager::TEXT,
735 'default' => __( 'Title:', 'better-payment' ),
736 'condition' => [
737 'better_payment_form_payment_source' => 'woocommerce',
738 ],
739 'label_block' => true,
740 'ai' => [
741 'active' => false,
742 ],
743 ]
744 );
745
746 $this->add_control(
747 'better_payment_form_transaction_details_amount_text',
748 [
749 'label' => esc_html__( 'Amount Text', 'better-payment' ),
750 'type' => Controls_Manager::TEXT,
751 'default' => __( 'Amount:', 'better-payment' ),
752 'label_block' => true,
753 'ai' => [
754 'active' => false,
755 ],
756 ]
757 );
758
759 $this->add_control(
760 'better_payment_form_form_buttons_section',
761 [
762 'label' => esc_html__( 'Form Buttons', 'better-payment' ),
763 'type' => Controls_Manager::HEADING,
764 'separator' => 'before',
765 ]
766 );
767
768 $this->add_control(
769 'better_payment_form_form_buttons_paypal_button_text',
770 [
771 'label' => esc_html__( 'PayPal Button Text', 'better-payment' ),
772 'type' => Controls_Manager::TEXT,
773 'default' => __( 'Proceed to Payment', 'better-payment' ),
774 'label_block' => true,
775 'ai' => [
776 'active' => false,
777 ],
778 ]
779 );
780
781 $this->add_control(
782 'better_payment_form_form_buttons_stripe_button_text',
783 [
784 'label' => esc_html__( 'Stripe Button Text', 'better-payment' ),
785 'type' => Controls_Manager::TEXT,
786 'default' => __( 'Proceed to Payment', 'better-payment' ),
787 'label_block' => true,
788 'ai' => [
789 'active' => false,
790 ],
791 ]
792 );
793
794 $this->end_controls_section();
795 }
796
797 public function paypal_form_setting() {
798 $this->start_controls_section(
799 'better_payment_form_paypal_settings',
800 [
801 'label' => esc_html__( 'PayPal Settings', 'better-payment' ),
802 'condition' => [
803 'better_payment_form_paypal_enable' => 'yes'
804 ]
805 ]
806 );
807
808
809 $this->add_control(
810 'better_payment_paypal_business_email',
811 [
812 'label' => __( 'Business Email', 'better-payment' ),
813 'type' => Controls_Manager::TEXT,
814 'dynamic' => [
815 'active' => true,
816 ],
817 'label_block' => true,
818 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_payment_paypal_email']),
819 'ai' => [
820 'active' => false,
821 ],
822 ]
823 );
824
825 $this->add_control(
826 'better_payment_paypal_button_type',
827 [
828 'label' => esc_html__( 'Button Type', 'better-payment' ),
829 'type' => Controls_Manager::HIDDEN,
830 'default' => '_xclick',
831 'options' => [
832 '_xclick' => 'XCLICK',
833 '_cart' => 'CART',
834 '_donations' => 'DONATIONS'
835 ]
836 ]
837 );
838
839 $this->add_control(
840 'better_payment_paypal_live_mode',
841 [
842 'label' => __( 'Live Mode', 'better-payment' ),
843 'type' => Controls_Manager::SWITCHER,
844 'label_on' => __( 'Yes', 'better-payment' ),
845 'label_off' => __( 'No', 'better-payment' ),
846 'return_value' => 'yes',
847 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_payment_paypal_live_mode']), //yes or no
848 ]
849 );
850
851 $this->end_controls_section();
852 }
853
854 public function stripe_form_setting() {
855 $this->start_controls_section(
856 'better_payment_form_stripe_settings',
857 [
858 'label' => esc_html__( 'Stripe Settings', 'better-payment' ),
859 'condition' => [
860 'better_payment_form_stripe_enable' => 'yes'
861 ]
862 ]
863 );
864
865 $better_payment_is_stripe_live = $this->better_payment_global_settings['better_payment_settings_payment_stripe_live_mode'] == 'yes' ? 1 : 0;
866
867 $this->add_control(
868 'better_payment_stripe_public_key',
869 [
870 'label' => __( 'Public Key', 'better-payment' ),
871 'type' => Controls_Manager::TEXT,
872 'dynamic' => [
873 'active' => true,
874 ],
875 'label_block' => true,
876 'default' => $better_payment_is_stripe_live ? esc_html($this->better_payment_global_settings['better_payment_settings_payment_stripe_live_public']) : esc_html($this->better_payment_global_settings['better_payment_settings_payment_stripe_test_public']),
877 'ai' => [
878 'active' => false,
879 ],
880 ]
881 );
882
883 $this->add_control(
884 'better_payment_stripe_secret_key',
885 [
886 'label' => __( 'Secret Key', 'better-payment' ),
887 'type' => Controls_Manager::TEXT,
888 'input_type' => 'password',
889 'dynamic' => [
890 'active' => true,
891 ],
892 'label_block' => true,
893 'default' => $better_payment_is_stripe_live ? esc_html($this->better_payment_global_settings['better_payment_settings_payment_stripe_live_secret']) : esc_html($this->better_payment_global_settings['better_payment_settings_payment_stripe_test_secret']),
894 'ai' => [
895 'active' => false,
896 ],
897 ]
898 );
899
900 $this->add_control(
901 'better_payment_stripe_live_mode',
902 [
903 'label' => __( 'Live Mode', 'better-payment' ),
904 'type' => Controls_Manager::SWITCHER,
905 'label_on' => __( 'Yes', 'better-payment' ),
906 'label_off' => __( 'No', 'better-payment' ),
907 'return_value' => 'yes',
908 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_payment_paypal_live_mode']), //yes or no
909 ]
910 );
911
912 $this->end_controls_section();
913 }
914
915 public function email_element_settings() {
916 $this->start_controls_section(
917 'better_payment_email_element',
918 [
919 'label' => esc_html__( 'Email Settings', 'better-payment' ),
920 'condition' => [
921 'better_payment_form_email_enable' => 'yes'
922 ]
923 ]
924 );
925
926 $this->start_controls_tabs( 'better_payment_email_tabs' );
927
928 //Admin Email Notification
929 $this->start_controls_tab( 'better_payment_email_admin_tab', [
930 'label' => __( 'Admin', 'better-payment' ),
931 ] );
932
933 $this->add_control('better_payment_email_to', [
934 'label' => __('To', 'better-payment'),
935 'type' => Controls_Manager::TEXT,
936 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_to']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_to']) : esc_html(get_option('admin_email')),
937 'placeholder' => get_option('admin_email'),
938 'label_block' => true,
939 'title' => __('Email address to notify site admin after each successful transaction', 'better-payment'),
940 'render_type' => 'none',
941 'ai' => [
942 'active' => false,
943 ],
944 ]);
945
946 $default_subject = !empty($this->better_payment_global_settings['better_payment_settings_general_email_subject']) ? esc_html__($this->better_payment_global_settings['better_payment_settings_general_email_subject'], 'better-payment') : sprintf(__('Better Payment transaction on %s', 'better-payment'), esc_html(get_option('blogname')));
947
948 $this->add_control('better_payment_email_subject', [
949 'label' => __('Subject', 'better-payment'),
950 'type' => Controls_Manager::TEXT,
951 'default' => esc_html($default_subject),
952 'placeholder' => esc_html($default_subject),
953 'label_block' => true,
954 'render_type' => 'none',
955 'ai' => [
956 'active' => false,
957 ],
958 ]);
959
960 $this->add_control('better_payment_email_content', [
961 'label' => __('Message', 'better-payment'),
962 'type' => Controls_Manager::TEXTAREA,
963 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_message_admin']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_message_admin']) : '[bp-all-fields]',
964 'placeholder' => '[bp-all-fields]',
965 'render_type' => 'none',
966 ]);
967
968 $site_url_parsed = parse_url(get_site_url());
969 $better_domain = $site_url_parsed['host'] ? esc_html($site_url_parsed['host']) : 'example.com';
970
971 $this->add_control('better_payment_email_from', [
972 'label' => __('From email', 'better-payment'),
973 'type' => Controls_Manager::TEXT,
974 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_from_email']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_from_email']) : "wordpress@$better_domain",
975 'render_type' => 'none',
976 'separator' => 'before',
977 'ai' => [
978 'active' => false,
979 ],
980 ]);
981
982 $this->add_control('better_payment_email_from_name', [
983 'label' => __('From name', 'better-payment'),
984 'type' => Controls_Manager::TEXT,
985 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_from_name']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_from_name']) : esc_html(get_bloginfo('name')),
986 'render_type' => 'none',
987 'ai' => [
988 'active' => false,
989 ],
990 ]);
991
992 $this->add_control('better_payment_email_reply_to', [
993 'label' => __('Reply-To', 'better-payment'),
994 'type' => Controls_Manager::TEXT,
995 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_reply_to']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_reply_to']) : "wordpress@$better_domain",
996 'placeholder' => "wordpress@$better_domain",
997 'render_type' => 'none',
998 'ai' => [
999 'active' => false,
1000 ],
1001 ]);
1002
1003 $this->add_control('better_payment_email_cc', [
1004 'label' => __('Cc', 'better-payment'),
1005 'type' => Controls_Manager::TEXT,
1006 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_cc']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_cc']) : '',
1007 'render_type' => 'none',
1008 'ai' => [
1009 'active' => false,
1010 ],
1011 ]);
1012
1013 $this->add_control('better_payment_email_bcc', [
1014 'label' => __('Bcc', 'better-payment'),
1015 'type' => Controls_Manager::TEXT,
1016 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_bcc']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_bcc']) : '',
1017 'render_type' => 'none',
1018 'ai' => [
1019 'active' => false,
1020 ],
1021 ]);
1022
1023 $this->add_control('better_payment_email_content_type', [
1024 'label' => __('Send as', 'better-payment'),
1025 'type' => Controls_Manager::SELECT,
1026 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_send_as']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_send_as']) : 'html', //html or plain
1027 'render_type' => 'none',
1028 'options' => [
1029 'html' => __('HTML', 'better-payment'),
1030 'plain' => __('Plain', 'better-payment')
1031 ]
1032 ]);
1033
1034 $this->end_controls_tab();
1035
1036 //Customer Email Notification
1037 $this->start_controls_tab( 'better_payment_email_customer_tab', [
1038 'label' => __( 'Customer', 'better-payment' ),
1039 ] );
1040
1041 $default_subject = !empty($this->better_payment_global_settings['better_payment_settings_general_email_subject_customer']) ? esc_html__($this->better_payment_global_settings['better_payment_settings_general_email_subject_customer'], 'better-payment') : sprintf(__('Better Payment transaction on %s', 'better-payment'), esc_html(get_option('blogname')));
1042
1043 $this->add_control('better_payment_email_subject_customer', [
1044 'label' => __('Subject', 'better-payment'),
1045 'type' => Controls_Manager::TEXT,
1046 'default' => esc_html($default_subject),
1047 'placeholder' => esc_html($default_subject),
1048 'label_block' => true,
1049 'render_type' => 'none',
1050 'ai' => [
1051 'active' => false,
1052 ],
1053 ]);
1054
1055 $this->add_control('better_payment_email_content_customer', [
1056 'label' => __('Message', 'better-payment'),
1057 'type' => Controls_Manager::TEXTAREA,
1058 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_message_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_message_customer']) : '[bp-all-fields]',
1059 'placeholder' => '[bp-all-fields]',
1060 'render_type' => 'none'
1061 ]);
1062
1063 $site_url_parsed = parse_url(get_site_url());
1064 $better_domain = $site_url_parsed['host'] ? esc_html($site_url_parsed['host']) : 'example.com';
1065
1066 $this->add_control('better_payment_email_from_customer', [
1067 'label' => __('From email', 'better-payment'),
1068 'type' => Controls_Manager::TEXT,
1069 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_from_email_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_from_email_customer']) : "wordpress@$better_domain",
1070 'render_type' => 'none',
1071 'separator' => 'before',
1072 'ai' => [
1073 'active' => false,
1074 ],
1075 ]);
1076
1077 $this->add_control('better_payment_email_from_name_customer', [
1078 'label' => __('From name', 'better-payment'),
1079 'type' => Controls_Manager::TEXT,
1080 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_from_name_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_from_name_customer']) : get_bloginfo('name'),
1081 'render_type' => 'none',
1082 'ai' => [
1083 'active' => false,
1084 ],
1085 ]);
1086
1087 $this->add_control('better_payment_email_reply_to_customer', [
1088 'label' => __('Reply-To', 'better-payment'),
1089 'type' => Controls_Manager::TEXT,
1090 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_reply_to_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_reply_to_customer']) : "wordpress@$better_domain",
1091 'placeholder' => "wordpress@$better_domain",
1092 'render_type' => 'none',
1093 'ai' => [
1094 'active' => false,
1095 ],
1096 ]);
1097
1098 $this->add_control('better_payment_email_cc_customer', [
1099 'label' => __('Cc', 'better-payment'),
1100 'type' => Controls_Manager::TEXT,
1101 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_cc_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_cc_customer']) : '',
1102 'render_type' => 'none',
1103 'ai' => [
1104 'active' => false,
1105 ],
1106 ]);
1107
1108 $this->add_control('better_payment_email_bcc_customer', [
1109 'label' => __('Bcc', 'better-payment'),
1110 'type' => Controls_Manager::TEXT,
1111 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_bcc_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_bcc_customer']) : '',
1112 'render_type' => 'none',
1113 'ai' => [
1114 'active' => false,
1115 ],
1116 ]);
1117
1118 $this->add_control('better_payment_email_content_type_customer', [
1119 'label' => __('Send as', 'better-payment'),
1120 'type' => Controls_Manager::SELECT,
1121 'default' => !empty($this->better_payment_global_settings['better_payment_settings_general_email_send_as_customer']) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_email_send_as_customer']) : 'html', //html or plain
1122 'render_type' => 'none',
1123 'options' => [
1124 'html' => __('HTML', 'better-payment'),
1125 'plain' => __('Plain', 'better-payment')
1126 ]
1127 ]);
1128
1129 $this->end_controls_tab();
1130
1131 $this->end_controls_tabs();
1132
1133 $this->end_controls_section();
1134 }
1135
1136 public function success_message_setting() {
1137 $this->start_controls_section(
1138 'better_payment_form_success_message_settings',
1139 [
1140 'label' => esc_html__( 'Success Message', 'better-payment' ),
1141 'conditions' => [
1142 'relation' => 'or',
1143 'terms' => [
1144 [
1145 'name' => 'better_payment_form_stripe_enable',
1146 'value' => 'yes',
1147 ],
1148 [
1149 'name' => 'better_payment_form_paypal_enable',
1150 'value' => 'yes',
1151 ],
1152 ],
1153 ]
1154 ]
1155 );
1156
1157 $this->add_control(
1158 'better_payment_form_success_message_icon',
1159 [
1160 'label' => esc_html__( 'Icon', 'better-payment' ),
1161 'type' => Controls_Manager::ICONS,
1162
1163 ]
1164 );
1165
1166 $this->add_control(
1167 'better_payment_form_success_message_heading',
1168 [
1169 'label' => __( 'Heading Message Text', 'better-payment' ),
1170 'type' => Controls_Manager::TEXT,
1171 'default' => __( 'Payment Successful', 'better-payment' ),
1172 'dynamic' => [
1173 'active' => true,
1174 ],
1175 'label_block' => true,
1176 'ai' => [
1177 'active' => false,
1178 ],
1179 ]
1180 );
1181
1182 $this->add_control(
1183 'better_payment_form_success_message_transaction',
1184 [
1185 'label' => __( 'Transaction Text', 'better-payment' ),
1186 'type' => Controls_Manager::TEXT,
1187 'default' => __( 'Transaction Number', 'better-payment' ),
1188 'dynamic' => [
1189 'active' => true,
1190 ],
1191 'label_block' => true,
1192 'ai' => [
1193 'active' => false,
1194 ],
1195 ]
1196 );
1197
1198 $this->add_control(
1199 'better_payment_form_success_message_thanks',
1200 [
1201 'label' => __( 'Thanks Text', 'better-payment' ),
1202 'type' => Controls_Manager::TEXT,
1203 'default' => __( 'Thank you for your payment', 'better-payment' ),
1204 'dynamic' => [
1205 'active' => true,
1206 ],
1207 'label_block' => true,
1208 'ai' => [
1209 'active' => false,
1210 ],
1211 ]
1212 );
1213
1214 $this->add_control( 'better_payment_form_success_page_url', [
1215 'type' => Controls_Manager::URL,
1216 'label' => __( 'Custom Redirect URL', 'better-payment' ),
1217 'show_external' => false,
1218 'placeholder' => __( 'eg. https://your-link.com/custom-page/', 'better-payment' ),
1219 'description' => __( 'Please note that only your current domain is allowed here to keep your site secure.', 'better-payment' ),
1220 ] );
1221
1222 $this->end_controls_section();
1223 }
1224
1225 public function error_message_setting() {
1226 $this->start_controls_section(
1227 'better_payment_form_error_message_settings',
1228 [
1229 'label' => esc_html__( 'Error Message', 'better-payment' ),
1230 'conditions' => [
1231 'relation' => 'or',
1232 'terms' => [
1233 [
1234 'name' => 'better_payment_form_stripe_enable',
1235 'value' => 'yes',
1236 ],
1237 [
1238 'name' => 'better_payment_form_paypal_enable',
1239 'value' => 'yes',
1240 ],
1241 ],
1242 ]
1243 ]
1244 );
1245
1246 $this->add_control(
1247 'better_payment_form_error_message_icon',
1248 [
1249 'label' => esc_html__( 'Icon', 'better-payment' ),
1250 'type' => Controls_Manager::ICONS,
1251
1252 ]
1253 );
1254
1255 $this->add_control(
1256 'better_payment_form_error_message_heading',
1257 [
1258 'label' => __( 'Heading Message Text', 'better-payment' ),
1259 'type' => Controls_Manager::TEXT,
1260 'default' => __( 'Payment Failed', 'better-payment' ),
1261 'dynamic' => [
1262 'active' => true,
1263 ],
1264 'label_block' => true,
1265 'ai' => [
1266 'active' => false,
1267 ],
1268 ]
1269 );
1270
1271 $this->add_control( 'better_payment_form_error_page_url', [
1272 'type' => Controls_Manager::URL,
1273 'label' => __( 'Custom Redirect URL', 'better-payment' ),
1274 'show_external' => false,
1275 'placeholder' => __( 'eg. https://your-link.com/custom-page/', 'better-payment' ),
1276 'description' => __( 'Please note that only your current domain is allowed here to keep your site secure.', 'better-payment' ),
1277 ] );
1278
1279 $this->end_controls_section();
1280 }
1281
1282 public function form_style() {
1283 $this->form_sidebar_style();
1284 $this->form_sidebar_text_style();
1285 $this->form_container_style();
1286 $this->form_fields_style();
1287 $this->form_fields_amount_style();
1288 $this->form_button_style();
1289
1290 }
1291
1292 public function form_sidebar_style() {
1293 $this->start_controls_section(
1294 'better_payment_form_sidebar_style',
1295 [
1296 'label' => esc_html__( 'Form Sidebar Style', 'better-payment' ),
1297 'tab' => Controls_Manager::TAB_STYLE,
1298 ]
1299 );
1300
1301 $this->add_group_control(
1302 Group_Control_Background::get_type(),
1303 [
1304 'name' => 'better_payment_form_sidebar_background',
1305 'types' => [ 'classic', 'gradient' ],
1306 'selector' => '{{WRAPPER}} .better-payment .dynamic-amount-section',
1307 ]
1308 );
1309
1310 $this->add_responsive_control(
1311 'better_payment_form_sidebar_margin',
1312 [
1313 'label' => esc_html__( 'Margin', 'better-payment' ),
1314 'type' => Controls_Manager::DIMENSIONS,
1315 'size_units' => [ 'px', 'em', '%' ],
1316 'selectors' => [
1317 '{{WRAPPER}} .better-payment .dynamic-amount-section' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1318 ],
1319 'separator' => 'before',
1320 ]
1321 );
1322
1323 $this->add_responsive_control(
1324 'better_payment_form_sidebar_padding',
1325 [
1326 'label' => esc_html__( 'Padding', 'better-payment' ),
1327 'type' => Controls_Manager::DIMENSIONS,
1328 'size_units' => [ 'px', 'em', '%' ],
1329 'selectors' => [
1330 '{{WRAPPER}} .better-payment .dynamic-amount-section-inner.p-6' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1331 ],
1332 ]
1333 );
1334
1335 $this->add_responsive_control(
1336 'better_payment_form_sidebar_border_radius',
1337 [
1338 'label' => esc_html__( 'Border Radius', 'better-payment' ),
1339 'type' => Controls_Manager::DIMENSIONS,
1340 'separator' => 'before',
1341 'size_units' => [ 'px' ],
1342 'selectors' => [
1343 '{{WRAPPER}} .better-payment .dynamic-amount-section' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1344 ],
1345 ]
1346 );
1347
1348 $this->add_group_control(
1349 Group_Control_Border::get_type(),
1350 [
1351 'name' => 'better_payment_form_sidebar_border',
1352 'selector' => '{{WRAPPER}} .better-payment .dynamic-amount-section',
1353 ]
1354 );
1355
1356 $this->add_group_control(
1357 Group_Control_Box_Shadow::get_type(),
1358 [
1359 'name' => 'better_payment_form_sidebar_box_shadow',
1360 'selector' => '{{WRAPPER}} .better-payment .dynamic-amount-section',
1361 ]
1362 );
1363
1364 $this->end_controls_section();
1365 }
1366
1367 public function form_sidebar_text_style() {
1368 $this->start_controls_section(
1369 'better_payment_form_sidebar_text_style',
1370 [
1371 'label' => esc_html__( 'Sidebar Text Style', 'better-payment' ),
1372 'tab' => Controls_Manager::TAB_STYLE,
1373 ]
1374 );
1375
1376 $this->add_control(
1377 'better_payment_form_sidebar_text_title_style',
1378 [
1379 'label' => __( 'Title Text', 'better-payment' ),
1380 'type' => Controls_Manager::HEADING,
1381 ]
1382 );
1383
1384 $this->add_control(
1385 'better_payment_form_sidebar_text_title_color',
1386 [
1387 'label' => __( 'Color', 'better-payment' ),
1388 'type' => Controls_Manager::COLOR,
1389 'default' => '',
1390 'selectors' => [
1391 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-title' => 'color: {{VALUE}}',
1392 ],
1393 ]
1394 );
1395
1396 $this->add_group_control(
1397 Group_Control_Typography::get_type(),
1398 [
1399 'name' => 'better_payment_form_sidebar_text_title_typography',
1400 'label' => __( 'Typography', 'better-payment' ),
1401 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
1402 'selector' => '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-title',
1403 'separator' => 'after',
1404 ]
1405 );
1406
1407 $this->add_responsive_control(
1408 'better_payment_form_sidebar_text_title_margin',
1409 [
1410 'label' => esc_html__( 'Margin', 'better-payment' ),
1411 'type' => Controls_Manager::DIMENSIONS,
1412 'size_units' => [ 'px', 'em', '%' ],
1413 'selectors' => [
1414 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1415 ],
1416 ]
1417 );
1418
1419 $this->add_responsive_control(
1420 'better_payment_form_sidebar_text_title_padding',
1421 [
1422 'label' => esc_html__( 'Padding', 'better-payment' ),
1423 'type' => Controls_Manager::DIMENSIONS,
1424 'size_units' => [ 'px', 'em', '%' ],
1425 'selectors' => [
1426 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1427 ],
1428 ]
1429 );
1430
1431 $this->add_control(
1432 'better_payment_form_sidebar_text_sub_title_style',
1433 [
1434 'label' => __( 'Sub-Title Text', 'better-payment' ),
1435 'type' => Controls_Manager::HEADING,
1436 'separator' => 'before',
1437 ],
1438 );
1439
1440 $this->add_control(
1441 'better_payment_form_sidebar_text_sub_title_color',
1442 [
1443 'label' => __( 'Color', 'better-payment' ),
1444 'type' => Controls_Manager::COLOR,
1445 'default' => '',
1446 'selectors' => [
1447 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-sub-title' => 'color: {{VALUE}}',
1448 ],
1449 ]
1450 );
1451
1452 $this->add_group_control(
1453 Group_Control_Typography::get_type(),
1454 [
1455 'name' => 'better_payment_form_sidebar_text_sub_title_typography',
1456 'label' => __( 'Typography', 'better-payment' ),
1457 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
1458 'selector' => '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-sub-title',
1459 ]
1460 );
1461
1462 $this->add_responsive_control(
1463 'better_payment_form_sidebar_text_sub_title_margin',
1464 [
1465 'label' => esc_html__( 'Margin', 'better-payment' ),
1466 'type' => Controls_Manager::DIMENSIONS,
1467 'size_units' => [ 'px', 'em', '%' ],
1468 'selectors' => [
1469 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-sub-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1470 ],
1471 ]
1472 );
1473
1474 $this->add_responsive_control(
1475 'better_payment_form_sidebar_text_sub_title_padding',
1476 [
1477 'label' => esc_html__( 'Padding', 'better-payment' ),
1478 'type' => Controls_Manager::DIMENSIONS,
1479 'size_units' => [ 'px', 'em', '%' ],
1480 'selectors' => [
1481 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-sub-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1482 ],
1483 ]
1484 );
1485
1486 $this->add_control(
1487 'better_payment_form_sidebar_text_amount_style',
1488 [
1489 'label' => __( 'Amount Text', 'better-payment' ),
1490 'type' => Controls_Manager::HEADING,
1491 'separator' => 'before',
1492 ],
1493 );
1494
1495 $this->add_control(
1496 'better_payment_form_sidebar_text_amount_title_color',
1497 [
1498 'label' => __( 'Color', 'better-payment' ),
1499 'type' => Controls_Manager::COLOR,
1500 'default' => '',
1501 'selectors' => [
1502 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount' => 'color: {{VALUE}}',
1503 ],
1504 ]
1505 );
1506
1507 $this->add_group_control(
1508 Group_Control_Typography::get_type(),
1509 [
1510 'name' => 'better_payment_form_sidebar_text_amount_typography',
1511 'label' => __( 'Typography', 'better-payment' ),
1512 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
1513 'selector' => '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount',
1514 ]
1515 );
1516
1517 $this->add_responsive_control(
1518 'better_payment_form_sidebar_text_amount_margin',
1519 [
1520 'label' => esc_html__( 'Margin', 'better-payment' ),
1521 'type' => Controls_Manager::DIMENSIONS,
1522 'size_units' => [ 'px', 'em', '%' ],
1523 'selectors' => [
1524 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1525 ],
1526 ]
1527 );
1528
1529 $this->add_responsive_control(
1530 'better_payment_form_sidebar_text_amount_padding',
1531 [
1532 'label' => esc_html__( 'Padding', 'better-payment' ),
1533 'type' => Controls_Manager::DIMENSIONS,
1534 'size_units' => [ 'px', 'em', '%' ],
1535 'selectors' => [
1536 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1537 ],
1538 ]
1539 );
1540
1541 $this->add_control(
1542 'better_payment_form_sidebar_text_amount_summary_style',
1543 [
1544 'label' => __( 'Amount Summary', 'better-payment' ),
1545 'type' => Controls_Manager::HEADING,
1546 'separator' => 'before',
1547 ],
1548 );
1549
1550 $this->add_control(
1551 'better_payment_form_sidebar_text_amount_summary_color',
1552 [
1553 'label' => __( 'Color', 'better-payment' ),
1554 'type' => Controls_Manager::COLOR,
1555 'default' => '',
1556 'selectors' => [
1557 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount-summary' => 'color: {{VALUE}}',
1558 ],
1559 ]
1560 );
1561
1562 $this->add_group_control(
1563 Group_Control_Typography::get_type(),
1564 [
1565 'name' => 'better_payment_form_sidebar_text_amount_summary_typography',
1566 'label' => __( 'Typography', 'better-payment' ),
1567 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
1568 'selector' => '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount-summary',
1569 ]
1570 );
1571
1572 $this->add_responsive_control(
1573 'better_payment_form_sidebar_text_amount_summary_margin',
1574 [
1575 'label' => esc_html__( 'Margin', 'better-payment' ),
1576 'type' => Controls_Manager::DIMENSIONS,
1577 'size_units' => [ 'px', 'em', '%' ],
1578 'selectors' => [
1579 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount-summary' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1580 ],
1581 ]
1582 );
1583
1584 $this->add_responsive_control(
1585 'better_payment_form_sidebar_text_amount_summary_padding',
1586 [
1587 'label' => esc_html__( 'Padding', 'better-payment' ),
1588 'type' => Controls_Manager::DIMENSIONS,
1589 'size_units' => [ 'px', 'em', '%' ],
1590 'selectors' => [
1591 '{{WRAPPER}} .dynamic-amount-section-inner .bp-dynamic-amount-section-amount-summary' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1592 ],
1593 ]
1594 );
1595
1596 $this->add_control(
1597 'better_payment_form_sidebar_text_icon_style',
1598 [
1599 'label' => __( 'Icon', 'better-payment' ),
1600 'type' => Controls_Manager::HEADING,
1601 'separator' => 'before',
1602 ],
1603 );
1604
1605 $this->add_control(
1606 'better_payment_form_sidebar_text_icon_color',
1607 [
1608 'label' => __( 'Color', 'better-payment' ),
1609 'type' => Controls_Manager::COLOR,
1610 'default' => '',
1611 'selectors' => [
1612 '{{WRAPPER}} .bp-dynamic-amount-section-icon:before' => 'color: {{VALUE}}',
1613 ],
1614 'condition' => [
1615 'better_payment_form_layout!' => 'layout-1',
1616 ],
1617 ]
1618 );
1619
1620 $this->add_responsive_control(
1621 'better_payment_form_sidebar_text_icon_font_size',
1622 [
1623 'label' => esc_html__( 'Font Size', 'better-payment' ),
1624 'type' => Controls_Manager::SLIDER,
1625 'size_units' => [ 'px', 'em', '%' ],
1626 'range' => [
1627 'px' => [
1628 'min' => 10,
1629 'max' => 100,
1630 ],
1631 'em' => [
1632 'min' => 1,
1633 'max' => 50,
1634 ],
1635 ],
1636 'selectors' => [
1637 '{{WRAPPER}} .bp-dynamic-amount-section-icon:before' => 'font-size: {{SIZE}}{{UNIT}};',
1638 ],
1639 'condition' => [
1640 'better_payment_form_layout!' => 'layout-1',
1641 ],
1642 ]
1643 );
1644
1645 $this->add_responsive_control(
1646 'better_payment_form_sidebar_text_icon_margin',
1647 [
1648 'label' => esc_html__( 'Margin', 'better-payment' ),
1649 'type' => Controls_Manager::DIMENSIONS,
1650 'size_units' => [ 'px', 'em', '%' ],
1651 'selectors' => [
1652 '{{WRAPPER}} .bp-dynamic-amount-section-icon-wrap' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1653 ],
1654 'condition' => [
1655 'better_payment_form_layout!' => 'layout-1',
1656 ],
1657 ]
1658 );
1659
1660 $this->add_responsive_control(
1661 'better_payment_form_sidebar_text_icon_padding',
1662 [
1663 'label' => esc_html__( 'Padding', 'better-payment' ),
1664 'type' => Controls_Manager::DIMENSIONS,
1665 'size_units' => [ 'px', 'em', '%' ],
1666 'selectors' => [
1667 '{{WRAPPER}} .bp-dynamic-amount-section-icon-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1668 ],
1669 'condition' => [
1670 'better_payment_form_layout!' => 'layout-1',
1671 ],
1672 ]
1673 );
1674
1675 $this->end_controls_section();
1676 }
1677
1678 public function form_container_style() {
1679 $this->start_controls_section(
1680 'better_payment_form_container_style',
1681 [
1682 'label' => esc_html__( 'Form Container Style', 'better-payment' ),
1683 'tab' => Controls_Manager::TAB_STYLE,
1684 ]
1685 );
1686
1687 $this->add_group_control(
1688 Group_Control_Background::get_type(),
1689 [
1690 'name' => 'better_payment_form_container_background',
1691 'types' => [ 'classic', 'gradient' ],
1692 'selector' => '{{WRAPPER}} .better-payment .form-content-section',
1693 ]
1694 );
1695
1696 $this->add_responsive_control(
1697 'better_payment_form_container_margin',
1698 [
1699 'label' => esc_html__( 'Margin', 'better-payment' ),
1700 'type' => Controls_Manager::DIMENSIONS,
1701 'size_units' => [ 'px', 'em', '%' ],
1702 'selectors' => [
1703 '{{WRAPPER}} .better-payment .form-content-section' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1704 ],
1705 ]
1706 );
1707
1708 $this->add_responsive_control(
1709 'better_payment_form_container_padding',
1710 [
1711 'label' => esc_html__( 'Padding', 'better-payment' ),
1712 'type' => Controls_Manager::DIMENSIONS,
1713 'size_units' => [ 'px', 'em', '%' ],
1714 'selectors' => [
1715 '{{WRAPPER}} .better-payment .form-content-section-inner.p-6' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1716 ],
1717 ]
1718 );
1719
1720 $this->add_control(
1721 'better_payment_form_container_border_radius',
1722 [
1723 'label' => esc_html__( 'Border Radius', 'better-payment' ),
1724 'type' => Controls_Manager::DIMENSIONS,
1725 'separator' => 'before',
1726 'size_units' => [ 'px' ],
1727 'selectors' => [
1728 '{{WRAPPER}} .better-payment .form-content-section' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1729 ],
1730 ]
1731 );
1732
1733 $this->add_group_control(
1734 Group_Control_Border::get_type(),
1735 [
1736 'name' => 'better_payment_form_container_border',
1737 'selector' => '{{WRAPPER}} .better-payment .form-content-section',
1738 ]
1739 );
1740
1741 $this->add_group_control(
1742 Group_Control_Box_Shadow::get_type(),
1743 [
1744 'name' => 'better_payment_form_container_box_shadow',
1745 'selector' => '{{WRAPPER}} .better-payment .form-content-section',
1746 ]
1747 );
1748
1749 $this->end_controls_section();
1750 }
1751
1752 public function form_fields_style() {
1753 $this->start_controls_section(
1754 'better_payment_form_fields_style',
1755 [
1756 'label' => esc_html__( 'Form Fields Style', 'better-payment' ),
1757 'tab' => Controls_Manager::TAB_STYLE,
1758 ]
1759 );
1760
1761 $this->add_control(
1762 'better_payment_form_fields_input_bg',
1763 [
1764 'label' => __( 'Background Color', 'better-payment' ),
1765 'type' => Controls_Manager::COLOR,
1766 'default' => '',
1767 'selectors' => [
1768 '{{WRAPPER}} .better-payment .form-content-section input' => 'background-color: {{VALUE}}',
1769 ],
1770 ]
1771 );
1772
1773 $this->add_control(
1774 'better_payment_form_fields_input_text_color',
1775 [
1776 'label' => __( 'Text Color', 'better-payment' ),
1777 'type' => Controls_Manager::COLOR,
1778 'default' => '',
1779 'selectors' => [
1780 '{{WRAPPER}} .better-payment .form-content-section input' => 'color: {{VALUE}}',
1781 '{{WRAPPER}} .better-payment .form-content-section .payment-method-checkbox' => 'color: {{VALUE}}',
1782 ],
1783 ]
1784 );
1785
1786 $this->add_control(
1787 'better_payment_form_fields_input_placeholder_color',
1788 [
1789 'label' => __( 'Placeholder Color', 'better-payment' ),
1790 'type' => Controls_Manager::COLOR,
1791 'default' => '',
1792 'selectors' => [
1793 '{{WRAPPER}} .better-payment .form-content-section input::placeholder' => 'color: {{VALUE}}',
1794 ],
1795 ]
1796 );
1797
1798 $this->add_responsive_control(
1799 'better_payment_form_fields_input_spacing',
1800 [
1801 'label' => __( 'Spacing', 'better-payment' ),
1802 'type' => Controls_Manager::SLIDER,
1803 'default' => [
1804 'size' => '0',
1805 'unit' => 'px',
1806 ],
1807 'range' => [
1808 'px' => [
1809 'min' => 0,
1810 'max' => 100,
1811 'step' => 1,
1812 ],
1813 ],
1814 'size_units' => [ 'px', 'em', '%' ],
1815 'selectors' => [
1816 '{{WRAPPER}} .better-payment .form-content-section input' => 'margin-bottom: {{SIZE}}{{UNIT}}',
1817 ],
1818 ]
1819 );
1820
1821 $this->add_responsive_control(
1822 'better_payment_form_fields_input_padding',
1823 [
1824 'label' => __( 'Padding', 'better-payment' ),
1825 'type' => Controls_Manager::DIMENSIONS,
1826 'size_units' => [ 'px', 'em', '%' ],
1827 'selectors' => [
1828 '{{WRAPPER}} .better-payment .form-content-section input' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1829 ],
1830 ]
1831 );
1832
1833 $this->add_responsive_control(
1834 'better_payment_form_fields_input_text_indent',
1835 [
1836 'label' => __( 'Text Indent', 'better-payment' ),
1837 'type' => Controls_Manager::SLIDER,
1838 'range' => [
1839 'px' => [
1840 'min' => 0,
1841 'max' => 60,
1842 'step' => 1,
1843 ],
1844 '%' => [
1845 'min' => 0,
1846 'max' => 30,
1847 'step' => 1,
1848 ],
1849 ],
1850 'size_units' => [ 'px', 'em', '%' ],
1851 'selectors' => [
1852 '{{WRAPPER}} .form-content-section input' => 'text-indent: {{SIZE}}{{UNIT}}',
1853 ],
1854 ]
1855 );
1856
1857 $this->add_responsive_control(
1858 'better_payment_form_fields_input_width',
1859 [
1860 'label' => __( 'Input Width', 'better-payment' ),
1861 'type' => Controls_Manager::SLIDER,
1862 'range' => [
1863 'px' => [
1864 'min' => 0,
1865 'max' => 1200,
1866 'step' => 1,
1867 ],
1868 ],
1869 'size_units' => [ 'px', 'em', '%' ],
1870 'description' => __( 'Set width for all input fields. Not applicable if the field is set to display inline (<b>Content => Form Settings => Form Fields (Repeater) => Display Inline?</b>)', 'better-payment' ),
1871 'selectors' => [
1872 '{{WRAPPER}} .better-payment .form-content-section input[type="text"]' => 'width: {{SIZE}}{{UNIT}}',
1873 '{{WRAPPER}} .better-payment .form-content-section input[type="email"]' => 'width: {{SIZE}}{{UNIT}}',
1874 '{{WRAPPER}} .better-payment .form-content-section input[type="number"]' => 'width: {{SIZE}}{{UNIT}}',
1875 ],
1876 ]
1877 );
1878
1879 $this->add_responsive_control(
1880 'better_payment_form_fields_input_height',
1881 [
1882 'label' => __( 'Input Height', 'better-payment' ),
1883 'type' => Controls_Manager::SLIDER,
1884 'range' => [
1885 'px' => [
1886 'min' => 0,
1887 'max' => 1200,
1888 'step' => 1,
1889 ],
1890 ],
1891 'size_units' => [ 'px', 'em', '%' ],
1892 'selectors' => [
1893 '{{WRAPPER}} .better-payment .form-content-section input[type="text"]' => 'height: {{SIZE}}{{UNIT}}',
1894 '{{WRAPPER}} .better-payment .form-content-section input[type="email"]' => 'height: {{SIZE}}{{UNIT}}',
1895 '{{WRAPPER}} .better-payment .form-content-section input[type="number"]' => 'height: {{SIZE}}{{UNIT}}',
1896 ],
1897 ]
1898 );
1899
1900 $this->add_group_control(
1901 Group_Control_Border::get_type(),
1902 [
1903 'name' => 'better_payment_form_fields_input_border',
1904 'label' => __( 'Border', 'better-payment' ),
1905 'placeholder' => '1px',
1906 'default' => '1px',
1907 'selector' => '{{WRAPPER}} .better-payment .form-content-section input',
1908 ]
1909 );
1910
1911 $this->add_control(
1912 'better_payment_form_fields_input_radius',
1913 [
1914 'label' => __( 'Border Radius', 'better-payment' ),
1915 'type' => Controls_Manager::DIMENSIONS,
1916 'size_units' => [ 'px', 'em', '%' ],
1917 'selectors' => [
1918 '{{WRAPPER}} .better-payment .form-content-section input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1919 ],
1920 'separator' => 'after',
1921 ]
1922 );
1923
1924 $this->add_group_control(
1925 Group_Control_Typography::get_type(),
1926 [
1927 'name' => 'better_payment_form_fields_input_typography',
1928 'label' => __( 'Typography', 'better-payment' ),
1929 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
1930 'selector' => '{{WRAPPER}} .better-payment .form-content-section input',
1931 ]
1932 );
1933
1934 $this->add_group_control(
1935 Group_Control_Box_Shadow::get_type(),
1936 [
1937 'name' => 'better_payment_form_fields_input_box_shadow',
1938 'selector' => '{{WRAPPER}} .better-payment .form-content-section input',
1939 ]
1940 );
1941
1942 $this->end_controls_section();
1943 }
1944
1945 public function form_fields_amount_style() {
1946
1947 $this->start_controls_section(
1948 'better_payment_form_fields_amount_style',
1949 [
1950 'label' => __( 'Amount Fields Style', 'better-payment' ),
1951 'tab' => Controls_Manager::TAB_STYLE,
1952 ]
1953 );
1954
1955 $this->add_responsive_control(
1956 'better_payment_form_fields_amount_width',
1957 [
1958 'label' => __( 'Input Width', 'better-payment' ),
1959 'type' => Controls_Manager::SLIDER,
1960 'range' => [
1961 'px' => [
1962 'min' => 0,
1963 'max' => 1200,
1964 'step' => 1,
1965 ],
1966 ],
1967 'size_units' => [ 'px', 'em', '%' ],
1968 'selectors' => [
1969 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'width: {{SIZE}}{{UNIT}}',
1970 ],
1971 ]
1972 );
1973
1974 $this->add_responsive_control(
1975 'better_payment_form_fields_amount_height',
1976 [
1977 'label' => __( 'Input Height', 'better-payment' ),
1978 'type' => Controls_Manager::SLIDER,
1979 'range' => [
1980 'px' => [
1981 'min' => 0,
1982 'max' => 1200,
1983 'step' => 1,
1984 ],
1985 ],
1986 'size_units' => [ 'px', 'em', '%' ],
1987 'selectors' => [
1988 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'height: {{SIZE}}{{UNIT}}',
1989 ],
1990 ]
1991 );
1992
1993 $this->add_responsive_control(
1994 'better_payment_form_fields_amount_spacing',
1995 [
1996 'label' => __( 'Spacing', 'better-payment' ),
1997 'type' => Controls_Manager::SLIDER,
1998 'default' => [
1999 'size' => '0',
2000 'unit' => 'px',
2001 ],
2002 'range' => [
2003 'px' => [
2004 'min' => 0,
2005 'max' => 100,
2006 'step' => 1,
2007 ],
2008 ],
2009 'size_units' => [ 'px', 'em', '%' ],
2010 'selectors' => [
2011 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'margin-bottom: {{SIZE}}{{UNIT}}',
2012 ],
2013 ]
2014 );
2015
2016 $this->start_controls_tabs( 'better_payment_form_amount_tabs_button_style' );
2017
2018 $this->start_controls_tab(
2019 'better_payment_form_fields_amount_normal',
2020 [
2021 'label' => __( 'Normal', 'better-payment' ),
2022 ]
2023 );
2024
2025 $this->add_control(
2026 'better_payment_form_fields_amount_normal_bg',
2027 [
2028 'label' => __( 'Background Color', 'better-payment' ),
2029 'type' => Controls_Manager::COLOR,
2030 'default' => '',
2031 'selectors' => [
2032 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'background-color: {{VALUE}}',
2033 ],
2034 ]
2035 );
2036
2037 $this->add_control(
2038 'better_payment_form_fields_amount_normal_text_color',
2039 [
2040 'label' => __( 'Text Color', 'better-payment' ),
2041 'type' => Controls_Manager::COLOR,
2042 'default' => '',
2043 'selectors' => [
2044 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'color: {{VALUE}}',
2045 ],
2046 ]
2047 );
2048
2049 $this->end_controls_tab();
2050
2051 $this->start_controls_tab(
2052 'better_payment_form_fields_amount_selected',
2053 [
2054 'label' => __( 'Selected', 'better-payment' ),
2055 ]
2056 );
2057
2058 $this->add_control(
2059 'better_payment_form_fields_amount_selected_bg',
2060 [
2061 'label' => __( 'Background Color', 'better-payment' ),
2062 'type' => Controls_Manager::COLOR,
2063 'default' => '',
2064 'selectors' => [
2065 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'background-color: {{VALUE}}',
2066 ],
2067 ]
2068 );
2069
2070 $this->add_control(
2071 'better_payment_form_fields_amount_selected_text_color',
2072 [
2073 'label' => __( 'Text Color', 'better-payment' ),
2074 'type' => Controls_Manager::COLOR,
2075 'default' => '',
2076 'selectors' => [
2077 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'color: {{VALUE}}',
2078 ]
2079 ]
2080 );
2081
2082 $this->end_controls_tab();
2083
2084 $this->end_controls_tabs();
2085
2086 $this->add_group_control(
2087 Group_Control_Border::get_type(),
2088 [
2089 'name' => 'better_payment_form_fields_amount_border',
2090 'label' => __( 'Border', 'better-payment' ),
2091 'placeholder' => '1px',
2092 'default' => '1px',
2093 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
2094 'separator' => 'before',
2095 ]
2096 );
2097
2098 $this->add_control(
2099 'better_payment_form_fields_amount_border_radius',
2100 [
2101 'label' => __( 'Border Radius', 'better-payment' ),
2102 'type' => Controls_Manager::DIMENSIONS,
2103 'size_units' => [ 'px', 'em', '%' ],
2104 'selectors' => [
2105 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2106 ],
2107 ]
2108 );
2109
2110 $this->add_group_control(
2111 Group_Control_Typography::get_type(),
2112 [
2113 'name' => 'better_payment_form_fields_amount_typography',
2114 'label' => __( 'Typography', 'better-payment' ),
2115 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
2116 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
2117 'separator' => 'before',
2118 ]
2119 );
2120
2121 $this->add_group_control(
2122 Group_Control_Box_Shadow::get_type(),
2123 [
2124 'name' => 'better_payment_form_fields_amount_box_shadow',
2125 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
2126 ]
2127 );
2128
2129 $this->end_controls_section();
2130 }
2131
2132 public function form_button_style() {
2133 $this->start_controls_section(
2134 'better_payment_form_button_style',
2135 [
2136 'label' => __( 'Form Button Style', 'better-payment' ),
2137 'tab' => Controls_Manager::TAB_STYLE,
2138 ]
2139 );
2140
2141 $this->add_responsive_control(
2142 'better_payment_form_button_width',
2143 [
2144 'label' => __( 'Width', 'better-payment' ),
2145 'type' => Controls_Manager::SLIDER,
2146 'range' => [
2147 'px' => [
2148 'min' => 0,
2149 'max' => 700,
2150 'step' => 1,
2151 ],
2152 ],
2153 'size_units' => [ 'px', 'em', '%' ],
2154 'selectors' => [
2155 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'flex: none;width: {{SIZE}}{{UNIT}}',
2156 ],
2157 ]
2158 );
2159
2160 $this->start_controls_tabs( 'better_payment_form_button_tabs_style' );
2161
2162 $this->start_controls_tab(
2163 'better_payment_form_button_normal',
2164 [
2165 'label' => __( 'Normal', 'better-payment' ),
2166 ]
2167 );
2168
2169 $this->add_control(
2170 'better_payment_form_button_normal_bg',
2171 [
2172 'label' => __( 'Background Color', 'better-payment' ),
2173 'type' => Controls_Manager::COLOR,
2174 'default' => '',
2175 'selectors' => [
2176 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'background-color: {{VALUE}} !important',
2177 ],
2178 ]
2179 );
2180
2181 $this->add_control(
2182 'better_payment_form_button_normal_text_color',
2183 [
2184 'label' => __( 'Text Color', 'better-payment' ),
2185 'type' => Controls_Manager::COLOR,
2186 'default' => '',
2187 'selectors' => [
2188 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'color: {{VALUE}} !important',
2189 ],
2190 ]
2191 );
2192
2193 $this->add_group_control(
2194 Group_Control_Border::get_type(),
2195 [
2196 'name' => 'better_payment_form_button_normal_border',
2197 'label' => __( 'Border', 'better-payment' ),
2198 'default' => '1px',
2199 'selector' => '{{WRAPPER}} .better-payment .payment-form-layout .button',
2200 ]
2201 );
2202
2203 $this->add_control(
2204 'better_payment_form_button_normal_border_radius',
2205 [
2206 'label' => __( 'Border Radius', 'better-payment' ),
2207 'type' => Controls_Manager::DIMENSIONS,
2208 'size_units' => [ 'px', 'em', '%' ],
2209 'selectors' => [
2210 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2211 ],
2212 ]
2213 );
2214
2215 $this->add_responsive_control(
2216 'better_payment_form_button_normal_padding',
2217 [
2218 'label' => __( 'Padding', 'better-payment' ),
2219 'type' => Controls_Manager::DIMENSIONS,
2220 'size_units' => [ 'px', 'em', '%' ],
2221 'selectors' => [
2222 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2223 ],
2224 ]
2225 );
2226
2227 $this->add_responsive_control(
2228 'better_payment_form_button_normal_margin',
2229 [
2230 'label' => __( 'Margin Top', 'better-payment' ),
2231 'type' => Controls_Manager::SLIDER,
2232 'range' => [
2233 'px' => [
2234 'min' => 0,
2235 'max' => 100,
2236 'step' => 1,
2237 ],
2238 ],
2239 'size_units' => [ 'px', 'em', '%' ],
2240 'selectors' => [
2241 '{{WRAPPER}} .better-payment .payment-form-layout .button' => 'margin-top: {{SIZE}}{{UNIT}}',
2242 ],
2243 ]
2244 );
2245
2246 $this->add_group_control(
2247 Group_Control_Typography::get_type(),
2248 [
2249 'name' => 'better_payment_form_button_normal_typography',
2250 'label' => __( 'Typography', 'better-payment' ),
2251 'scheme' => Global_Typography::TYPOGRAPHY_ACCENT,
2252 'selector' => '{{WRAPPER}} .better-payment .payment-form-layout .button',
2253 'separator' => 'before',
2254 ]
2255 );
2256
2257 $this->add_group_control(
2258 Group_Control_Box_Shadow::get_type(),
2259 [
2260 'name' => 'better_payment_form_button_normal_box_shadow',
2261 'selector' => '{{WRAPPER}} .better-payment .payment-form-layout .button',
2262 ]
2263 );
2264
2265 $this->end_controls_tab();
2266
2267 $this->start_controls_tab(
2268 'better_payment_form_button_hover',
2269 [
2270 'label' => __( 'Hover', 'better-payment' ),
2271 ]
2272 );
2273
2274 $this->add_control(
2275 'better_payment_form_button_hover_bg',
2276 [
2277 'label' => __( 'Background Color', 'better-payment' ),
2278 'type' => Controls_Manager::COLOR,
2279 'default' => '',
2280 'selectors' => [
2281 '{{WRAPPER}} .better-payment .payment-form-layout .button:hover' => 'background-color: {{VALUE}} !important',
2282 '{{WRAPPER}} .better-payment .payment-form-layout.payment-form-layout-3 .button:hover' => 'background-color: {{VALUE}} !important',
2283 ],
2284 ]
2285 );
2286
2287 $this->add_control(
2288 'better_payment_form_button_hover_text_color',
2289 [
2290 'label' => __( 'Text Color', 'better-payment' ),
2291 'type' => Controls_Manager::COLOR,
2292 'default' => '',
2293 'selectors' => [
2294 '{{WRAPPER}} .better-payment .payment-form-layout .button:hover' => 'color: {{VALUE}} !important',
2295 '{{WRAPPER}} .better-payment .payment-form-layout.payment-form-layout-3 .button:hover' => 'color: {{VALUE}} !important',
2296 ],
2297 ]
2298 );
2299
2300 $this->add_control(
2301 'better_payment_form_button_hover_border',
2302 [
2303 'label' => __( 'Border Color', 'better-payment' ),
2304 'type' => Controls_Manager::COLOR,
2305 'default' => '',
2306 'selectors' => [
2307 '{{WRAPPER}} .better-payment .payment-form-layout .button:hover' => 'border-color: {{VALUE}}',
2308 ],
2309 ]
2310 );
2311
2312 $this->end_controls_tab();
2313
2314 $this->end_controls_tabs();
2315
2316 $this->end_controls_section();
2317 }
2318
2319 /**
2320 * Render the widget output on the frontend.
2321 *
2322 * @since 1.0.0
2323 */
2324 protected function render() {
2325
2326 $settings = $this->get_settings_for_display();
2327
2328 if ( $settings[ 'better_payment_form_paypal_enable' ] != 'yes' && $settings[ 'better_payment_form_stripe_enable' ] != 'yes' ) {
2329 return false;
2330 }
2331
2332 $payment_field = "number" ;
2333
2334 $response = Better_Payment_Handler::manage_response( $settings, $this->get_id() );
2335 if ( $response ) {
2336 return false;
2337 }
2338
2339 wp_enqueue_script( 'better-payment' );
2340
2341 $action = esc_url( admin_url( 'admin-post.php' ) );
2342 $setting_meta = json_encode( [
2343 'page_id' => get_the_ID(),
2344 'widget_id' => esc_attr( $this->get_id() ),
2345 ] );
2346
2347 $better_payment_placeholder_class = '';
2348 if ( !empty($settings[ 'better_payment_placeholder_switch' ]) && $settings[ 'better_payment_placeholder_switch' ] != 'yes' ) {
2349 $better_payment_placeholder_class = 'better-payment-hide-placeholder';
2350 }
2351
2352 $data = array(
2353 'payment_field' => $payment_field,
2354 'action' => $action,
2355 'setting_meta' => $setting_meta,
2356 'better_payment_placeholder_class' => $better_payment_placeholder_class,
2357 );
2358
2359 $widgetObj = $this;
2360 $extraDatas = $data;
2361
2362 $better_payment_form_layout = sanitize_text_field($settings[ 'better_payment_form_layout' ]);
2363 $better_payment_form_layout = in_array($better_payment_form_layout, $this->better_payment_free_layouts()) ? $better_payment_form_layout : 'layout-1';
2364
2365 $template_file = BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/elementor/layouts/' . $better_payment_form_layout . '.php';
2366 $better_payment_form_content = '';
2367
2368 if ( file_exists($template_file) ) {
2369 ob_start();
2370 include $template_file;
2371 $better_payment_form_content = ob_get_contents();
2372 ob_end_clean();
2373 }
2374
2375 $better_payment_form_content = apply_filters( 'better_payment/elementor/editor/get_layout_content', $better_payment_form_content, $settings, $this, $data );
2376
2377 echo $better_payment_form_content;
2378 }
2379
2380 /**
2381 * Render amount element
2382 *
2383 * @since 0.0.1
2384 */
2385 public function render_amount_element( $settings ) {
2386 $layout_form_currency_symbol = Better_Payment_Handler::get_currency_symbols( esc_html($settings[ 'better_payment_form_currency' ]) );
2387 $currency_alignment = ! empty ( $settings['better_payment_form_currency_alignment'] ) ? $settings['better_payment_form_currency_alignment'] : 'left';
2388 $layout_form_currency_left = 'left' === $currency_alignment ? $layout_form_currency_symbol : '';
2389 $layout_form_currency_right = 'right' === $currency_alignment ? $layout_form_currency_symbol : '' ;
2390
2391 $id = esc_attr( $this->get_id() );
2392 ?>
2393 <!-- <div class="pt-5"> -->
2394 <?php
2395 foreach ( $settings[ 'better_payment_amount' ] as $item ) {
2396 $uid = uniqid();
2397 ?>
2398 <div class="bp-form__group pt-5">
2399 <input type="radio" value="<?php echo floatval( $item[ 'better_payment_amount_val' ] ); ?>"
2400 id="bp_payment_amount-<?php echo esc_attr($uid); ?>" class="bp-form__control bp-form_pay-radio "
2401 name="primary_payment_amount_radio">
2402 <label for="bp_payment_amount-<?php echo esc_attr($uid); ?>"><?php printf( "%s%s%s", esc_html( $layout_form_currency_left ), floatval( $item[ 'better_payment_amount_val' ] ), esc_html( $layout_form_currency_right ) ); ?></label>
2403 </div>
2404 <?php
2405 }
2406 ?>
2407 <!-- </div> -->
2408 <?php
2409 }
2410
2411 public function better_payment_free_layouts(){
2412 return [
2413 'layout-1',
2414 'layout-2',
2415 'layout-3',
2416 ];
2417 }
2418
2419 }
2420