PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / trunk
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder vtrunk
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / Payments / PaymentMethods / Stripe / Components / StripeInline.php

StripeInline.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder trunk, at app/Modules/Payments/PaymentMethods/Stripe/Components/StripeInline.php

95 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Payments\PaymentMethods\Stripe\Components;
4
5 use FluentForm\Framework\Helpers\ArrayHelper;
6 use FluentForm\App\Modules\Payments\PaymentHelper;
7 use FluentForm\App\Services\FormBuilder\BaseFieldManager;
8 use FluentForm\App\Modules\Payments\PaymentMethods\Stripe\StripeSettings;
9
10 if (!defined('ABSPATH')) {
11 exit; // Exit if accessed directly.
12 }
13
14 class StripeInline extends BaseFieldManager
15 {
16 /**
17 * This is not a standalone editor components
18 * rather just a frontend rendering.
19 */
20 public function __construct()
21 {
22 parent::__construct(
23 'stripe_inline',
24 'Inline Stripe Payment Method',
25 ['payment methods', 'payment', 'methods', 'stripe', 'stripe inline'],
26 'payments'
27 );
28
29 add_filter('fluentform/payment_method_contents_stripe', array($this, 'maybePushPaymentInputs'), 10, 4);
30 }
31
32 public function maybePushPaymentInputs($inlineContents, $method, $data, $form)
33 {
34 if (ArrayHelper::get($method, 'settings.embedded_checkout.value') !== 'yes') {
35 return $inlineContents;
36 }
37
38 $paymentElement = PaymentHelper::isStripePaymentElement($method);
39
40 add_filter('fluentform/form_class', function ($classes, $targetForm) use ($form) {
41 if ($form->instance_index == $targetForm->instance_index) {
42 $classes .= ' ff_has_stripe_inline';
43 }
44
45 return $classes;
46 }, 10, 2);
47
48 $elementId = $data['attributes']['name'] . '_' . $form->id . '_' . $form->instance_index . '_stripe_inline';
49 $label = ArrayHelper::get($method, 'settings.option_label.value', __('Pay with Stripe', 'fluentform'));
50 $display = $method['is_default'] ? 'block' : 'none';
51
52 $markup = '<div class="stripe-inline-wrapper ff_pay_inline ff_pay_inline_stripe" style="display: ' . $display . '">';
53 $markup .= '<div class="ff-el-input--label">';
54 $markup .= '<label for="' . $elementId . '">' . $label . '</label>';
55 $markup .= '</div>';
56
57 $attributes = [
58 'name' => 'stripe_card_element',
59 // The Payment Element draws its own inputs; only the bare Card Element needs the input box
60 'class' => $paymentElement ? 'ff_stripe_card_element' : 'ff_stripe_card_element ff-el-form-control',
61 'data-wpf_payment_method' => 'stripe',
62 'id' => $elementId,
63 'data-checkout_style' => 'embedded_form',
64 'data-verify_zip' => ArrayHelper::get($method, 'settings.verify_zip.value') === 'yes'
65 ];
66
67 $markup .= '<div ' . $this->buildAttributes($attributes) . '></div>';
68 $markup .= '<div class="ff_card-errors text-danger" role="alert"></div>';
69
70 if (!StripeSettings::isLive($form->id)) {
71 $stripeTestModeMessage = __('Stripe test mode activated', 'fluentform');
72 $markup .= '<span style="margin-top: 5px;padding: 0;font-style: italic;font-size: 12px">' . $stripeTestModeMessage . '</span>';
73 }
74
75 $markup .= '</div>';
76
77 return $inlineContents . $markup;
78 }
79
80
81 /**
82 * We don't need to return anything from here
83 */
84 function getComponent()
85 {
86 }
87
88 /**
89 * We don't need to return anything from here
90 */
91 function render($element, $form)
92 {
93 }
94 }
95