%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/shortcodes/
Upload File :
Create Path :
Current File : //dom645759/wp-content/plugins/fusion-builder/shortcodes/fusion-stripe-button.php

<?php
/**
 * Add an element to fusion-builder.
 *
 * @package fusion-builder
 * @since 3.9
 */

if ( fusion_is_element_enabled( 'fusion_stripe_button' ) ) {

	if ( ! class_exists( 'FusionSC_Stripe_Button_API_Handler' ) ) {

		/**
		 * Class Stripe API Handler.
		 *
		 * @since 3.9
		 */
		class FusionSC_Stripe_Button_API_Handler {
			/**
			 * Stripe Endpoint URL.
			 *
			 * @access private
			 * @since 3.9
			 * @var string
			 */
			private static $stripe_endpoint_url = 'https://api.stripe.com/v1/';

			/**
			 * Stripe Tax Endpoint.
			 *
			 * @access private
			 * @since 3.9
			 * @var string
			 */
			private static $stripe_tax_endpoint_url = 'tax_rates';

			/**
			 * Stripe Prices Endpoint.
			 *
			 * @access private
			 * @since 3.16.2
			 * @var string
			 */
			private static $stripe_prices_endpoint_url = 'prices';

			/**
			 * Stripe Checkout Endpoint.
			 *
			 * @access private
			 * @since 3.9
			 * @var string
			 */
			private static $stripe_checkout_url_ext = 'checkout/sessions';

			/**
			 * API Get Request handler.
			 *
			 * @access public
			 * @since 3.9
			 * @param string $secret_key The secret key.
			 * @param string $endpoint The endpoint.
			 * @param array  $body The body.
			 * @return array|\WP_Error
			 */
			public function get( $secret_key, $endpoint = '', $body = [] ) {
				$headers = [ 'Authorization' => 'Bearer ' . $secret_key ];
				return wp_remote_get(
					self::$stripe_endpoint_url . $endpoint,
					[
						'headers' => $headers,
						'body'    => $body,
					]
				);
			}

			/**
			 * API Post Request handler.
			 *
			 * @access public
			 * @since 3.9
			 * @param array  $headers The headers.
			 * @param array  $body The body.
			 * @param string $endpoint The endpoint.
			 * @return array|\WP_Error
			 */
			public function post( $headers, $body, $endpoint ) {
				return wp_remote_post(
					self::$stripe_endpoint_url . $endpoint,
					[
						'headers' => $headers,
						'body'    => $body,
					]
				);
			}

			/**
			 * Get correct price based on currencies.
			 * Zero decimal currencies by stripe https://stripe.com/docs/currencies#zero-decimal
			 *
			 * @access public
			 * @since 3.9
			 * @param string $currency The currency.
			 * @param float  $product_price The product price.
			 * @return false|float
			 */
			public function set_price( $currency, $product_price ) {
				if ( self::is_zero_decimal( $currency ) ) {
					// There is no need to multiply $product_price by 100.
					return floor( $product_price );
				} else {
					return floor( $product_price * 100 );
				}
			}

			/**
			 * Whether the currency is a zero decimal one.
			 * Zero decimal currencies by stripe https://stripe.com/docs/currencies#zero-decimal
			 *
			 * @access public
			 * @since 3.16.2
			 * @param string $currency The currency.
			 * @return bool
			 */
			public static function is_zero_decimal( $currency ) {
				$zero_decimal = [ 'BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ];
				return in_array( strtoupper( (string) $currency ), $zero_decimal, true );
			}

			/**
			 * Turns a Stripe amount, in the smallest currency unit, into a readable one.
			 * Used for the Stripe product select labels.
			 *
			 * @access public
			 * @since 3.16.2
			 * @param string $currency The currency.
			 * @param int    $amount   The amount, in the smallest currency unit.
			 * @return string
			 */
			public static function format_amount( $currency, $amount ) {
				if ( self::is_zero_decimal( $currency ) ) {
					return number_format( (float) $amount, 0 );
				}
				return number_format( (float) $amount / 100, 2 );
			}

			/**
			 * Validate API KEY.
			 *
			 * @access public
			 * @since 3.9
			 * @param string $secret_key The secret key.
			 * @return array|WP_Error
			 */
			public function validate_api_key_endpoint( $secret_key ) {
				return $this->get( $secret_key, self::$stripe_tax_endpoint_url, [ 'limit' => 0 ] );
			}

			/**
			 * Call API Checkout.
			 *
			 * @access public
			 * @since 3.9
			 * @param string $secret_key The secret key.
			 * @param array  $args The arguments.
			 * @return void
			 */
			public function post_checkout_endpoint( $secret_key, $args ) {
				$headers = [ 'Authorization' => 'Bearer ' . $secret_key ];
				$body    = [
					'success_url'          => $args['success_url'],
					'cancel_url'           => $args['cancel_url'],
					'payment_method_types' => [ 'card' ],
					'mode'                 => 'payment',
				];

				$price_mode = isset( $args['price_mode'] ) ? $args['price_mode'] : 'fixed';

				if ( 'stripe' === $price_mode ) {

					// The amount lives on the Price object in the Stripe account, so nothing about it is sent from here.
					$body['line_items[0][price]']    = $args['price_id'];
					$body['line_items[0][quantity]'] = $args['product_qty'];
				} elseif ( ! empty( $args['product_name'] ) && ! empty( $args['product_price'] ) ) {
					$body['line_items[0][quantity]']                       = $args['product_qty'];
					$body['line_items[0][price_data][currency]']           = $args['currency'];
					$body['line_items[0][price_data][product_data][name]'] = $args['product_name'];
					$body['line_items[0][price_data][unit_amount]']        = $this->set_price( $args['currency'], $args['product_price'] );
				}

				if ( ! empty( $args['shipping_price'] ) ) {
					$body['shipping_options'][0]['shipping_rate_data']['type']                     = 'fixed_amount';
					$body['shipping_options'][0]['shipping_rate_data']['fixed_amount']['amount']   = $this->set_price( $args['currency'], $args['shipping_price'] );
					$body['shipping_options'][0]['shipping_rate_data']['fixed_amount']['currency'] = $args['currency'];
					$body['shipping_options'][0]['shipping_rate_data']['display_name']             = esc_html__( 'shipping fee', 'fusion-builder' );
				}

				if ( ! empty( $args['shipping_address'] ) && 'yes' === $args['shipping_address'] ) {
					$body['shipping_address_collection'] = [
						'allowed_countries' => self::get_available_shipping_address_countries(),
					];
				}

				if ( ! empty( $args['tax_rate'] ) ) {
					$tax_rate     = explode( '|', $args['tax_rate'] );
					$tax_id       = $tax_rate[0];
					$tax_behavior = isset( $tax_rate[1] ) ? $tax_rate[1] : '';

					if ( ! empty( $tax_id ) ) {
						$body['line_items[0][tax_rates][0]'] = $tax_id;

						// tax_behavior is a property of the Price object, so it can only be set on an inline one.
						if ( ! empty( $tax_behavior ) && 'stripe' !== $price_mode ) {
							$body['line_items[0][price_data][tax_behavior]'] = $tax_behavior;
						}
					}
				}

				$response = $this->post( $headers, $body, self::$stripe_checkout_url_ext );
				wp_send_json( $response );
			}

			/**
			 * Call API Tax rates.
			 *
			 * @since 3.9
			 * @param string $secret_key The secret key.
			 * @return array
			 */
			public function post_tax_rates_endpoint( $secret_key ) {
				$response = $this->get( $secret_key, self::$stripe_tax_endpoint_url, [ 'active' => 'true' ] );
				$options  = [];
				$data     = [];

				if ( ! is_wp_error( $response ) ) {
					$decoded_response = json_decode( $response['body'], true );

					if ( isset( $decoded_response['error'] ) || 0 === count( $decoded_response['data'] ) ) {
						$data = [];
					} else {
						$data = $decoded_response['data'];
					}
				}

				if ( ! empty( $data ) ) {
					foreach ( $data as $tax ) {
						$rate_type                                = $tax['inclusive'] ? 'inclusive' : 'exclusive';
						$options[ $tax['id'] . '|' . $rate_type ] = sprintf( '%s (%d%%) %s', $tax['display_name'], $tax['percentage'], $tax['description'] );
					}
				}

				return $options;
			}

			/**
			 * Call API Prices.
			 * Builds the Stripe product select, the same way the tax rate one is built.
			 *
			 * @since 3.16.2
			 * @param string $secret_key The secret key.
			 * @return array
			 */
			public function get_prices_endpoint( $secret_key ) {
				$response = $this->get(
					$secret_key,
					self::$stripe_prices_endpoint_url,
					[
						'active' => 'true',
						'limit'  => 100,
						'expand' => [ 'data.product' ],
					]
				);
				$options  = [];
				$data     = [];

				if ( ! is_wp_error( $response ) ) {
					$decoded_response = json_decode( $response['body'], true );

					if ( ! isset( $decoded_response['error'] ) && isset( $decoded_response['data'] ) && is_array( $decoded_response['data'] ) ) {
						$data = $decoded_response['data'];
					}
				}

				foreach ( $data as $price ) {
					if ( ! isset( $price['id'] ) || ! isset( $price['currency'] ) ) {
						continue;
					}

					// Tiered and metered prices carry no unit_amount, so there is nothing to display or charge.
					if ( ! isset( $price['unit_amount'] ) || null === $price['unit_amount'] ) {
						continue;
					}

					// The session is created in payment mode, which rejects recurring prices.
					if ( isset( $price['recurring'] ) && null !== $price['recurring'] ) {
						continue;
					}

					$name = $price['id'];
					if ( isset( $price['product']['name'] ) ) {
						$name = $price['product']['name'];
					} elseif ( isset( $price['nickname'] ) && '' !== $price['nickname'] ) {
						$name = $price['nickname'];
					}

					// The currency is paired onto the value so shipping can be charged in it without a second API call.
					$options[ $price['id'] . '|' . $price['currency'] ] = sprintf(
						'%1$s - %2$s %3$s',
						$name,
						self::format_amount( $price['currency'], $price['unit_amount'] ),
						strtoupper( $price['currency'] )
					);
				}

				return $options;
			}

			/**
			 * Returns a list of country codes and countries.
			 *
			 * @since 3.9
			 * @return array $countries A list of the available countries
			 */
			public static function get_countries() {
				$countries = [
					'AF' => __( 'Afghanistan', 'fusion-builder' ),
					'AX' => __( 'Ă…land Islands', 'fusion-builder' ),
					'AL' => __( 'Albania', 'fusion-builder' ),
					'DZ' => __( 'Algeria', 'fusion-builder' ),
					'AS' => __( 'American Samoa', 'fusion-builder' ),
					'AD' => __( 'Andorra', 'fusion-builder' ),
					'AO' => __( 'Angola', 'fusion-builder' ),
					'AI' => __( 'Anguilla', 'fusion-builder' ),
					'AQ' => __( 'Antarctica', 'fusion-builder' ),
					'AG' => __( 'Antigua and Barbuda', 'fusion-builder' ),
					'AR' => __( 'Argentina', 'fusion-builder' ),
					'AM' => __( 'Armenia', 'fusion-builder' ),
					'AW' => __( 'Aruba', 'fusion-builder' ),
					'AU' => __( 'Australia', 'fusion-builder' ),
					'AT' => __( 'Austria', 'fusion-builder' ),
					'AZ' => __( 'Azerbaijan', 'fusion-builder' ),
					'BS' => __( 'Bahamas', 'fusion-builder' ),
					'BH' => __( 'Bahrain', 'fusion-builder' ),
					'BD' => __( 'Bangladesh', 'fusion-builder' ),
					'BB' => __( 'Barbados', 'fusion-builder' ),
					'BY' => __( 'Belarus', 'fusion-builder' ),
					'BE' => __( 'Belgium', 'fusion-builder' ),
					'PW' => __( 'Belau', 'fusion-builder' ),
					'BZ' => __( 'Belize', 'fusion-builder' ),
					'BJ' => __( 'Benin', 'fusion-builder' ),
					'BM' => __( 'Bermuda', 'fusion-builder' ),
					'BT' => __( 'Bhutan', 'fusion-builder' ),
					'BO' => __( 'Bolivia', 'fusion-builder' ),
					'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'fusion-builder' ),
					'BA' => __( 'Bosnia and Herzegovina', 'fusion-builder' ),
					'BW' => __( 'Botswana', 'fusion-builder' ),
					'BV' => __( 'Bouvet Island', 'fusion-builder' ),
					'BR' => __( 'Brazil', 'fusion-builder' ),
					'IO' => __( 'British Indian Ocean Territory', 'fusion-builder' ),
					'BN' => __( 'Brunei', 'fusion-builder' ),
					'BG' => __( 'Bulgaria', 'fusion-builder' ),
					'BF' => __( 'Burkina Faso', 'fusion-builder' ),
					'BI' => __( 'Burundi', 'fusion-builder' ),
					'KH' => __( 'Cambodia', 'fusion-builder' ),
					'CM' => __( 'Cameroon', 'fusion-builder' ),
					'CA' => __( 'Canada', 'fusion-builder' ),
					'CV' => __( 'Cape Verde', 'fusion-builder' ),
					'KY' => __( 'Cayman Islands', 'fusion-builder' ),
					'CF' => __( 'Central African Republic', 'fusion-builder' ),
					'TD' => __( 'Chad', 'fusion-builder' ),
					'CL' => __( 'Chile', 'fusion-builder' ),
					'CN' => __( 'China', 'fusion-builder' ),
					'CX' => __( 'Christmas Island', 'fusion-builder' ),
					'CC' => __( 'Cocos (Keeling) Islands', 'fusion-builder' ),
					'CO' => __( 'Colombia', 'fusion-builder' ),
					'KM' => __( 'Comoros', 'fusion-builder' ),
					'CG' => __( 'Congo (Brazzaville)', 'fusion-builder' ),
					'CD' => __( 'Congo (Kinshasa)', 'fusion-builder' ),
					'CK' => __( 'Cook Islands', 'fusion-builder' ),
					'CR' => __( 'Costa Rica', 'fusion-builder' ),
					'HR' => __( 'Croatia', 'fusion-builder' ),
					'CU' => __( 'Cuba', 'fusion-builder' ),
					'CW' => __( 'Cura&ccedil;ao', 'fusion-builder' ),
					'CY' => __( 'Cyprus', 'fusion-builder' ),
					'CZ' => __( 'Czech Republic', 'fusion-builder' ),
					'DK' => __( 'Denmark', 'fusion-builder' ),
					'DJ' => __( 'Djibouti', 'fusion-builder' ),
					'DM' => __( 'Dominica', 'fusion-builder' ),
					'DO' => __( 'Dominican Republic', 'fusion-builder' ),
					'EC' => __( 'Ecuador', 'fusion-builder' ),
					'EG' => __( 'Egypt', 'fusion-builder' ),
					'SV' => __( 'El Salvador', 'fusion-builder' ),
					'GQ' => __( 'Equatorial Guinea', 'fusion-builder' ),
					'ER' => __( 'Eritrea', 'fusion-builder' ),
					'EE' => __( 'Estonia', 'fusion-builder' ),
					'ET' => __( 'Ethiopia', 'fusion-builder' ),
					'FK' => __( 'Falkland Islands', 'fusion-builder' ),
					'FO' => __( 'Faroe Islands', 'fusion-builder' ),
					'FJ' => __( 'Fiji', 'fusion-builder' ),
					'FI' => __( 'Finland', 'fusion-builder' ),
					'FR' => __( 'France', 'fusion-builder' ),
					'GF' => __( 'French Guiana', 'fusion-builder' ),
					'PF' => __( 'French Polynesia', 'fusion-builder' ),
					'TF' => __( 'French Southern Territories', 'fusion-builder' ),
					'GA' => __( 'Gabon', 'fusion-builder' ),
					'GM' => __( 'Gambia', 'fusion-builder' ),
					'GE' => __( 'Georgia', 'fusion-builder' ),
					'DE' => __( 'Germany', 'fusion-builder' ),
					'GH' => __( 'Ghana', 'fusion-builder' ),
					'GI' => __( 'Gibraltar', 'fusion-builder' ),
					'GR' => __( 'Greece', 'fusion-builder' ),
					'GL' => __( 'Greenland', 'fusion-builder' ),
					'GD' => __( 'Grenada', 'fusion-builder' ),
					'GP' => __( 'Guadeloupe', 'fusion-builder' ),
					'GU' => __( 'Guam', 'fusion-builder' ),
					'GT' => __( 'Guatemala', 'fusion-builder' ),
					'GG' => __( 'Guernsey', 'fusion-builder' ),
					'GN' => __( 'Guinea', 'fusion-builder' ),
					'GW' => __( 'Guinea-Bissau', 'fusion-builder' ),
					'GY' => __( 'Guyana', 'fusion-builder' ),
					'HT' => __( 'Haiti', 'fusion-builder' ),
					'HM' => __( 'Heard Island and McDonald Islands', 'fusion-builder' ),
					'HN' => __( 'Honduras', 'fusion-builder' ),
					'HK' => __( 'Hong Kong', 'fusion-builder' ),
					'HU' => __( 'Hungary', 'fusion-builder' ),
					'IS' => __( 'Iceland', 'fusion-builder' ),
					'IN' => __( 'India', 'fusion-builder' ),
					'ID' => __( 'Indonesia', 'fusion-builder' ),
					'IR' => __( 'Iran', 'fusion-builder' ),
					'IQ' => __( 'Iraq', 'fusion-builder' ),
					'IE' => __( 'Ireland', 'fusion-builder' ),
					'IM' => __( 'Isle of Man', 'fusion-builder' ),
					'IL' => __( 'Israel', 'fusion-builder' ),
					'IT' => __( 'Italy', 'fusion-builder' ),
					'CI' => __( 'Ivory Coast', 'fusion-builder' ),
					'JM' => __( 'Jamaica', 'fusion-builder' ),
					'JP' => __( 'Japan', 'fusion-builder' ),
					'JE' => __( 'Jersey', 'fusion-builder' ),
					'JO' => __( 'Jordan', 'fusion-builder' ),
					'KZ' => __( 'Kazakhstan', 'fusion-builder' ),
					'KE' => __( 'Kenya', 'fusion-builder' ),
					'KI' => __( 'Kiribati', 'fusion-builder' ),
					'KW' => __( 'Kuwait', 'fusion-builder' ),
					'KG' => __( 'Kyrgyzstan', 'fusion-builder' ),
					'LA' => __( 'Laos', 'fusion-builder' ),
					'LV' => __( 'Latvia', 'fusion-builder' ),
					'LB' => __( 'Lebanon', 'fusion-builder' ),
					'LS' => __( 'Lesotho', 'fusion-builder' ),
					'LR' => __( 'Liberia', 'fusion-builder' ),
					'LY' => __( 'Libya', 'fusion-builder' ),
					'LI' => __( 'Liechtenstein', 'fusion-builder' ),
					'LT' => __( 'Lithuania', 'fusion-builder' ),
					'LU' => __( 'Luxembourg', 'fusion-builder' ),
					'MO' => __( 'Macao', 'fusion-builder' ),
					'MK' => __( 'North Macedonia', 'fusion-builder' ),
					'MG' => __( 'Madagascar', 'fusion-builder' ),
					'MW' => __( 'Malawi', 'fusion-builder' ),
					'MY' => __( 'Malaysia', 'fusion-builder' ),
					'MV' => __( 'Maldives', 'fusion-builder' ),
					'ML' => __( 'Mali', 'fusion-builder' ),
					'MT' => __( 'Malta', 'fusion-builder' ),
					'MH' => __( 'Marshall Islands', 'fusion-builder' ),
					'MQ' => __( 'Martinique', 'fusion-builder' ),
					'MR' => __( 'Mauritania', 'fusion-builder' ),
					'MU' => __( 'Mauritius', 'fusion-builder' ),
					'YT' => __( 'Mayotte', 'fusion-builder' ),
					'MX' => __( 'Mexico', 'fusion-builder' ),
					'FM' => __( 'Micronesia', 'fusion-builder' ),
					'MD' => __( 'Moldova', 'fusion-builder' ),
					'MC' => __( 'Monaco', 'fusion-builder' ),
					'MN' => __( 'Mongolia', 'fusion-builder' ),
					'ME' => __( 'Montenegro', 'fusion-builder' ),
					'MS' => __( 'Montserrat', 'fusion-builder' ),
					'MA' => __( 'Morocco', 'fusion-builder' ),
					'MZ' => __( 'Mozambique', 'fusion-builder' ),
					'MM' => __( 'Myanmar', 'fusion-builder' ),
					'NA' => __( 'Namibia', 'fusion-builder' ),
					'NR' => __( 'Nauru', 'fusion-builder' ),
					'NP' => __( 'Nepal', 'fusion-builder' ),
					'NL' => __( 'Netherlands', 'fusion-builder' ),
					'NC' => __( 'New Caledonia', 'fusion-builder' ),
					'NZ' => __( 'New Zealand', 'fusion-builder' ),
					'NI' => __( 'Nicaragua', 'fusion-builder' ),
					'NE' => __( 'Niger', 'fusion-builder' ),
					'NG' => __( 'Nigeria', 'fusion-builder' ),
					'NU' => __( 'Niue', 'fusion-builder' ),
					'NF' => __( 'Norfolk Island', 'fusion-builder' ),
					'MP' => __( 'Northern Mariana Islands', 'fusion-builder' ),
					'KP' => __( 'North Korea', 'fusion-builder' ),
					'NO' => __( 'Norway', 'fusion-builder' ),
					'OM' => __( 'Oman', 'fusion-builder' ),
					'PK' => __( 'Pakistan', 'fusion-builder' ),
					'PS' => __( 'Palestinian Territory', 'fusion-builder' ),
					'PA' => __( 'Panama', 'fusion-builder' ),
					'PG' => __( 'Papua New Guinea', 'fusion-builder' ),
					'PY' => __( 'Paraguay', 'fusion-builder' ),
					'PE' => __( 'Peru', 'fusion-builder' ),
					'PH' => __( 'Philippines', 'fusion-builder' ),
					'PN' => __( 'Pitcairn', 'fusion-builder' ),
					'PL' => __( 'Poland', 'fusion-builder' ),
					'PT' => __( 'Portugal', 'fusion-builder' ),
					'PR' => __( 'Puerto Rico', 'fusion-builder' ),
					'QA' => __( 'Qatar', 'fusion-builder' ),
					'RE' => __( 'Reunion', 'fusion-builder' ),
					'RO' => __( 'Romania', 'fusion-builder' ),
					'RU' => __( 'Russia', 'fusion-builder' ),
					'RW' => __( 'Rwanda', 'fusion-builder' ),
					'BL' => __( 'Saint Barth&eacute;lemy', 'fusion-builder' ),
					'SH' => __( 'Saint Helena', 'fusion-builder' ),
					'KN' => __( 'Saint Kitts and Nevis', 'fusion-builder' ),
					'LC' => __( 'Saint Lucia', 'fusion-builder' ),
					'MF' => __( 'Saint Martin (French part)', 'fusion-builder' ),
					'SX' => __( 'Saint Martin (Dutch part)', 'fusion-builder' ),
					'PM' => __( 'Saint Pierre and Miquelon', 'fusion-builder' ),
					'VC' => __( 'Saint Vincent and the Grenadines', 'fusion-builder' ),
					'SM' => __( 'San Marino', 'fusion-builder' ),
					'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'fusion-builder' ),
					'SA' => __( 'Saudi Arabia', 'fusion-builder' ),
					'SN' => __( 'Senegal', 'fusion-builder' ),
					'RS' => __( 'Serbia', 'fusion-builder' ),
					'SC' => __( 'Seychelles', 'fusion-builder' ),
					'SL' => __( 'Sierra Leone', 'fusion-builder' ),
					'SG' => __( 'Singapore', 'fusion-builder' ),
					'SK' => __( 'Slovakia', 'fusion-builder' ),
					'SI' => __( 'Slovenia', 'fusion-builder' ),
					'SB' => __( 'Solomon Islands', 'fusion-builder' ),
					'SO' => __( 'Somalia', 'fusion-builder' ),
					'ZA' => __( 'South Africa', 'fusion-builder' ),
					'GS' => __( 'South Georgia/Sandwich Islands', 'fusion-builder' ),
					'KR' => __( 'South Korea', 'fusion-builder' ),
					'SS' => __( 'South Sudan', 'fusion-builder' ),
					'ES' => __( 'Spain', 'fusion-builder' ),
					'LK' => __( 'Sri Lanka', 'fusion-builder' ),
					'SD' => __( 'Sudan', 'fusion-builder' ),
					'SR' => __( 'Suriname', 'fusion-builder' ),
					'SJ' => __( 'Svalbard and Jan Mayen', 'fusion-builder' ),
					'SZ' => __( 'Eswatini', 'fusion-builder' ),
					'SE' => __( 'Sweden', 'fusion-builder' ),
					'CH' => __( 'Switzerland', 'fusion-builder' ),
					'SY' => __( 'Syria', 'fusion-builder' ),
					'TW' => __( 'Taiwan', 'fusion-builder' ),
					'TJ' => __( 'Tajikistan', 'fusion-builder' ),
					'TZ' => __( 'Tanzania', 'fusion-builder' ),
					'TH' => __( 'Thailand', 'fusion-builder' ),
					'TL' => __( 'Timor-Leste', 'fusion-builder' ),
					'TG' => __( 'Togo', 'fusion-builder' ),
					'TK' => __( 'Tokelau', 'fusion-builder' ),
					'TO' => __( 'Tonga', 'fusion-builder' ),
					'TT' => __( 'Trinidad and Tobago', 'fusion-builder' ),
					'TN' => __( 'Tunisia', 'fusion-builder' ),
					'TR' => __( 'Turkey', 'fusion-builder' ),
					'TM' => __( 'Turkmenistan', 'fusion-builder' ),
					'TC' => __( 'Turks and Caicos Islands', 'fusion-builder' ),
					'TV' => __( 'Tuvalu', 'fusion-builder' ),
					'UG' => __( 'Uganda', 'fusion-builder' ),
					'UA' => __( 'Ukraine', 'fusion-builder' ),
					'AE' => __( 'United Arab Emirates', 'fusion-builder' ),
					'GB' => __( 'United Kingdom (UK)', 'fusion-builder' ),
					'US' => __( 'United States (US)', 'fusion-builder' ),
					'UM' => __( 'United States (US) Minor Outlying Islands', 'fusion-builder' ),
					'UY' => __( 'Uruguay', 'fusion-builder' ),
					'UZ' => __( 'Uzbekistan', 'fusion-builder' ),
					'VU' => __( 'Vanuatu', 'fusion-builder' ),
					'VA' => __( 'Vatican', 'fusion-builder' ),
					'VE' => __( 'Venezuela', 'fusion-builder' ),
					'VN' => __( 'Vietnam', 'fusion-builder' ),
					'VG' => __( 'Virgin Islands (British)', 'fusion-builder' ),
					'VI' => __( 'Virgin Islands (US)', 'fusion-builder' ),
					'WF' => __( 'Wallis and Futuna', 'fusion-builder' ),
					'EH' => __( 'Western Sahara', 'fusion-builder' ),
					'WS' => __( 'Samoa', 'fusion-builder' ),
					'YE' => __( 'Yemen', 'fusion-builder' ),
					'ZM' => __( 'Zambia', 'fusion-builder' ),
					'ZW' => __( 'Zimbabwe', 'fusion-builder' ),
				];

				return apply_filters( 'fusion_stripe_countries', $countries );
			}

			/**
			 * Retrieves a list of countries that support Shipping Address collection.
			 *
			 * @since 3.9
			 * @return array List of country codes.
			 */
			public static function get_available_shipping_address_countries() {
				// Built in countries.
				$countries = self::get_countries();

				// Remove unsupported countries.
				unset( $countries['AS'] );
				unset( $countries['CX'] );
				unset( $countries['CC'] );
				unset( $countries['CU'] );
				unset( $countries['TP'] );
				unset( $countries['HM'] );
				unset( $countries['IR'] );
				unset( $countries['MH'] );
				unset( $countries['FM'] );
				unset( $countries['AN'] );
				unset( $countries['NF'] );
				unset( $countries['KP'] );
				unset( $countries['MP'] );
				unset( $countries['PW'] );
				unset( $countries['SD'] );
				unset( $countries['SY'] );
				unset( $countries['UM'] );
				unset( $countries['VI'] );

				return array_keys( $countries );
			}
		}
	}

	if ( ! class_exists( 'FusionSC_Stripe_Button' ) ) {
		/**
		 * Shortcode class.
		 *
		 * @since 3.9
		 */
		class FusionSC_Stripe_Button extends Fusion_Element { // phpcs:ignore Generic.Files.OneObjectStructurePerFile, Generic.Classes.OpeningBraceSameLine

			/**
			 * The one, true instance of this object.
			 *
			 * @static
			 * @access private
			 * @since 3.9
			 * @var object
			 */
			private static $instance;

			/**
			 * The counter.
			 *
			 * @access private
			 * @since 3.9
			 * @var int
			 */
			private $counter = 1;

			/**
			 * Secret key selected.
			 *
			 * @access protected
			 * @since 3.9
			 * @var string
			 */
			protected $secret_key;

			/**
			 * Stripe Api Handler.
			 *
			 * @access public
			 * @since 3.9
			 * @var Object
			 */
			public $api;

			/**
			 * Constructor.
			 *
			 * @access public
			 * @since 3.9
			 */
			public function __construct() {
				parent::__construct();
				add_filter( 'fusion_attr_stripe_button-shortcode', [ $this, 'attr' ] );

				// Validate API KEY.
				add_action( 'wp_ajax_awb_validate_stripe_api_key', [ $this, 'validate_api_key' ] );
				add_action( 'wp_ajax_awb_stripe_button_submit', [ $this, 'submit_form_ajax' ] );
				add_action( 'wp_ajax_nopriv_awb_stripe_button_submit', [ $this, 'submit_form_ajax' ] );

				add_shortcode( 'fusion_stripe_button', [ $this, 'render' ] );

				$this->api = new FusionSC_Stripe_Button_API_Handler();
			}

			/**
			 * Creates or returns an instance of this class.
			 *
			 * @static
			 * @access public
			 * @since 3.9
			 */
			public static function get_instance() {

				// If an instance hasn't been created and set to $instance create an instance and set it to $instance.
				if ( null === self::$instance ) {
					self::$instance = new FusionSC_Stripe_Button();
				}
				return self::$instance;
			}

			/**
			 * Gets the default values.
			 *
			 * @static
			 * @access public
			 * @since 3.9
			 * @return array
			 */
			public static function get_element_defaults() {
				$fusion_settings = awb_get_fusion_settings();
				return [
					'api_mode'                           => $fusion_settings->get( 'stripe_button_api_mode' ),
					'price_mode'                         => 'fixed',
					'shipping_address'                   => 'yes',
					'product_name'                       => esc_attr__( 'My Product', 'fusion-builder' ),
					'currency'                           => 'USD',
					'product_price'                      => '3.99',
					'min_price'                          => '1',
					'max_price'                          => '',
					'amount_label'                       => esc_attr__( 'Amount', 'fusion-builder' ),
					'test_price_id'                      => '',
					'live_price_id'                      => '',
					'product_qty'                        => '1',
					'shipping_price'                     => '',
					'test_tax_rate'                      => '',
					'live_tax_rate'                      => '',
					'success_url'                        => '',
					'cancel_url'                         => '',
					'button_el_type'                     => 'submit',
					'tab_index'                          => '',
					'hide_on_mobile'                     => fusion_builder_default_visibility( 'string' ),
					'sticky_display'                     => '',
					'class'                              => '',
					'id'                                 => '',
					'accent_color'                       => ( '' !== $fusion_settings->get( 'button_accent_color' ) ) ? strtolower( $fusion_settings->get( 'button_accent_color' ) ) : '#ffffff',
					'accent_hover_color'                 => ( '' !== $fusion_settings->get( 'button_accent_hover_color' ) ) ? strtolower( $fusion_settings->get( 'button_accent_hover_color' ) ) : '#ffffff',
					'bevel_color'                        => ( '' !== $fusion_settings->get( 'button_bevel_color' ) ) ? strtolower( $fusion_settings->get( 'button_bevel_color' ) ) : '#54770F',
					'bevel_color_hover'                  => ( '' !== $fusion_settings->get( 'button_bevel_color' ) ) ? strtolower( $fusion_settings->get( 'button_bevel_color_hover' ) ) : '#54770F',
					'border_color'                       => ( '' !== $fusion_settings->get( 'button_border_color' ) ) ? strtolower( $fusion_settings->get( 'button_border_color' ) ) : '#ffffff',
					'border_hover_color'                 => ( '' !== $fusion_settings->get( 'button_border_hover_color' ) ) ? strtolower( $fusion_settings->get( 'button_border_hover_color' ) ) : '#ffffff',
					'color'                              => 'default',
					'gradient_colors'                    => '',
					'icon'                               => '',
					'icon_divider'                       => 'no',
					'icon_position'                      => 'left',
					'hover_icon'                         => '',
					'hover_transition'                   => '',
					'border_rotate_speed'                => '3',
					'enable_hover_text_icon'             => 'no',
					'hover_click_mode'                   => 'hover',
					'hover_text'                         => '',
					'link'                               => '',
					'link_attributes'                    => '',
					'modal'                              => '',
					'size'                               => '',
					'margin_bottom'                      => '',
					'margin_left'                        => '',
					'margin_right'                       => '',
					'margin_top'                         => '',
					'margin_bottom_medium'               => '',
					'margin_left_medium'                 => '',
					'margin_right_medium'                => '',
					'margin_top_medium'                  => '',
					'margin_bottom_small'                => '',
					'margin_left_small'                  => '',
					'margin_right_small'                 => '',
					'margin_top_small'                   => '',
					'stretch'                            => ( '' !== $fusion_settings->get( 'button_span' ) ) ? $fusion_settings->get( 'button_span' ) : 'no',
					'stretch_medium'                     => '',
					'stretch_small'                      => '',
					'default_stretch_value'              => ( '' !== $fusion_settings->get( 'button_span' ) ) ? $fusion_settings->get( 'button_span' ) : 'no',
					'target'                             => '_self',
					'text_transform'                     => '',
					'title'                              => '',
					'type'                               => ( '' !== $fusion_settings->get( 'button_type' ) ) ? strtolower( $fusion_settings->get( 'button_type' ) ) : 'flat',
					'alignment'                          => '',
					'alignment_medium'                   => '',
					'alignment_small'                    => '',
					'animation_type'                     => '',
					'animation_direction'                => 'down',
					'animation_speed'                    => '',
					'animation_delay'                    => '',
					'animation_offset'                   => $fusion_settings->get( 'animation_offset' ),
					'animation_color'                    => '',
					'padding_top'                        => '',
					'padding_right'                      => '',
					'padding_bottom'                     => '',
					'padding_left'                       => '',
					'padding_top_medium'                 => '',
					'padding_right_medium'               => '',
					'padding_bottom_medium'              => '',
					'padding_left_medium'                => '',
					'padding_top_small'                  => '',
					'padding_right_small'                => '',
					'padding_bottom_small'               => '',
					'padding_left_small'                 => '',
					'font_size'                          => '',
					'line_height'                        => '',
					'letter_spacing'                     => '',
					'fusion_font_family_button_font'     => '',
					'fusion_font_variant_button_font'    => '',
					'gradient_start_position'            => $fusion_settings->get( 'button_gradient_start' ),
					'gradient_end_position'              => $fusion_settings->get( 'button_gradient_end' ),
					'gradient_type'                      => $fusion_settings->get( 'button_gradient_type' ),
					'radial_direction'                   => $fusion_settings->get( 'button_radial_direction' ),
					'linear_angle'                       => $fusion_settings->get( 'button_gradient_angle' ),
					'border_radius_top_left'             => $fusion_settings->get( 'button_border_radius', 'top_left' ),
					'border_radius_top_right'            => $fusion_settings->get( 'button_border_radius', 'top_right' ),
					'border_radius_bottom_right'         => $fusion_settings->get( 'button_border_radius', 'bottom_right' ),
					'border_radius_bottom_left'          => $fusion_settings->get( 'button_border_radius', 'bottom_left' ),
					'border_top'                         => '',
					'border_right'                       => '',
					'border_bottom'                      => '',
					'border_left'                        => '',
					'icon_color'                         => '',
					'text_color'                         => '',
					'icon_hover_color'                   => '',
					'text_hover_color'                   => '',
					'gradient_hover_colors'              => '',
					'button_gradient_top_color'          => ( '' !== $fusion_settings->get( 'button_gradient_top_color' ) ) ? $fusion_settings->get( 'button_gradient_top_color' ) : '#65bc7b',
					'button_gradient_bottom_color'       => ( '' !== $fusion_settings->get( 'button_gradient_bottom_color' ) ) ? $fusion_settings->get( 'button_gradient_bottom_color' ) : '#65bc7b',
					'button_gradient_top_color_hover'    => ( '' !== $fusion_settings->get( 'button_gradient_top_color_hover' ) ) ? $fusion_settings->get( 'button_gradient_top_color_hover' ) : '#5aa86c',
					'button_gradient_bottom_color_hover' => ( '' !== $fusion_settings->get( 'button_gradient_bottom_color_hover' ) ) ? $fusion_settings->get( 'button_gradient_bottom_color_hover' ) : '#5aa86c',
					'button_accent_color'                => ( '' !== $fusion_settings->get( 'button_accent_color' ) ) ? $fusion_settings->get( 'button_accent_color' ) : '#ffffff',
					'button_accent_hover_color'          => ( '' !== $fusion_settings->get( 'button_accent_hover_color' ) ) ? $fusion_settings->get( 'button_accent_hover_color' ) : '#ffffff',
					'button_bevel_color'                 => ( '' !== $fusion_settings->get( 'button_bevel_color' ) ) ? $fusion_settings->get( 'button_bevel_color' ) : '#54770F',
				];
			}

			/**
			 * Maps settings to param variables.
			 *
			 * @static
			 * @access public
			 * @since 3.9
			 * @return array
			 */
			public static function settings_to_params() {
				return [
					'stripe_button_api_mode' => 'api_mode',
				];
			}

			/**
			 * Render the shortcode
			 *
			 * @access public
			 * @since 3.9
			 * @param  array  $args    Shortcode parameters.
			 * @param  string $content Content between shortcode.
			 * @return string          HTML output.
			 */
			public function render( $args, $content = '' ) {
				global $shortcode_tags;

				$this->set_element_id( $this->counter );
				$this->defaults = self::get_element_defaults();
				$this->args     = FusionBuilder::set_shortcode_defaults( $this->defaults, $args, 'fusion_stripe_button' );

				$html  = '<form ' . FusionBuilder::attributes( 'stripe_button-shortcode' ) . '>';
				$html .= $this->generate_hidden_fields();
				$html .= $this->generate_amount_field();
				$html .= call_user_func( $shortcode_tags['fusion_button'], $this->args, $content, 'fusion_button' );

				$html .= $this->render_notice( '&nbsp;', 'error' );

				$html .= '</form>';

				$this->counter++;

				$this->on_render();

				return apply_filters( 'fusion_element_stripe_button_content', $html, $args );
			}

			/**
			 * Builds the attributes array.
			 *
			 * @access public
			 * @since 3.9
			 * @return array
			 */
			public function attr() {
				$attr = [
					'class' => 'awb-stripe-button-form awb-strip-button-form-' . $this->counter,
					'style' => '',
				];

				$attr                    = fusion_builder_visibility_atts( $this->args['hide_on_mobile'], $attr );
				$attr['data-target']     = $this->args['target'];
				$attr['data-price-mode'] = self::get_price_mode( $this->args['price_mode'] );

				return $attr;
			}

			/**
			 * Normalizes the price mode.
			 * Anything unrecognized, including the empty value on content saved before 3.16.2, is a fixed price.
			 *
			 * @access public
			 * @static
			 * @since 3.16.2
			 * @param string $price_mode The submitted or stored price mode.
			 * @return string One of fixed|stripe|customer.
			 */
			public static function get_price_mode( $price_mode ) {
				return in_array( $price_mode, [ 'stripe', 'customer' ], true ) ? $price_mode : 'fixed';
			}

			/**
			 * Renders notice.
			 *
			 * @since 3.9
			 * @access private
			 * @param string $notice      The submission notice.
			 * @param string $notice_type Can be error|success.
			 * @return string The notices.
			 */
			private function render_notice( $notice, $notice_type ) {

				// If form was not sent yet, $notice will be empty, so return early.
				if ( ! $notice ) {
					return '';
				}

				if ( class_exists( 'FusionSC_Alert' ) ) {
					$shortcode = '[fusion_alert type="' . $notice_type . '" class="fusion-hidden awb-stripe-button-response awb-stripe-button-response-' . $notice_type . '" ';
					foreach ( [ 'margin_top', 'margin_right', 'margin_bottom', 'margin_left' ] as $param ) {
						if ( isset( $this->args[ $param ] ) && '' !== $this->args[ $param ] ) {
							$shortcode .= $param . '="' . $this->args[ $param ] . '" ';
						}
					}
					$shortcode .= ']' . $notice . '[/fusion_alert]';
					$notice     = do_shortcode( $shortcode );
				} else {
					$notice = '<div class="fusion-hidden awb-stripe-button-response awb-stripe-button-response-' . $notice_type . '">' . $notice . '</div>';
				}

				return apply_filters( 'fusion_stripe_button_notice', $notice, $notice_type );
			}

			/**
			 * Adds settings to element options panel.
			 *
			 * @access public
			 * @since 3.9
			 * @return array $sections Button settings.
			 */
			public function add_options() {
				$api_key_link = 'https://stripe.com/docs/keys#obtain-api-keys';
				return [
					'stripe_button_shortcode_section' => [
						'label'  => esc_html__( 'Stripe Button', 'fusion-builder' ),
						'id'     => 'stripe_button_shortcode_section',
						'type'   => 'accordion',
						'icon'   => 'fusiona-check-empty',
						'fields' => [
							'stripe_button_shortcode_important_note_info' => [
								'label'       => '',
								'description' => '<div class="fusion-redux-important-notice">' . __( '<strong>IMPORTANT NOTE:</strong> Insert API keys to authenticate requests with Stripe. You can find the keys in <a href="https://stripe.com/docs/keys" target="_blank">Stripe Account Dashboard</a>.', 'fusion-builder' ) . '</div>',
								'id'          => 'stripe_button_shortcode_important_note_info',
								'type'        => 'custom',
							],
							'stripe_button_api_mode' => [
								'type'        => 'radio-buttonset',
								'label'       => esc_attr__( 'API Mode', 'fusion-builder' ),
								'description' => esc_attr__( 'Build your integration in Test mode, and switch to Live mode when you are ready.', 'fusion-builder' ),
								'id'          => 'stripe_button_api_mode',
								'transport'   => 'postMessage',
								'choices'     => [
									'live' => esc_attr__( 'Live', 'fusion-builder' ),
									'test' => esc_attr__( 'Test', 'fusion-builder' ),
								],
								'default'     => 'test',
							],
							'stripe_button_test_secret_key' => [
								'label'       => esc_html__( 'Stripe Test Secret Key', 'fusion-builder' ),
								/* translators: %s - Link to the docs. */
								'description' => sprintf( __( 'Enter your Stripe Test Secret Key. For more information please see <a href="%s" target="_blank">Stripe API Guide</a>.', 'fusion-builder' ), $api_key_link ),
								'id'          => 'stripe_button_test_secret_key',
								'default'     => '',
								'type'        => 'text',
							],
							'stripe_button_validate_test_sk' => [
								'label'       => '',
								'description' => esc_html__( 'Test Secret Key Status.', 'fusion-builder' ),
								'id'          => 'stripe_button_validate_test_sk',
								'default'     => '',
								'type'        => 'raw',
								'content'     => '<a class="button button-secondary" href="#" onclick="awbValidateStripeApiKey(event);" data-mode="test" data-nonce="' . esc_attr( wp_create_nonce( 'awb_validate_stripe_api_key' ) ) . '" target="_self" >' . esc_html__( 'Test Connection', 'fusion-builder' ) . '</a><span class="spinner fusion-spinner"></span>',
								'full_width'  => false,
								'transport'   => 'postMessage', // No need to refresh the page.
							],
							'stripe_button_live_secret_key' => [
								'label'       => esc_html__( 'Stripe Live Secret Key', 'fusion-builder' ),
								/* translators: Link to the docs. */
								'description' => sprintf( __( 'Enter your Live Secret Key. For more information please see <a href="%s" target="_blank">Stripe API Guide</a>.', 'fusion-builder' ), $api_key_link ),
								'id'          => 'stripe_button_live_secret_key',
								'default'     => '',
								'type'        => 'text',
							],
							'stripe_button_validate_live_sk' => [
								'label'       => '',
								'description' => esc_html__( 'Live Secret Key Status.', 'fusion-builder' ),
								'id'          => 'stripe_button_validate_live_sk',
								'default'     => '',
								'type'        => 'raw',
								'content'     => '<a class="button button-secondary" href="#" onclick="awbValidateStripeApiKey(event);" data-mode="live" data-nonce="' . esc_attr( wp_create_nonce( 'awb_validate_stripe_api_key' ) ) . '" target="_self" >' . esc_html__( 'Test Connection', 'fusion-builder' ) . '</a><span class="spinner fusion-spinner"></span>',
								'full_width'  => false,
								'transport'   => 'postMessage', // No need to refresh the page.
							],
						],
					],
				];
			}

			/**
			 * Validate API KEY.
			 *
			 * @access public
			 * @since 3.9
			 * @return void
			 */
			public function validate_api_key() {
				check_ajax_referer( 'awb_validate_stripe_api_key', 'nonce' );

				if ( ! current_user_can( apply_filters( 'awb_role_manager_access_capability', 'manage_options', 'awb_global_options' ) ) ) {
					wp_send_json_error( esc_html__( 'You do not have permission to do this.', 'fusion-builder' ) );
				}

				$secret_key = '';
				if ( empty( $_POST['secretkey'] ) ) {
					wp_send_json_error( esc_html__( 'Secret Key is empty.', 'fusion-builder' ) );
				} else {
					$secret_key = wp_unslash( $_POST['secretkey'] ); // WordPress.Security.ValidatedSanitizedInput
				}

				$response = $this->api->validate_api_key_endpoint( $secret_key );
				$code     = $response['response']['code'];

				if ( 200 !== $code ) {
					wp_send_json_error( sprintf( '%s: %s. %s', $code, $response['response']['message'], esc_html__( 'Please make sure you are entering a valid API KEY.', 'fusion-builder' ) ) );
				} else {
					wp_send_json_success( esc_html__( 'API is working properly.', 'fusion-builder' ) );
				}
			}

			/**
			 * Generate form hidden fields.
			 *
			 * @access public
			 * @since 3.9
			 * @return string
			 */
			public function generate_hidden_fields() {
				global $wp;
				$current_url = home_url( add_query_arg( [], $wp->request ) );
				$price_mode  = self::get_price_mode( $this->args['price_mode'] );
				$api_mode    = self::get_api_mode( $this->args['api_mode'] );
				$html        = '';

				$fields = [
					'price_mode'       => $price_mode,
					'api_mode'         => $api_mode,
					'cancel_url'       => self::sanitize_redirect_url( $this->args['cancel_url'], $current_url ),
					'success_url'      => self::sanitize_redirect_url( $this->args['success_url'], $current_url ),
					'product_qty'      => $this->args['product_qty'],
					'shipping_price'   => $this->args['shipping_price'],
					'shipping_address' => $this->args['shipping_address'],
					'tax_rate'         => isset( $this->args[ $api_mode . '_tax_rate' ] ) ? $this->args[ $api_mode . '_tax_rate' ] : '',
					'product_name'     => 'stripe' === $price_mode ? '' : $this->args['product_name'],
					'currency'         => 'stripe' === $price_mode ? '' : $this->args['currency'],
					'price_id'         => 'stripe' === $price_mode && isset( $this->args[ $api_mode . '_price_id' ] ) ? $this->args[ $api_mode . '_price_id' ] : '',
					'product_price'    => 'fixed' === $price_mode ? $this->args['product_price'] : '',
					'min_price'        => 'customer' === $price_mode ? $this->args['min_price'] : '',
					'max_price'        => 'customer' === $price_mode ? $this->args['max_price'] : '',
				];

				// Signing these is what makes the server, rather than the browser, the authority on what gets charged.
				$signature = self::get_signature( $fields );

				// In customer mode the amount is the visible field the buyer fills in, so it is not repeated as a hidden one.
				if ( 'customer' === $price_mode ) {
					unset( $fields['product_price'] );
				}

				$fields['post_id'] = get_the_ID();
				$fields['awb_sig'] = $signature;

				foreach ( $fields as $key => $value ) {
					$html .= sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $key ), esc_attr( $value ) );
				}

				return $html;
			}

			/**
			 * Generates the visible amount field, for the customer chooses price mode.
			 *
			 * @access public
			 * @since 3.16.2
			 * @return string
			 */
			public function generate_amount_field() {
				if ( 'customer' !== self::get_price_mode( $this->args['price_mode'] ) ) {
					return '';
				}

				$field_id = 'awb-stripe-button-amount-' . $this->counter;
				$step     = FusionSC_Stripe_Button_API_Handler::is_zero_decimal( $this->args['currency'] ) ? '1' : '0.01';
				$label    = '' !== $this->args['amount_label'] ? $this->args['amount_label'] : esc_html__( 'Amount', 'fusion-builder' );

				$attributes = [
					'type'  => 'number',
					'name'  => 'product_price',
					'id'    => $field_id,
					'class' => 'awb-stripe-button-amount-input',
					'step'  => $step,
				];

				// The bounds are repeated on the server, where they are enforced. These only keep the browser from submitting.
				if ( '' !== $this->args['min_price'] ) {
					$attributes['min'] = $this->args['min_price'];
				}

				if ( '' !== $this->args['max_price'] ) {
					$attributes['max'] = $this->args['max_price'];
				}

				if ( '' !== $this->args['min_price'] ) {
					$attributes['value'] = $this->args['min_price'];
				}

				$html = '<div class="awb-stripe-button-amount">';

				$html .= sprintf(
					'<label class="awb-stripe-button-amount-label" for="%1$s">%2$s</label>',
					esc_attr( $field_id ),
					esc_html( $label )
				);

				$html .= '<input required';

				foreach ( $attributes as $key => $value ) {
					$html .= sprintf( ' %1$s="%2$s"', esc_attr( $key ), esc_attr( $value ) );
				}

				$html .= ' />';
				$html .= '</div>';

				return $html;
			}

			/**
			 * The fields whose values the site owner, rather than the visitor, decides.
			 *
			 * @access public
			 * @static
			 * @since 3.16.2
			 * @return array
			 */
			public static function get_signed_fields() {
				return [
					'price_mode',
					'api_mode',
					'cancel_url',
					'success_url',
					'product_qty',
					'shipping_price',
					'shipping_address',
					'tax_rate',
					'product_name',
					'currency',
					'price_id',
					'product_price',
					'min_price',
					'max_price',
				];
			}

			/**
			 * Signs the configured values, so that the submission can be checked against what was rendered.
			 *
			 * @access public
			 * @static
			 * @since 3.16.2
			 * @param array $fields The fields to sign.
			 * @return string
			 */
			public static function get_signature( $fields ) {
				$price_mode = self::get_price_mode( isset( $fields['price_mode'] ) ? $fields['price_mode'] : '' );
				$canonical  = [];

				foreach ( self::get_signed_fields() as $key ) {
					$value = isset( $fields[ $key ] ) ? (string) $fields[ $key ] : '';

					// Normalized so that a stored '' and an explicit 'fixed' cannot produce two different signatures.
					if ( 'price_mode' === $key ) {
						$value = $price_mode;
					}

					// The buyer picks the amount in customer mode, so it is checked against the signed bounds instead of being signed.
					if ( 'product_price' === $key && 'customer' === $price_mode ) {
						$value = '';
					}

					$canonical[] = $key . '=' . $value;
				}

				return hash_hmac( 'sha256', implode( '&', $canonical ), wp_salt( 'awb_stripe_button' ) );
			}

			/**
			 * Normalizes the API mode, falling back to the global option and then to test.
			 *
			 * @access public
			 * @static
			 * @since 3.16.2
			 * @param string $api_mode The stored or submitted API mode.
			 * @return string One of test|live.
			 */
			public static function get_api_mode( $api_mode ) {
				if ( ! in_array( $api_mode, [ 'test', 'live' ], true ) ) {
					$api_mode = awb_get_fusion_settings()->get( 'stripe_button_api_mode' );
				}

				return in_array( $api_mode, [ 'test', 'live' ], true ) ? $api_mode : 'test';
			}

			/**
			 * Makes a Stripe redirect URL an absolute http(s) URL.
			 * Off-site URLs are allowed, e.g. a thank you page on another domain: the URLs are part
			 * of the signed fields, so a request can't swap in its own.
			 *
			 * @access public
			 * @static
			 * @since 3.16.2
			 * @param string $url      The configured URL.
			 * @param string $fallback The URL to use when the configured one is empty or invalid.
			 * @return string
			 */
			public static function sanitize_redirect_url( $url, $fallback ) {
				$url = esc_url_raw( (string) $url, [ 'http', 'https' ] );

				if ( '' === $url ) {
					return $fallback;
				}

				// Stripe rejects anything that is not absolute.
				if ( 0 !== strpos( $url, 'http' ) ) {
					$url = home_url( $url );
				}

				return $url;
			}

			/**
			 * Submit Stripe Form.
			 *
			 * @access public
			 * @since 3.9
			 * @return void
			 */
			public function submit_form_ajax() {
				check_ajax_referer( 'awb-stripe-button-nonce', 'nonce' );

				$fields = [];

				if ( isset( $_POST['data'] ) ) {
					wp_parse_str( wp_unslash( $_POST['data'] ), $fields ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
				}

				$args = $this->validate_submission( $fields );

				if ( is_wp_error( $args ) ) {
					$this->error_handler( 400, $args->get_error_message() );
					return;
				}

				$fusion_settings = awb_get_fusion_settings();
				$secret_key      = $fusion_settings->get( "stripe_button_{$args['api_mode']}_secret_key" );

				if ( ! empty( $secret_key ) ) {
					$this->api->post_checkout_endpoint( $secret_key, $args );
				} else {
					$this->error_handler( 401, esc_html__( 'Secret Key is empty. Please enter a valid secret key', 'fusion-builder' ) );
				}
			}

			/**
			 * Checks a submission against the values that were signed when the button was rendered.
			 * Everything the site owner configured is taken from the signed set, never from the request.
			 *
			 * @access protected
			 * @since 3.16.2
			 * @param array $fields The parsed form fields.
			 * @return array|WP_Error The arguments for the checkout session, or an error.
			 */
			protected function validate_submission( $fields ) {
				$generic_error = esc_html__( 'This payment could not be started. Please reload the page and try again.', 'fusion-builder' );
				$signature     = isset( $fields['awb_sig'] ) ? (string) $fields['awb_sig'] : '';

				if ( '' === $signature || ! hash_equals( self::get_signature( $fields ), $signature ) ) {
					return new WP_Error( 'awb_stripe_button_signature', $generic_error );
				}

				$price_mode = self::get_price_mode( isset( $fields['price_mode'] ) ? $fields['price_mode'] : '' );
				$args       = wp_parse_args( $fields, self::get_element_defaults() );
				$fallback   = home_url( '/' );

				$args['price_mode']  = $price_mode;
				$args['api_mode']    = self::get_api_mode( isset( $fields['api_mode'] ) ? $fields['api_mode'] : '' );
				$args['success_url'] = self::sanitize_redirect_url( $args['success_url'], $fallback );
				$args['cancel_url']  = self::sanitize_redirect_url( $args['cancel_url'], $fallback );

				$quantity = isset( $fields['product_qty'] ) ? (int) $fields['product_qty'] : 1;

				if ( 1 > $quantity || 999999 < $quantity ) {
					return new WP_Error( 'awb_stripe_button_quantity', $generic_error );
				}

				$args['product_qty'] = $quantity;

				if ( 'stripe' === $price_mode ) {

					// The select value pairs the Price ID with its currency, the same way the tax rate one pairs id and behavior.
					$price_parts      = explode( '|', isset( $fields['price_id'] ) ? (string) $fields['price_id'] : '' );
					$args['price_id'] = $price_parts[0];
					$args['currency'] = isset( $price_parts[1] ) ? strtoupper( $price_parts[1] ) : '';

					if ( ! preg_match( '/^price_[A-Za-z0-9]+$/', $args['price_id'] ) ) {
						return new WP_Error( 'awb_stripe_button_price_id', $generic_error );
					}

					return $args;
				}

				$currency = strtoupper( (string) $args['currency'] );

				if ( ! array_key_exists( $currency, $this->get_currencies() ) ) {
					return new WP_Error( 'awb_stripe_button_currency', $generic_error );
				}

				$args['currency'] = $currency;

				if ( 'customer' === $price_mode ) {
					$amount = isset( $fields['product_price'] ) ? $fields['product_price'] : '';

					if ( ! is_numeric( $amount ) ) {
						return new WP_Error( 'awb_stripe_button_amount', esc_html__( 'Please enter a valid amount.', 'fusion-builder' ) );
					}

					$amount = (float) $amount;

					// The bounds come out of the signed set, so they are the ones the site owner configured.
					$min = isset( $fields['min_price'] ) && '' !== $fields['min_price'] ? (float) $fields['min_price'] : 0;
					$max = isset( $fields['max_price'] ) && '' !== $fields['max_price'] ? (float) $fields['max_price'] : 0;

					if ( $amount < $min ) {
						return new WP_Error(
							'awb_stripe_button_amount_min',
							sprintf(
								/* translators: %1$s: The minimum amount. %2$s: The currency. */
								esc_html__( 'The minimum amount is %1$s %2$s.', 'fusion-builder' ),
								FusionSC_Stripe_Button_API_Handler::format_amount( $currency, FusionSC_Stripe_Button_API_Handler::is_zero_decimal( $currency ) ? $min : $min * 100 ),
								$currency
							)
						);
					}

					if ( 0 < $max && $amount > $max ) {
						return new WP_Error(
							'awb_stripe_button_amount_max',
							sprintf(
								/* translators: %1$s: The maximum amount. %2$s: The currency. */
								esc_html__( 'The maximum amount is %1$s %2$s.', 'fusion-builder' ),
								FusionSC_Stripe_Button_API_Handler::format_amount( $currency, FusionSC_Stripe_Button_API_Handler::is_zero_decimal( $currency ) ? $max : $max * 100 ),
								$currency
							)
						);
					}

					$args['product_price'] = $amount;
				}

				return $args;
			}

			/**
			 * Error handler
			 *
			 * @since 3.9
			 *
			 * @param int    $status_code The status code.
			 * @param string $error_message The error message.
			 */
			protected function error_handler( $status_code, $error_message ) {
				$resp['response']['code'] = $status_code;
				$resp['body']             = wp_json_encode(
					[ 'error' => [ 'message' => $error_message ] ],
					JSON_PRETTY_PRINT
				);

				wp_send_json( $resp );
			}

			/**
			 * Get list of supported currencies.
			 *
			 * @access public
			 * @since 3.9
			 * @return array
			 */
			public function get_currencies() {
				return [
					'USD' => _x( 'USD', 'Currency', 'fusion-builder' ),
					'AED' => _x( 'AED', 'Currency', 'fusion-builder' ),
					'AFN' => _x( 'AFN', 'Currency', 'fusion-builder' ),
					'ALL' => _x( 'ALL', 'Currency', 'fusion-builder' ),
					'AMD' => _x( 'AMD', 'Currency', 'fusion-builder' ),
					'ANG' => _x( 'ANG', 'Currency', 'fusion-builder' ),
					'AOA' => _x( 'AOA', 'Currency', 'fusion-builder' ),
					'ARS' => _x( 'ARS', 'Currency', 'fusion-builder' ),
					'AUD' => _x( 'AUD', 'Currency', 'fusion-builder' ),
					'AWG' => _x( 'AWG', 'Currency', 'fusion-builder' ),
					'AZN' => _x( 'AZN', 'Currency', 'fusion-builder' ),
					'BAM' => _x( 'BAM', 'Currency', 'fusion-builder' ),
					'BBD' => _x( 'BBD', 'Currency', 'fusion-builder' ),
					'BDT' => _x( 'BDT', 'Currency', 'fusion-builder' ),
					'BGN' => _x( 'BGN', 'Currency', 'fusion-builder' ),
					'BIF' => _x( 'BIF', 'Currency', 'fusion-builder' ),
					'BMD' => _x( 'BMD', 'Currency', 'fusion-builder' ),
					'BND' => _x( 'BND', 'Currency', 'fusion-builder' ),
					'BOB' => _x( 'BOB', 'Currency', 'fusion-builder' ),
					'BRL' => _x( 'BRL', 'Currency', 'fusion-builder' ),
					'BSD' => _x( 'BSD', 'Currency', 'fusion-builder' ),
					'BWP' => _x( 'BWP', 'Currency', 'fusion-builder' ),
					'BYN' => _x( 'BYN', 'Currency', 'fusion-builder' ),
					'BZD' => _x( 'BZD', 'Currency', 'fusion-builder' ),
					'CAD' => _x( 'CAD', 'Currency', 'fusion-builder' ),
					'CDF' => _x( 'CDF', 'Currency', 'fusion-builder' ),
					'CHF' => _x( 'CHF', 'Currency', 'fusion-builder' ),
					'CLP' => _x( 'CLP', 'Currency', 'fusion-builder' ),
					'CNY' => _x( 'CNY', 'Currency', 'fusion-builder' ),
					'COP' => _x( 'COP', 'Currency', 'fusion-builder' ),
					'CRC' => _x( 'CRC', 'Currency', 'fusion-builder' ),
					'CVE' => _x( 'CVE', 'Currency', 'fusion-builder' ),
					'CZK' => _x( 'CZK', 'Currency', 'fusion-builder' ),
					'DJF' => _x( 'DJF', 'Currency', 'fusion-builder' ),
					'DKK' => _x( 'DKK', 'Currency', 'fusion-builder' ),
					'DOP' => _x( 'DOP', 'Currency', 'fusion-builder' ),
					'DZD' => _x( 'DZD', 'Currency', 'fusion-builder' ),
					'EGP' => _x( 'EGP', 'Currency', 'fusion-builder' ),
					'ETB' => _x( 'ETB', 'Currency', 'fusion-builder' ),
					'EUR' => _x( 'EUR', 'Currency', 'fusion-builder' ),
					'FJD' => _x( 'FJD', 'Currency', 'fusion-builder' ),
					'FKP' => _x( 'FKP', 'Currency', 'fusion-builder' ),
					'GBP' => _x( 'GBP', 'Currency', 'fusion-builder' ),
					'GEL' => _x( 'GEL', 'Currency', 'fusion-builder' ),
					'GIP' => _x( 'GIP', 'Currency', 'fusion-builder' ),
					'GMD' => _x( 'GMD', 'Currency', 'fusion-builder' ),
					'GNF' => _x( 'GNF', 'Currency', 'fusion-builder' ),
					'GTQ' => _x( 'GTQ', 'Currency', 'fusion-builder' ),
					'GYD' => _x( 'GYD', 'Currency', 'fusion-builder' ),
					'HKD' => _x( 'HKD', 'Currency', 'fusion-builder' ),
					'HNL' => _x( 'HNL', 'Currency', 'fusion-builder' ),
					'HRK' => _x( 'HRK', 'Currency', 'fusion-builder' ),
					'HTG' => _x( 'HTG', 'Currency', 'fusion-builder' ),
					'IDR' => _x( 'IDR', 'Currency', 'fusion-builder' ),
					'ILS' => _x( 'ILS', 'Currency', 'fusion-builder' ),
					'INR' => _x( 'INR', 'Currency', 'fusion-builder' ),
					'ISK' => _x( 'ISK', 'Currency', 'fusion-builder' ),
					'JMD' => _x( 'JMD', 'Currency', 'fusion-builder' ),
					'JPY' => _x( 'JPY', 'Currency', 'fusion-builder' ),
					'KES' => _x( 'KES', 'Currency', 'fusion-builder' ),
					'KGS' => _x( 'KGS', 'Currency', 'fusion-builder' ),
					'KHR' => _x( 'KHR', 'Currency', 'fusion-builder' ),
					'KMF' => _x( 'KMF', 'Currency', 'fusion-builder' ),
					'KRW' => _x( 'KRW', 'Currency', 'fusion-builder' ),
					'KYD' => _x( 'KYD', 'Currency', 'fusion-builder' ),
					'KZT' => _x( 'KZT', 'Currency', 'fusion-builder' ),
					'LAK' => _x( 'LAK', 'Currency', 'fusion-builder' ),
					'LBP' => _x( 'LBP', 'Currency', 'fusion-builder' ),
					'LKR' => _x( 'LKR', 'Currency', 'fusion-builder' ),
					'LRD' => _x( 'LRD', 'Currency', 'fusion-builder' ),
					'LSL' => _x( 'LSL', 'Currency', 'fusion-builder' ),
					'MAD' => _x( 'MAD', 'Currency', 'fusion-builder' ),
					'MDL' => _x( 'MDL', 'Currency', 'fusion-builder' ),
					'MGA' => _x( 'MGA', 'Currency', 'fusion-builder' ),
					'MKD' => _x( 'MKD', 'Currency', 'fusion-builder' ),
					'MMK' => _x( 'MMK', 'Currency', 'fusion-builder' ),
					'MNT' => _x( 'MNT', 'Currency', 'fusion-builder' ),
					'MOP' => _x( 'MOP', 'Currency', 'fusion-builder' ),
					'MRO' => _x( 'MRO', 'Currency', 'fusion-builder' ),
					'MUR' => _x( 'MUR', 'Currency', 'fusion-builder' ),
					'MVR' => _x( 'MVR', 'Currency', 'fusion-builder' ),
					'MWK' => _x( 'MWK', 'Currency', 'fusion-builder' ),
					'MXN' => _x( 'MXN', 'Currency', 'fusion-builder' ),
					'MYR' => _x( 'MYR', 'Currency', 'fusion-builder' ),
					'MZN' => _x( 'MZN', 'Currency', 'fusion-builder' ),
					'NAD' => _x( 'NAD', 'Currency', 'fusion-builder' ),
					'NGN' => _x( 'NGN', 'Currency', 'fusion-builder' ),
					'NIO' => _x( 'NIO', 'Currency', 'fusion-builder' ),
					'NOK' => _x( 'NOK', 'Currency', 'fusion-builder' ),
					'NPR' => _x( 'NPR', 'Currency', 'fusion-builder' ),
					'NZD' => _x( 'NZD', 'Currency', 'fusion-builder' ),
					'PAB' => _x( 'PAB', 'Currency', 'fusion-builder' ),
					'PEN' => _x( 'PEN', 'Currency', 'fusion-builder' ),
					'PGK' => _x( 'PGK', 'Currency', 'fusion-builder' ),
					'PHP' => _x( 'PHP', 'Currency', 'fusion-builder' ),
					'PKR' => _x( 'PKR', 'Currency', 'fusion-builder' ),
					'PLN' => _x( 'PLN', 'Currency', 'fusion-builder' ),
					'PYG' => _x( 'PYG', 'Currency', 'fusion-builder' ),
					'QAR' => _x( 'QAR', 'Currency', 'fusion-builder' ),
					'RON' => _x( 'RON', 'Currency', 'fusion-builder' ),
					'RSD' => _x( 'RSD', 'Currency', 'fusion-builder' ),
					'RUB' => _x( 'RUB', 'Currency', 'fusion-builder' ),
					'RWF' => _x( 'RWF', 'Currency', 'fusion-builder' ),
					'SAR' => _x( 'SAR', 'Currency', 'fusion-builder' ),
					'SBD' => _x( 'SBD', 'Currency', 'fusion-builder' ),
					'SCR' => _x( 'SCR', 'Currency', 'fusion-builder' ),
					'SEK' => _x( 'SEK', 'Currency', 'fusion-builder' ),
					'SGD' => _x( 'SGD', 'Currency', 'fusion-builder' ),
					'SHP' => _x( 'SHP', 'Currency', 'fusion-builder' ),
					'SLL' => _x( 'SLL', 'Currency', 'fusion-builder' ),
					'SOS' => _x( 'SOS', 'Currency', 'fusion-builder' ),
					'SRD' => _x( 'SRD', 'Currency', 'fusion-builder' ),
					'STD' => _x( 'STD', 'Currency', 'fusion-builder' ),
					'SZL' => _x( 'SZL', 'Currency', 'fusion-builder' ),
					'THB' => _x( 'THB', 'Currency', 'fusion-builder' ),
					'TJS' => _x( 'TJS', 'Currency', 'fusion-builder' ),
					'TOP' => _x( 'TOP', 'Currency', 'fusion-builder' ),
					'TRY' => _x( 'TRY', 'Currency', 'fusion-builder' ),
					'TTD' => _x( 'TTD', 'Currency', 'fusion-builder' ),
					'TWD' => _x( 'TWD', 'Currency', 'fusion-builder' ),
					'TZS' => _x( 'TZS', 'Currency', 'fusion-builder' ),
					'UAH' => _x( 'UAH', 'Currency', 'fusion-builder' ),
					'UYU' => _x( 'UYU', 'Currency', 'fusion-builder' ),
					'UZS' => _x( 'UZS', 'Currency', 'fusion-builder' ),
					'VND' => _x( 'VND', 'Currency', 'fusion-builder' ),
					'VUV' => _x( 'VUV', 'Currency', 'fusion-builder' ),
					'WST' => _x( 'WST', 'Currency', 'fusion-builder' ),
					'XAF' => _x( 'XAF', 'Currency', 'fusion-builder' ),
					'XCD' => _x( 'XCD', 'Currency', 'fusion-builder' ),
					'XOF' => _x( 'XOF', 'Currency', 'fusion-builder' ),
					'XPF' => _x( 'XPF', 'Currency', 'fusion-builder' ),
					'YER' => _x( 'YER', 'Currency', 'fusion-builder' ),
					'ZAR' => _x( 'ZAR', 'Currency', 'fusion-builder' ),
					'ZMW' => _x( 'ZMW', 'Currency', 'fusion-builder' ),
				];
			}

			/**
			 * Get tax rates.
			 *
			 * @access public
			 * @since 3.9
			 * @param string $mode The mode.
			 * @return array
			 */
			public function get_tax_rates( $mode ) {
				$fusion_settings = awb_get_fusion_settings();
				$options         = [
					'' => esc_html__( 'None', 'fusion-builder' ),
				];
				$secret_key      = $fusion_settings->get( "stripe_button_{$mode}_secret_key" );
				if ( ! empty( $secret_key ) ) {
					$rates   = $this->api->post_tax_rates_endpoint( $secret_key );
					$options = array_merge( $options, $rates );
				}
				return $options;
			}

			/**
			 * Get the list of products from the Stripe account, for the Stripe product price mode.
			 *
			 * @access public
			 * @since 3.16.2
			 * @param string $mode The API mode.
			 * @return array
			 */
			public function get_prices( $mode ) {
				$fusion_settings = awb_get_fusion_settings();
				$options         = [
					'' => esc_html__( 'Select a product', 'fusion-builder' ),
				];
				$secret_key      = $fusion_settings->get( "stripe_button_{$mode}_secret_key" );

				if ( empty( $secret_key ) ) {
					return $options;
				}

				// Cached so that opening the element settings does not hit the API on every load.
				$transient_key = 'awb_stripe_button_prices_' . $mode . '_' . md5( $secret_key );
				$prices        = get_transient( $transient_key );

				if ( false === $prices ) {
					$prices = $this->api->get_prices_endpoint( $secret_key );
					set_transient( $transient_key, $prices, 5 * MINUTE_IN_SECONDS );
				}

				return array_merge( $options, $prices );
			}

			/**
			 * Load base CSS.
			 *
			 * @access public
			 * @since 3.16.2
			 * @return void
			 */
			public function add_css_files() {
				FusionBuilder()->add_element_css( FUSION_BUILDER_PLUGIN_DIR . 'assets/css/shortcodes/stripe-button.min.css' );
			}

			/**
			 * Sets the necessary scripts.
			 *
			 * @access public
			 * @since 3.9
			 * @return void
			 */
			public function on_first_render() {

				Fusion_Dynamic_JS::enqueue_script(
					'fusion-stripe-button',
					FusionBuilder::$js_folder_url . '/general/fusion-stripe-button.js',
					FusionBuilder::$js_folder_path . '/general/fusion-stripe-button.js',
					[ 'jquery' ],
					FUSION_BUILDER_VERSION,
					true
				);

				Fusion_Dynamic_JS::localize_script(
					'fusion-stripe-button',
					'fusionStripeButtonVars',
					[
						'ajax_url'         => admin_url( 'admin-ajax.php' ),
						'nonce'            => wp_create_nonce( 'awb-stripe-button-nonce' ),
						'productEmptyText' => esc_html__( 'Please fill product name or price in Element Settings.', 'fusion-builder' ),
					]
				);
			}
		}
	}

	/**
	 * Instantiates the post cards class.
	 *
	 * @since 3.9
	 * @return object FusionSC_Stripe_Button
	 */
	function fusion_stripe_button() { // phpcs:ignore WordPress.NamingConventions
		return FusionSC_Stripe_Button::get_instance();
	}

	// Instantiate stripe button.
	fusion_stripe_button();

}

