PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 0.0.4
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v0.0.4
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.4, at includes/Admin/Elementor/Better_Payment_Widget.php

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