JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
namespace WPForms\Integrations\Stripe\Fields;
use WPForms_Field;
use WPForms\Integrations\Stripe\Fields\Traits\CreditCard;
/**
* Stripe Payment element credit card field.
*
* @since 1.8.2
*/
class PaymentElementCreditCard extends WPForms_Field {
use CreditCard;
/**
* Field preview CVC icon SVG code.
*
* @since 1.8.2
*/
const FIELD_PREVIEW_CVC_ICON_SVG = '<svg width="24" height="24" viewBox="0 0 24 24"><path opacity=".2" fill-rule="evenodd" clip-rule="evenodd" d="M15.337 4A5.493 5.493 0 0013 8.5c0 1.33.472 2.55 1.257 3.5H4a1 1 0 00-1 1v1a1 1 0 001 1h16a1 1 0 001-1v-.6a5.526 5.526 0 002-1.737V18a2 2 0 01-2 2H3a2 2 0 01-2-2V6a2 2 0 012-2h12.337zm6.707.293c.239.202.46.424.662.663a2.01 2.01 0 00-.662-.663z"></path><path opacity=".4" fill-rule="evenodd" clip-rule="evenodd" d="M13.6 6a5.477 5.477 0 00-.578 3H1V6h12.6z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M18.5 14a5.5 5.5 0 110-11 5.5 5.5 0 010 11zm-2.184-7.779h-.621l-1.516.77v.786l1.202-.628v3.63h.943V6.22h-.008zm1.807.629c.448 0 .762.251.762.613 0 .393-.37.668-.904.668h-.235v.668h.283c.565 0 .95.282.95.691 0 .393-.377.66-.911.66-.393 0-.786-.126-1.194-.37v.786c.44.189.88.291 1.312.291 1.029 0 1.736-.526 1.736-1.288 0-.535-.33-.967-.88-1.14.472-.157.778-.573.778-1.045 0-.738-.652-1.241-1.595-1.241a3.143 3.143 0 00-1.234.267v.77c.378-.212.763-.33 1.132-.33zm3.394 1.713c.574 0 .974.338.974.778 0 .463-.4.785-.974.785-.346 0-.707-.11-1.076-.337v.809c.385.173.778.26 1.163.26.204 0 .392-.032.573-.08a4.313 4.313 0 00.644-2.262l-.015-.33a1.807 1.807 0 00-.967-.252 3 3 0 00-.448.032V6.944h1.132a4.423 4.423 0 00-.362-.723h-1.587v2.475a3.9 3.9 0 01.943-.133z"></path></svg>';
/**
* Define additional field properties.
*
* @since 1.8.2
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array
*/
public function field_properties( $properties, $field, $form_data ) {
// Save form data for future usage in the class.
$this->form_data = $form_data;
unset( $properties['label']['attr']['for'] );
return $properties;
}
/**
* Advanced section field options.
*
* @since 1.8.2
*
* @param array $field Field settings.
*/
protected function advanced_options( $field ) {
// Link Email field map.
$output = $this->field_element(
'label',
$field,
[
'slug' => 'link_email',
'value' => esc_html__( 'Link Email', 'wpforms-lite' ),
'tooltip' => esc_html__( 'Select an Email field to autofill your customers’ payment information using Link.', 'wpforms-lite' ),
],
false
);
$output .= $this->field_element(
'select',
$field,
[
'slug' => 'link_email',
'value' => ! empty( $field['link_email'] ) ? esc_attr( $field['link_email'] ) : '',
'options' => $this->get_email_field_options(),
'class' => 'wpforms-field-map-select',
'data' => [
'field-map-allowed' => 'email',
'field-map-placeholder' => esc_attr__( 'Stripe Credit Card Email', 'wpforms-lite' ),
],
],
false
);
$this->field_element(
'row',
$field,
[
'slug' => 'link_email',
'content' => $output,
]
);
$output = $this->field_element(
'label',
$field,
[
'slug' => 'sublabel_position',
'value' => esc_html__( 'Sublabel Position', 'wpforms-lite' ),
],
false
);
$output .= $this->field_element(
'select',
$field,
[
'slug' => 'sublabel_position',
'value' => ! empty( $field['sublabel_position'] ) ? esc_attr( $field['sublabel_position'] ) : '',
'options' => [
'above' => esc_html__( 'Above', 'wpforms-lite' ),
'floating' => esc_html__( 'Floating', 'wpforms-lite' ),
],
],
false
);
$this->field_element(
'row',
$field,
[
'slug' => 'sublabel_position',
'content' => $output,
]
);
}
/**
* Array of available form email fields.
*
* @since 1.8.2
*
* @return array
*/
private function get_email_field_options() {
$fields = [ '' => esc_html__( 'Stripe Credit Card Email', 'wpforms-lite' ) ];
$email_options = wpforms_get_form_fields( $this->form_data, [ 'email' ] );
if ( empty( $email_options ) ) {
return $fields;
}
foreach ( $email_options as $id => $email_option ) {
$fields[ $id ] = ! empty( $email_option['label'] )
? esc_attr( $email_option['label'] )
: sprintf( /* translators: %d - field ID. */
esc_html__( 'Field #%d', 'wpforms-lite' ),
absint( $id )
);
}
return $fields;
}
/**
* Field preview inside the builder.
*
* @since 1.8.2
*
* @param array $field Field settings.
*/
public function field_preview( $field ) {
// Label.
$this->field_preview_option( 'label', $field );
$sublabels = $this->get_sublabels();
$sublabel_position = ! empty( $field['sublabel_position'] ) ? $field['sublabel_position'] : 'above';
$hide_link_email = ! empty( $field['link_email'] ) ? 'wpforms-hidden' : '';
?>
<div class="format-selected wpforms-stripe-payment-element <?php echo esc_attr( $sublabel_position ); ?>">
<div class="wpforms-field-row wpforms-stripe-link-email <?php echo esc_attr( $hide_link_email ); ?>">
<?php $this->input_preview( $sublabels['email'] ); ?>
</div>
<div class="wpforms-field-row">
<?php $this->input_preview( $sublabels['number'] ); ?>
<div class="wpforms-stripe-cardnumber-pics"></div>
</div>
<div class="wpforms-field-row">
<div class="wpforms-one-half">
<?php $this->input_preview( $sublabels['exp'] ); ?>
</div>
<div class="wpforms-one-half last wpforms-stripe-cvc">
<?php $this->input_preview( $sublabels['cvv'] ); ?>
<?php echo self::FIELD_PREVIEW_CVC_ICON_SVG; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
<div class="wpforms-field-row">
<label class="wpforms-sub-label"><?php echo esc_attr( $sublabels['country'] ); ?></label>
<?php $this->get_country_dropdown_preview( $field ); ?>
</div>
</div>
<?php
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Input preview html output.
*
* @since 1.8.2
*
* @param string $label Label text.
*/
private function input_preview( $label ) {
echo '<label class="wpforms-sub-label">' . esc_html( $label ) . '</label>';
echo '<input type="text" placeholder="' . esc_attr( $label ) . '" readonly>';
}
/**
* Get Sublabels strings.
*
* @since 1.8.2
*
* @return array
*/
private function get_sublabels() {
return [
'email' => __( 'Email', 'wpforms-lite' ),
'number' => __( 'Card Number', 'wpforms-lite' ),
'exp' => __( 'Expiration', 'wpforms-lite' ),
'cvv' => __( 'CVC', 'wpforms-lite' ),
'country' => __( 'Country', 'wpforms-lite' ),
];
}
/**
* Get Country dropdown preview.
*
* @since 1.8.2
*
* @param array $field Field settings.
*/
private function get_country_dropdown_preview( $field ) {
$display_label = ! empty( $field['sublabel_position'] ) && $field['sublabel_position'] === 'above';
$sublabels = $this->get_sublabels();
echo '<select readonly>';
echo '<option value="empty" ' . selected( $display_label, true, false ) . '></option>';
echo '<option value="country" ' . selected( ! $display_label, true, false ) . '>';
echo esc_attr( $sublabels['country'] );
echo '</option>';
echo '</select>';
}
/**
* Block editor field preview.
*
* @since 1.8.2
*
* @param array $field Field settings.
*/
private function block_editor_field_display( $field ) {
$hide_sub_label = ! empty( $field['sublabel_hide'] );
$sublabel_position = ! empty( $field['sublabel_position'] ) ? $field['sublabel_position'] : 'above';
$field_class = 'wpforms-field-row wpforms-field-row-responsive wpforms-field-' . sanitize_html_class( $field['size'] );
$no_columns_class = 'wpforms-field-row wpforms-no-columns wpforms-field-' . sanitize_html_class( $field['size'] );
$sublabels = $this->get_sublabels();
?>
<div class="format-selected wpforms-stripe-payment-element">
<?php if ( empty( $field['link_email'] ) ) : ?>
<div class="<?php echo esc_attr( $no_columns_class ); ?> ">
<?php $this->block_editor_input_preview( $sublabels['email'], $sublabel_position, $hide_sub_label ); ?>
</div>
<?php endif; ?>
<div class="<?php echo esc_attr( $no_columns_class ); ?>">
<?php $this->block_editor_input_preview( $sublabels['number'], $sublabel_position, $hide_sub_label, '1234 1234 1234 1234' ); ?>
<div class="wpforms-stripe-payment-element-cardnumber-preview"></div>
</div>
<div class="<?php echo esc_attr( $field_class ); ?>">
<div class="wpforms-field-row-block wpforms-one-half wpforms-first">
<?php $this->block_editor_input_preview( $sublabels['exp'], $sublabel_position, $hide_sub_label, 'MM / YY' ); ?>
</div>
<div class="wpforms-field-row-block wpforms-one-half wpforms-stripe-payment-element-cvc-preview">
<?php $this->block_editor_input_preview( $sublabels['cvv'], $sublabel_position, $hide_sub_label, 'CVC' ); ?>
<?php echo self::FIELD_PREVIEW_CVC_ICON_SVG; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
<div class="<?php echo esc_attr( $no_columns_class ); ?>">
<?php if ( $sublabel_position === 'above' && ! $hide_sub_label ) : ?>
<label class="wpforms-field-sublabel before"><?php echo esc_attr( $sublabels['country'] ); ?></label>
<?php endif; ?>
<?php $this->get_country_dropdown_preview( $field ); ?>
</div>
</div>
<?php
}
/**
* Get block editor input preview html.
*
* @since 1.8.2
*
* @param string $label Label text.
* @param string $position Label Position.
* @param bool $hide Hide label.
* @param string $placeholder Placeholder text.
*/
private function block_editor_input_preview( $label, $position, $hide, $placeholder = '' ) {
if ( $hide ) {
echo '<input type="text" readonly placeholder="' . esc_attr( $placeholder ) . '">';
return;
}
if ( $position === 'above' ) {
echo '<label class="wpforms-field-sublabel before">' . esc_html( $label ) . '</label><input type="text" readonly placeholder="' . esc_attr( $placeholder ) . '">';
return;
}
echo '<input type="text" readonly placeholder="' . esc_attr( $label ) . '">';
}
/**
* Field display on the form front-end.
*
* @since 1.8.2
*
* @param array $field Field data and settings.
* @param array $deprecated Deprecated field attributes. Use field properties.
* @param array $form_data Form data and settings.
*/
public function field_display( $field, $deprecated, $form_data ) {
if ( $this->field_display_errors( $form_data ) ) {
return;
}
if ( wpforms_is_editor_page() ) {
$this->block_editor_field_display( $field );
return;
}
$form_id = absint( $form_data['id'] );
$hide_sub_label = ! empty( $field['sublabel_hide'] ) ? 'wpforms-sublabel-hide' : '';
$sublabel_position = ! empty( $field['sublabel_position'] ) ? $field['sublabel_position'] : 'above';
$link_email = ! empty( $field['link_email'] ) ? $field['link_email'] : '';
// Row wrapper.
echo '<div class="wpforms-field-row wpforms-no-columns wpforms-field-' . sanitize_html_class( $field['size'] ) . ' ' . sanitize_html_class( $hide_sub_label ) . '" data-sublabel-position="' . esc_attr( $sublabel_position ) . '" data-link-email="' . esc_attr( $link_email ) . '" data-required="' . (int) ! empty( $field['required'] ) . '">';
if ( ! $link_email ) {
echo '<div id="wpforms-field-stripe-link-element-' . absint( $form_id ) . '"></div>';
}
echo '<div id="wpforms-field-stripe-payment-element-' . absint( $form_id ) . '"></div>';
echo '<input type="text" class="wpforms-stripe-credit-card-hidden-input" name="wpforms[stripe-credit-card-hidden-input-' . absint( $form_data['id'] ) . ']" disabled style="display: none;">';
echo '</div>';
}
}