/**
 * Map shortcode to Avada Builder.
 *
 * @since 3.9
 */
function fusion_element_stripe_button() {
	$editing             = function_exists( 'is_fusion_editor' ) && is_fusion_editor();
	$fusion_settings     = awb_get_fusion_settings();
	$currencies          = [];
	$test_mode_tax_rates = [];
	$live_mode_tax_rates = [];
	$test_mode_prices    = [];
	$live_mode_prices    = [];

	if ( function_exists( 'fusion_stripe_button' ) && $editing ) {
		$currencies          = fusion_stripe_button()->get_currencies();
		$test_mode_tax_rates = fusion_stripe_button()->get_tax_rates( 'test' );
		$live_mode_tax_rates = fusion_stripe_button()->get_tax_rates( 'live' );
		$test_mode_prices    = fusion_stripe_button()->get_prices( 'test' );
		$live_mode_prices    = fusion_stripe_button()->get_prices( 'live' );
	}

	$standard_schemes = [
		'default' => esc_attr__( 'Default', 'fusion-builder' ),
		'custom'  => esc_attr__( 'Custom', 'fusion-builder' ),
	];

	$style_option = 'radio_button_set';
	if ( apply_filters( 'awb_load_button_presets', ( '1' === $fusion_settings->get( 'button_presets' ) ) ) ) {
		$style_option     = 'select';
		$standard_schemes = [
			'default'   => esc_attr__( 'Default', 'fusion-builder' ),
			'custom'    => esc_attr__( 'Custom', 'fusion-builder' ),
			'green'     => esc_attr__( 'Green', 'fusion-builder' ),
			'darkgreen' => esc_attr__( 'Dark Green', 'fusion-builder' ),
			'orange'    => esc_attr__( 'Orange', 'fusion-builder' ),
			'blue'      => esc_attr__( 'Blue', 'fusion-builder' ),
			'red'       => esc_attr__( 'Red', 'fusion-builder' ),
			'pink'      => esc_attr__( 'Pink', 'fusion-builder' ),
			'darkgray'  => esc_attr__( 'Dark Gray', 'fusion-builder' ),
			'lightgray' => esc_attr__( 'Light Gray', 'fusion-builder' ),
		];
	}

	fusion_builder_map(
		fusion_builder_frontend_data(
			'FusionSC_Stripe_Button',
			[
				'name'          => esc_attr__( 'Stripe Button', 'fusion-builder' ),
				'shortcode'     => 'fusion_stripe_button',
				'icon'          => 'fusiona-check-empty',
				'preview'       => FUSION_BUILDER_PLUGIN_DIR . 'inc/templates/previews/fusion-button-preview.php',
				'preview_id'    => 'fusion-builder-block-module-button-preview-template',
				'help_url'      => 'https://classic.avada.com/documentation/stripe-button-element/',
				'inline_editor' => true,
				'subparam_map'  => [
					'fusion_font_family_button_font'  => 'main_typography',
					'fusion_font_variant_button_font' => 'main_typography',
					'font_size'                       => 'main_typography',
					'line_height'                     => 'main_typography',
					'letter_spacing'                  => 'main_typography',
					'text_transform'                  => 'main_typography',
				],
				'params'        => [
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'API Mode', 'fusion-builder' ),
						'description' => esc_attr__( 'Build your integration in Test mode, and switch to Live mode when you are ready.', 'fusion-builder' ),
						'param_name'  => 'api_mode',
						'default'     => '',
						'value'       => [
							''     => esc_attr__( 'Default', 'fusion-builder' ),
							'live' => esc_attr__( 'Live', 'fusion-builder' ),
							'test' => esc_attr__( 'Test', 'fusion-builder' ),
						],
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Price Mode', 'fusion-builder' ),
						'description' => esc_attr__( 'Select where the amount comes from. "Fixed Price" charges the price you enter below. "Stripe Product" charges a price from your Stripe account, which is the option to use if you manage your catalog in Stripe. "Customer Chooses" lets the visitor enter their own amount, for donations or pay what you want, within the limits you set.', 'fusion-builder' ),
						'param_name'  => 'price_mode',
						'default'     => 'fixed',
						'value'       => [
							'fixed'    => esc_attr__( 'Fixed Price', 'fusion-builder' ),
							'stripe'   => esc_attr__( 'Stripe Product', 'fusion-builder' ),
							'customer' => esc_attr__( 'Customer Chooses', 'fusion-builder' ),
						],
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Stripe Product', 'fusion-builder' ),
						'description' => esc_attr__( 'Select the product to charge for. These options are the active one time prices in your Stripe account, and can be managed on Stripe dashboard > Products. The amount and currency are taken from Stripe, so they cannot be changed here.', 'fusion-builder' ),
						'param_name'  => 'test_price_id',
						'default'     => '',
						'value'       => $test_mode_prices,
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'price_mode',
								'value'    => 'stripe',
								'operator' => '==',
							],
							[
								'element'  => 'api_mode',
								'value'    => 'live',
								'operator' => '!=',
							],
						],
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Stripe Product', 'fusion-builder' ),
						'description' => esc_attr__( 'Select the product to charge for. These options are the active one time prices in your Stripe account, and can be managed on Stripe dashboard > Products. The amount and currency are taken from Stripe, so they cannot be changed here.', 'fusion-builder' ),
						'param_name'  => 'live_price_id',
						'default'     => '',
						'value'       => $live_mode_prices,
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'price_mode',
								'value'    => 'stripe',
								'operator' => '==',
							],
							[
								'element'  => 'api_mode',
								'value'    => 'test',
								'operator' => '!=',
							],
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Collect Shipping Address', 'fusion-builder' ),
						'description' => esc_attr__( 'Collect customer shipping address.', 'fusion-builder' ),
						'param_name'  => 'shipping_address',
						'default'     => 'yes',
						'value'       => [
							'yes' => esc_attr__( 'Yes', 'fusion-builder' ),
							'no'  => esc_attr__( 'No', 'fusion-builder' ),
						],
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Product Name', 'fusion-builder' ),
						'param_name'   => 'product_name',
						'value'        => esc_attr__( 'My Product', 'fusion-builder' ),
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the product name that you sell.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'price_mode',
								'value'    => 'stripe',
								'operator' => '!=',
							],
						],
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Currency', 'fusion-builder' ),
						'description' => esc_attr__( 'Select the currency.', 'fusion-builder' ),
						'param_name'  => 'currency',
						'default'     => 'USD',
						'value'       => $currencies,
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'price_mode',
								'value'    => 'stripe',
								'operator' => '!=',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Product Price', 'fusion-builder' ),
						'param_name'   => 'product_price',
						'value'        => '3.99',
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the product price. Decimal numbers are supported by using the "." (period) delimiter.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'price_mode',
								'value'    => 'fixed',
								'operator' => '==',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Amount Field Label', 'fusion-builder' ),
						'param_name'   => 'amount_label',
						'value'        => esc_attr__( 'Amount', 'fusion-builder' ),
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the label shown above the field the customer enters their amount into.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'price_mode',
								'value'    => 'customer',
								'operator' => '==',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Minimum Amount', 'fusion-builder' ),
						'param_name'   => 'min_price',
						'value'        => '1',
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the lowest amount the customer is allowed to pay. Decimal numbers are supported by using the "." (period) delimiter. Note that Stripe enforces its own minimum charge amount per currency, which is around 0.50 for most of them.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'price_mode',
								'value'    => 'customer',
								'operator' => '==',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Maximum Amount', 'fusion-builder' ),
						'param_name'   => 'max_price',
						'value'        => '',
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the highest amount the customer is allowed to pay. Leave empty for no upper limit. Decimal numbers are supported by using the "." (period) delimiter.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'price_mode',
								'value'    => 'customer',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'textfield',
						'heading'     => esc_attr__( 'Quantity', 'fusion-builder' ),
						'param_name'  => 'product_qty',
						'value'       => '1',
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'description' => esc_attr__( 'Add the product quantity.', 'fusion-builder' ),
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Shipping Price', 'fusion-builder' ),
						'param_name'   => 'shipping_price',
						'value'        => '',
						'group'        => esc_attr__( 'Payment', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the shipping price. Decimal numbers are supported by using the "." (period) delimiter.', 'fusion-builder' ),
						'dynamic_data' => true,
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Tax Rate', 'fusion-builder' ),
						'description' => esc_attr__( 'Select the tax rate. These options can be managed on Stripe dashboard > Products > Tax Rates.', 'fusion-builder' ),
						'param_name'  => 'test_tax_rate',
						'default'     => 'none',
						'value'       => $test_mode_tax_rates,
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'api_mode',
								'value'    => 'live',
								'operator' => '!=',
							],
						],
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Tax Rate', 'fusion-builder' ),
						'description' => esc_attr__( 'Select the tax rate. These options can be managed on Stripe dashboard > Products > Tax Rates.', 'fusion-builder' ),
						'param_name'  => 'live_tax_rate',
						'default'     => 'none',
						'value'       => $live_mode_tax_rates,
						'group'       => esc_attr__( 'Payment', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'api_mode',
								'value'    => 'test',
								'operator' => '!=',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Button Text', 'fusion-builder' ),
						'param_name'   => 'element_content',
						'value'        => esc_attr__( 'Pay Now', 'fusion-builder' ),
						'description'  => esc_attr__( 'Add the text that will display on button.', 'fusion-builder' ),
						'placeholder'  => true,
						'dynamic_data' => true,
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Hover Or Click Text / Icon', 'fusion-builder' ),
						'description' => esc_attr__( 'Turn on to enable independent hover text and icon options.', 'fusion-builder' ),
						'param_name'  => 'enable_hover_text_icon',
						'default'     => 'no',
						'value'       => [
							'yes' => esc_attr__( 'On', 'fusion-builder' ),
							'no'  => esc_attr__( 'Off', 'fusion-builder' ),
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Mode', 'fusion-builder' ),
						'description' => esc_attr__( 'Choose if icon and text should change on hover or click.', 'fusion-builder' ),
						'param_name'  => 'hover_click_mode',
						'default'     => 'hover',
						'value'       => [
							'hover'  => esc_attr__( 'Hover', 'fusion-builder' ),
							'click'  => esc_attr__( 'Click', 'fusion-builder' ),
							'toggle' => esc_attr__( 'Toggle', 'fusion-builder' ),
						],
						'dependency'  => [
							[
								'element'  => 'enable_hover_text_icon',
								'value'    => 'yes',
								'operator' => '==',
							],
						],
					],
					[
						'type'         => 'textfield',
						'heading'      => esc_attr__( 'Button Hover / Click Text', 'fusion-builder' ),
						'param_name'   => 'hover_text',
						'value'        => '',
						'description'  => esc_attr__( 'Add the text that will display on button hover / click.', 'fusion-builder' ),
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'enable_hover_text_icon',
								'value'    => 'yes',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Target', 'fusion-builder' ),
						'description' => esc_attr__( '_self = open in same browser tab, _blank = open in new browser tab.', 'fusion-builder' ),
						'param_name'  => 'target',
						'default'     => '_self',
						'value'       => [
							'_self'  => esc_attr__( '_self', 'fusion-builder' ),
							'_blank' => esc_attr__( '_blank', 'fusion-builder' ),
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Alignment', 'fusion-builder' ),
						'description' => esc_attr__( "Select the button's alignment.", 'fusion-builder' ),
						'param_name'  => 'alignment',
						'default'     => '',
						'responsive'  => [
							'state' => 'large',
						],
						'value'       => [
							''       => esc_attr__( 'Text Flow', 'fusion-builder' ),
							'left'   => esc_attr__( 'Left', 'fusion-builder' ),
							'center' => esc_attr__( 'Center', 'fusion-builder' ),
							'right'  => esc_attr__( 'Right', 'fusion-builder' ),
						],
					],
					[
						'type'         => 'link_selector',
						'heading'      => esc_attr__( 'Payment Success URL', 'fusion-builder' ),
						'param_name'   => 'success_url',
						'value'        => '',
						'description'  => esc_attr__( 'The URL the customer will be directed to after the payment is successful. ex: http://example.com.', 'fusion-builder' ),
						'dynamic_data' => true,
					],
					[
						'type'         => 'link_selector',
						'heading'      => esc_attr__( 'Payment Cancel URL', 'fusion-builder' ),
						'param_name'   => 'cancel_url',
						'value'        => '',
						'description'  => esc_attr__( 'The URL the customer will be directed to if they decide to cancel payment. ex: http://example.com.', 'fusion-builder' ),
						'dynamic_data' => true,
					],
					[
						'type'        => $style_option,
						'heading'     => esc_attr__( 'Button Style', 'fusion-builder' ),
						'description' => $fusion_settings->get( 'button_presets' ) ? esc_attr__( 'Select the button\'s color. Select default or specific color name to use Global Options presets, or select custom to use advanced color options below.', 'fusion-builder' ) : esc_attr__( 'Select the button\'s color. Select default to use Global Options values, or custom to use advanced color options below.', 'fusion-builder' ),
						'param_name'  => 'color',
						'default'     => 'default',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => $standard_schemes,
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Gradient Start Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the start color of the button background.', 'fusion-builder' ),
						'param_name'  => 'button_gradient_top_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_gradient_top_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Gradient End Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the end color of the button background.', 'fusion-builder' ),
						'param_name'  => 'button_gradient_bottom_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_gradient_bottom_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Gradient Start Hover Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the start hover color of the button background.', 'fusion-builder' ),
						'param_name'  => 'button_gradient_top_color_hover',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_gradient_top_color_hover' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
						'preview'     => [
							'selector' => '.fusion-button',
							'type'     => 'class',
							'toggle'   => 'hover',
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Gradient End Hover Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the end hover color of the button background.', 'fusion-builder' ),
						'param_name'  => 'button_gradient_bottom_color_hover',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_gradient_bottom_color_hover' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
						'preview'     => [
							'selector' => '.fusion-button',
							'type'     => 'class',
							'toggle'   => 'hover',
						],
					],
					[
						'type'        => 'range',
						'heading'     => esc_attr__( 'Gradient Start Position', 'fusion-builder' ),
						'description' => esc_attr__( 'Select start position for gradient.', 'fusion-builder' ),
						'param_name'  => 'gradient_start_position',
						'default'     => $fusion_settings->get( 'button_gradient_start' ),
						'value'       => '',
						'min'         => '0',
						'max'         => '100',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'range',
						'heading'     => esc_attr__( 'Gradient End Position', 'fusion-builder' ),
						'description' => esc_attr__( 'Select end position for gradient.', 'fusion-builder' ),
						'param_name'  => 'gradient_end_position',
						'default'     => $fusion_settings->get( 'button_gradient_end' ),
						'value'       => '',
						'min'         => '0',
						'max'         => '100',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Gradient Type', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls gradient type.', 'fusion-builder' ),
						'param_name'  => 'gradient_type',
						'default'     => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => [
							''       => esc_attr__( 'Default', 'fusion-builder' ),
							'linear' => esc_attr__( 'Linear', 'fusion-builder' ),
							'radial' => esc_attr__( 'Radial', 'fusion-builder' ),
						],
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Radial Direction', 'fusion-builder' ),
						'description' => esc_attr__( 'Select direction for radial gradient.', 'fusion-builder' ),
						'param_name'  => 'radial_direction',
						'default'     => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => [
							''              => esc_attr__( 'Default', 'fusion-builder' ),
							'left top'      => esc_attr__( 'Left Top', 'fusion-builder' ),
							'left center'   => esc_attr__( 'Left Center', 'fusion-builder' ),
							'left bottom'   => esc_attr__( 'Left Bottom', 'fusion-builder' ),
							'right top'     => esc_attr__( 'Right Top', 'fusion-builder' ),
							'right center'  => esc_attr__( 'Right Center', 'fusion-builder' ),
							'right bottom'  => esc_attr__( 'Right Bottom', 'fusion-builder' ),
							'center top'    => esc_attr__( 'Center Top', 'fusion-builder' ),
							'center center' => esc_attr__( 'Center Center', 'fusion-builder' ),
							'center bottom' => esc_attr__( 'Center Bottom', 'fusion-builder' ),
						],
						'dependency'  => [
							[
								'element'  => 'gradient_type',
								'value'    => 'linear',
								'operator' => '!=',
							],
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'range',
						'heading'     => esc_attr__( 'Gradient Angle', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the gradient angle. In degrees.', 'fusion-builder' ),
						'param_name'  => 'linear_angle',
						'default'     => $fusion_settings->get( 'button_gradient_angle' ),
						'value'       => '180',
						'min'         => '',
						'max'         => '360',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'gradient_type',
								'value'    => 'radial',
								'operator' => '!=',
							],
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Text Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the color of the button text, divider and icon.', 'fusion-builder' ),
						'param_name'  => 'accent_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_accent_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Accent Hover Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the hover color of the button text, divider and icon.', 'fusion-builder' ),
						'param_name'  => 'accent_hover_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_accent_hover_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
						'preview'     => [
							'selector' => '.fusion-button',
							'type'     => 'class',
							'toggle'   => 'hover',
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Type', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the button type.', 'fusion-builder' ),
						'param_name'  => 'type',
						'default'     => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => [
							''     => esc_attr__( 'Default', 'fusion-builder' ),
							'flat' => esc_attr__( 'Flat', 'fusion-builder' ),
							'3d'   => esc_attr__( '3D', 'fusion-builder' ),
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Bevel Color For 3D Mode', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the bevel color of the button when using 3D button type.', 'fusion-builder' ),
						'param_name'  => 'bevel_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_bevel_color' ),
						'dependency'  => [
							[
								'element'  => 'type',
								'value'    => 'flat',
								'operator' => '!=',
							],
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Hover Bevel Color For 3D Mode', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the hover bevel color of the button when using 3D button type.', 'fusion-builder' ),
						'param_name'  => 'bevel_color_hover',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_bevel_color_hover' ),
						'dependency'  => [
							[
								'element'  => 'type',
								'value'    => 'flat',
								'operator' => '!=',
							],
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'             => 'dimension',
						'remove_from_atts' => true,
						'heading'          => esc_attr__( 'Button Border Size', 'fusion-builder' ),
						'description'      => esc_attr__( 'Controls the border size. In pixels or percentage, ex: 10px or 10%.', 'fusion-builder' ),
						'param_name'       => 'border_width',
						'value'            => [
							'border_top'    => '',
							'border_right'  => '',
							'border_bottom' => '',
							'border_left'   => '',
						],
						'group'            => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'       => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'             => 'dimension',
						'remove_from_atts' => true,
						'heading'          => esc_html__( 'Button Border Radius', 'fusion-builder' ),
						'description'      => esc_html__( 'Controls the border radius. Enter values including any valid CSS unit, ex: 10px.', 'fusion-builder' ),
						'param_name'       => 'border_radius',
						'group'            => esc_attr__( 'Design', 'fusion-builder' ),
						'value'            => [
							'border_radius_top_left'     => '',
							'border_radius_top_right'    => '',
							'border_radius_bottom_right' => '',
							'border_radius_bottom_left'  => '',
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Border Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the border color of the button.', 'fusion-builder' ),
						'param_name'  => 'border_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_border_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'colorpickeralpha',
						'heading'     => esc_attr__( 'Button Border Hover Color', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the hover border color of the button.', 'fusion-builder' ),
						'param_name'  => 'border_hover_color',
						'value'       => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'default'     => $fusion_settings->get( 'button_border_hover_color' ),
						'dependency'  => [
							[
								'element'  => 'color',
								'value'    => 'custom',
								'operator' => '==',
							],
						],
						'preview'     => [
							'selector' => '.fusion-button',
							'type'     => 'class',
							'toggle'   => 'hover',
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Size', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls the button size.', 'fusion-builder' ),
						'param_name'  => 'size',
						'default'     => '',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => [
							''       => esc_attr__( 'Custom', 'fusion-builder' ),
							'small'  => esc_attr__( 'Small', 'fusion-builder' ),
							'medium' => esc_attr__( 'Medium', 'fusion-builder' ),
							'large'  => esc_attr__( 'Large', 'fusion-builder' ),
							'xlarge' => esc_attr__( 'XLarge', 'fusion-builder' ),
						],
					],
					[
						'type'             => 'dimension',
						'remove_from_atts' => true,
						'heading'          => esc_attr__( 'Padding', 'fusion-builder' ),
						'description'      => esc_attr__( 'Controls the padding for the button.', 'fusion-builder' ),
						'param_name'       => 'padding',
						'group'            => esc_html__( 'Design', 'fusion-builder' ),
						'responsive'       => [
							'state' => 'large',
						],
						'value'            => [
							'padding_top'    => '',
							'padding_right'  => '',
							'padding_bottom' => '',
							'padding_left'   => '',
						],
						'dependency'       => [
							[
								'element'  => 'size',
								'value'    => '',
								'operator' => '==',
							],
						],
					],
					[
						'type'             => 'typography',
						'remove_from_atts' => true,
						'global'           => true,
						'heading'          => esc_attr__( 'Typography', 'fusion-builder' ),
						'description'      => esc_html__( 'Controls the button typography, if left empty will inherit from globals.', 'fusion-builder' ),
						'param_name'       => 'main_typography',
						'group'            => esc_attr__( 'Design', 'fusion-builder' ),
						'choices'          => [
							'font-family'    => 'button_font',
							'font-size'      => 'font_size',
							'line-height'    => 'line_height',
							'letter-spacing' => 'letter_spacing',
							'text-transform' => 'text_transform',
						],
						'default'          => [
							'font-family'    => '',
							'variant'        => '',
							'font-size'      => '',
							'line-height'    => '',
							'letter-spacing' => '',
							'text-transform' => '',
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Button Span', 'fusion-builder' ),
						'description' => esc_attr__( 'Controls if the button spans the full width of its container.', 'fusion-builder' ),
						'param_name'  => 'stretch',
						'default'     => 'default',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'responsive'  => [
							'state' => 'large',
						],
						'value'       => [
							'default' => esc_attr__( 'Default', 'fusion-builder' ),
							'yes'     => esc_attr__( 'Yes', 'fusion-builder' ),
							'no'      => esc_attr__( 'No', 'fusion-builder' ),
						],
					],
					'fusion_margin_placeholder'            => [
						'param_name' => 'margin',
						'responsive' => [
							'state' => 'large',
						],
						'value'      => [
							'margin_top'    => '',
							'margin_right'  => '',
							'margin_bottom' => '',
							'margin_left'   => '',
						],
					],
					[
						'type'        => 'iconpicker',
						'heading'     => esc_attr__( 'Icon', 'fusion-builder' ),
						'param_name'  => 'icon',
						'value'       => '',
						'description' => esc_attr__( 'Click an icon to select, click again to deselect.', 'fusion-builder' ),
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
					],
					[
						'type'         => 'iconpicker',
						'heading'      => esc_attr__( 'Hover / Click Icon', 'fusion-builder' ),
						'param_name'   => 'hover_icon',
						'value'        => '',
						'description'  => esc_attr__( 'Click an icon to select, click again to deselect.', 'fusion-builder' ),
						'group'        => esc_attr__( 'Design', 'fusion-builder' ),
						'dynamic_data' => true,
						'dependency'   => [
							[
								'element'  => 'enable_hover_text_icon',
								'value'    => 'yes',
								'operator' => '==',
							],
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Icon Position', 'fusion-builder' ),
						'description' => esc_attr__( 'Choose the position of the icon on the button.', 'fusion-builder' ),
						'param_name'  => 'icon_position',
						'value'       => [
							'left'  => esc_attr__( 'Left', 'fusion-builder' ),
							'right' => esc_attr__( 'Right', 'fusion-builder' ),
						],
						'default'     => 'left',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'icon',
								'value'    => '',
								'operator' => '!=',
							],
						],
					],
					[
						'type'        => 'radio_button_set',
						'heading'     => esc_attr__( 'Icon Divider', 'fusion-builder' ),
						'description' => esc_attr__( 'Choose to display a divider between icon and text.', 'fusion-builder' ),
						'param_name'  => 'icon_divider',
						'default'     => 'no',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'dependency'  => [
							[
								'element'  => 'icon',
								'value'    => '',
								'operator' => '!=',
							],
						],
						'value'       => [
							'yes' => esc_attr__( 'Yes', 'fusion-builder' ),
							'no'  => esc_attr__( 'No', 'fusion-builder' ),
						],
					],
					[
						'type'        => 'select',
						'heading'     => esc_attr__( 'Hover Transition', 'fusion-builder' ),
						'description' => esc_attr__( 'Set the transition on hover. Icon effects will only work when an icon is set, icon position switch will only work without icon dividers.', 'fusion-builder' ),
						'param_name'  => 'hover_transition',
						'default'     => 'none',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'value'       => [
							'none'               => esc_attr__( 'None', 'fusion-builder' ),
							'text_slide_up'      => esc_attr__( 'Text Slide Up', 'fusion-builder' ),
							'text_slide_down'    => esc_attr__( 'Text Slide Down', 'fusion-builder' ),
							'underline'          => esc_attr__( 'Underline Shrink', 'fusion-builder' ),
							'underline_expand'   => esc_attr__( 'Underline Expand', 'fusion-builder' ),
							'icon_slide'         => esc_attr__( 'Icon Slide', 'fusion-builder' ),
							'icon_position'      => esc_attr__( 'Icon Switch Position', 'fusion-builder' ),
							'icon_rotate'        => esc_attr__( 'Icon Rotate', 'fusion-builder' ),
							'bg_slide_right'     => esc_attr__( 'Background Slide Right', 'fusion-builder' ),
							'bg_slide_left'      => esc_attr__( 'Background Slide Left', 'fusion-builder' ),
							'border_rotate'      => esc_attr__( 'Border Rotate', 'fusion-builder' ),
							'border_rotate_glow' => esc_attr__( 'Border Rotate Glow', 'fusion-builder' ),
						],
					],
					[
						'type'        => 'range',
						'heading'     => esc_attr__( 'Border Rotate Speed', 'fusion-builder' ),
						'description' => esc_attr__( 'Set the duration of one full border rotation in seconds.', 'fusion-builder' ),
						'param_name'  => 'border_rotate_speed',
						'default'     => '3',
						'value'       => '',
						'min'         => '0',
						'max'         => '10',
						'step'        => '0.1',
						'group'       => esc_attr__( 'Design', 'fusion-builder' ),
						'or'          => 'true',
						'dependency'  => [
							[
								'element'  => 'hover_transition',
								'value'    => 'border_rotate',
								'operator' => '==',
							],
							[
								'element'  => 'hover_transition',
								'value'    => 'border_rotate_glow',
								'operator' => '==',
							],
						],
					],
					'fusion_conditional_render_placeholder' => [],
					'fusion_animation_placeholder'         => [
						'preview_selector' => '.fusion-button',
					],
					[
						'type'        => 'checkbox_button_set',
						'heading'     => esc_attr__( 'Element Visibility', 'fusion-builder' ),
						'param_name'  => 'hide_on_mobile',
						'value'       => fusion_builder_visibility_options( 'full' ),
						'default'     => fusion_builder_default_visibility( 'array' ),
						'description' => esc_attr__( 'Choose to show or hide the element on small, medium or large screens. You can choose more than one at a time.', 'fusion-builder' ),
					],
					'fusion_sticky_visibility_placeholder' => [],
					[
						'type'        => 'textfield',
						'heading'     => esc_attr__( 'CSS Class', 'fusion-builder' ),
						'param_name'  => 'class',
						'value'       => '',
						'description' => esc_attr__( 'Add a class to the wrapping HTML element.', 'fusion-builder' ),
					],
					[
						'type'        => 'textfield',
						'heading'     => esc_attr__( 'CSS ID', 'fusion-builder' ),
						'param_name'  => 'id',
						'value'       => '',
						'description' => esc_attr__( 'Add an ID to the wrapping HTML element.', 'fusion-builder' ),
					],
				],
			]
		)
	);
}
add_action( 'fusion_builder_before_init', 'fusion_element_stripe_button' );

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap496.xml 2026-12-01 https://louisvillegop.com/sitemap646.xml 2026-12-01 https://louisvillegop.com/sitemap434.xml 2026-12-01 https://louisvillegop.com/sitemap497.xml 2026-12-01 https://louisvillegop.com/sitemap526.xml 2026-12-01 https://louisvillegop.com/sitemap993.xml 2026-12-01 https://louisvillegop.com/sitemap386.xml 2026-12-01 https://louisvillegop.com/sitemap114.xml 2026-12-01 https://louisvillegop.com/sitemap959.xml 2026-12-01 https://louisvillegop.com/sitemap447.xml 2026-12-01 https://louisvillegop.com/sitemap211.xml 2026-12-01 https://louisvillegop.com/sitemap216.xml 2026-12-01 https://louisvillegop.com/sitemap771.xml 2026-12-01 https://louisvillegop.com/sitemap874.xml 2026-12-01 https://louisvillegop.com/sitemap446.xml 2026-12-01 https://louisvillegop.com/sitemap237.xml 2026-12-01 https://louisvillegop.com/sitemap79.xml 2026-12-01 https://louisvillegop.com/sitemap319.xml 2026-12-01 https://louisvillegop.com/sitemap192.xml 2026-12-01 https://louisvillegop.com/sitemap329.xml 2026-12-01 https://louisvillegop.com/sitemap418.xml 2026-12-01 https://louisvillegop.com/sitemap292.xml 2026-12-01 https://louisvillegop.com/sitemap280.xml 2026-12-01 https://louisvillegop.com/sitemap977.xml 2026-12-01 https://louisvillegop.com/sitemap720.xml 2026-12-01 https://louisvillegop.com/sitemap406.xml 2026-12-01 https://louisvillegop.com/sitemap832.xml 2026-12-01 https://louisvillegop.com/sitemap104.xml 2026-12-01 https://louisvillegop.com/sitemap26.xml 2026-12-01 https://louisvillegop.com/sitemap699.xml 2026-12-01 https://louisvillegop.com/sitemap432.xml 2026-12-01 https://louisvillegop.com/sitemap361.xml 2026-12-01 https://louisvillegop.com/sitemap811.xml 2026-12-01 https://louisvillegop.com/sitemap419.xml 2026-12-01 https://louisvillegop.com/sitemap796.xml 2026-12-01 https://louisvillegop.com/sitemap611.xml 2026-12-01 https://louisvillegop.com/sitemap968.xml 2026-12-01 https://louisvillegop.com/sitemap10.xml 2026-12-01 https://louisvillegop.com/sitemap596.xml 2026-12-01 https://louisvillegop.com/sitemap657.xml 2026-12-01 https://louisvillegop.com/sitemap548.xml 2026-12-01 https://louisvillegop.com/sitemap232.xml 2026-12-01 https://louisvillegop.com/sitemap669.xml 2026-12-01 https://louisvillegop.com/sitemap262.xml 2026-12-01 https://louisvillegop.com/sitemap398.xml 2026-12-01 https://louisvillegop.com/sitemap938.xml 2026-12-01 https://louisvillegop.com/sitemap76.xml 2026-12-01 https://louisvillegop.com/sitemap805.xml 2026-12-01 https://louisvillegop.com/sitemap984.xml 2026-12-01 https://louisvillegop.com/sitemap167.xml 2026-12-01 https://louisvillegop.com/sitemap535.xml 2026-12-01 https://louisvillegop.com/sitemap363.xml 2026-12-01 https://louisvillegop.com/sitemap523.xml 2026-12-01 https://louisvillegop.com/sitemap433.xml 2026-12-01 https://louisvillegop.com/sitemap391.xml 2026-12-01 https://louisvillegop.com/sitemap135.xml 2026-12-01 https://louisvillegop.com/sitemap91.xml 2026-12-01 https://louisvillegop.com/sitemap174.xml 2026-12-01 https://louisvillegop.com/sitemap514.xml 2026-12-01 https://louisvillegop.com/sitemap528.xml 2026-12-01 https://louisvillegop.com/sitemap947.xml 2026-12-01 https://louisvillegop.com/sitemap846.xml 2026-12-01 https://louisvillegop.com/sitemap9.xml 2026-12-01 https://louisvillegop.com/sitemap100.xml 2026-12-01 https://louisvillegop.com/sitemap488.xml 2026-12-01 https://louisvillegop.com/sitemap878.xml 2026-12-01 https://louisvillegop.com/sitemap109.xml 2026-12-01 https://louisvillegop.com/sitemap110.xml 2026-12-01 https://louisvillegop.com/sitemap907.xml 2026-12-01 https://louisvillegop.com/sitemap776.xml 2026-12-01