| @@ -817,21 +817,45 @@ | ||
| 817 | 817 | |
| 818 | 818 | $stripe = ArrayHelper::get($methods, 'stripe'); |
| 819 | 819 | $stripeInlineStyles = ArrayHelper::get(Helper::getFormMeta($formId, '_ff_form_styles', []), 'stripe_inline_element_style', false); |
| 820 | 820 | if ($stripe) { |
| 821 | - return apply_filters( | |
| 822 | - 'fluentform/stripe_inline_config', | |
| 823 | - [ | |
| 824 | - 'is_inline' => ArrayHelper::get($stripe, 'settings.embedded_checkout.value') == 'yes', | |
| 825 | - 'inline_styles' => $stripeInlineStyles, | |
| 826 | - 'verifyZip' => ArrayHelper::get($methods['stripe'], 'settings.verify_zip_code.value') === 'yes', | |
| 827 | - 'disable_link' => false | |
| 828 | - ], | |
| 829 | - $formId | |
| 830 | - ); | |
| 821 | + $config = [ | |
| 822 | + 'is_inline' => ArrayHelper::get($stripe, 'settings.embedded_checkout.value') == 'yes', | |
| 823 | + 'inline_styles' => $stripeInlineStyles, | |
| 824 | + 'verifyZip' => ArrayHelper::get($methods['stripe'], 'settings.verify_zip_code.value') === 'yes', | |
| 825 | + 'disable_link' => false, | |
| 826 | + 'enable_payment_element' => static::isStripePaymentElement($stripe), | |
| 827 | + 'is_zero_decimal' => static::isZeroDecimal(static::getFormCurrency($formId)), | |
| 828 | + ]; | |
| 829 | + | |
| 830 | + // Classic and conversational forms both create the Payment Element with these options | |
| 831 | + if ($config['enable_payment_element']) { | |
| 832 | + $config['payment_element_options'] = apply_filters( | |
| 833 | + 'fluentform/stripe_payment_element_options', | |
| 834 | + [ | |
| 835 | + 'layout' => 'tabs', | |
| 836 | + 'wallets' => ['applePay' => 'auto', 'googlePay' => 'auto', 'link' => 'never'], | |
| 837 | + 'fields' => ['billingDetails' => ['address' => $config['verifyZip'] ? 'auto' : 'if_required']], | |
| 838 | + 'appearance' => [], | |
| 839 | + ], | |
| 840 | + $formId | |
| 841 | + ); | |
| 842 | + } | |
| 843 | + | |
| 844 | + return apply_filters('fluentform/stripe_inline_config', $config, $formId); | |
| 831 | 845 | } |
| 832 | 846 | |
| 833 | 847 | return []; |
| 848 | + } | |
| 849 | + | |
| 850 | + /** | |
| 851 | + * Stripe's Payment Element (card plus Apple Pay / Google Pay) replaces the Card Element on the embedded field, | |
| 852 | + * so it only applies with Embedded Checkout on. | |
| 853 | + */ | |
| 854 | + public static function isStripePaymentElement($stripeMethod) | |
| 855 | + { | |
| 856 | + return ArrayHelper::get($stripeMethod, 'settings.embedded_checkout.value') === 'yes' | |
| 857 | + && ArrayHelper::get($stripeMethod, 'settings.enable_payment_element.value') === 'yes'; | |
| 834 | 858 | } |
| 835 | 859 | |
| 836 | 860 | public static function log($data, $submission = false, $forceInsert = false) |
| 837 | 861 | { |