Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions classes/views/shared/payment-connect-mode-box.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( 'You are not allowed to call this page directly.' );
}

/**
* Shared view for a payment gateway connect mode box (Live / Test).
*
* Required variables:
* @var string $mode 'live' or 'test'.
* @var bool $connected Whether the gateway is connected for this mode.
* @var string $column_class CSS grid column class (e.g. 'frm4', 'frm6').
* @var string $gateway_slug Gateway identifier (e.g. 'paypal', 'square').
* Used to build the connect button class
* (frm-connect-{slug}-with-oauth) and the
* disconnect anchor id (frm_disconnect_{slug}_{mode}).
* @var string $icon_font_class Font class for the checkmark icon (e.g. 'frmfont', 'frm_icon_font').
* @var callable|null $extra_content_callback Optional callback invoked between the description
* and the action button. Receives $mode as its only arg.
*/

$tag_classes = $connected ? 'frm-lt-green-tag' : 'frm-grey-tag';
?>
<div class="frm-card-item <?php echo esc_attr( $column_class ); ?>">
<div class="frm-flex-col" style="width: 100%;">
<div>
<span style="font-size: var(--text-lg); font-weight: 500; margin-right: 5px;">
<?php echo 'test' === $mode ? esc_html__( 'Test', 'formidable' ) : esc_html__( 'Live', 'formidable' ); ?>
</span>
<div class="frm-meta-tag <?php echo esc_attr( $tag_classes ); ?>" style="font-size: var(--text-sm); font-weight: 600;">
<?php
if ( $connected ) {
FrmAppHelper::icon_by_class( $icon_font_class . ' frm_checkmark_icon', array( 'style' => 'width: 10px; position: relative; top: 2px; margin-right: 5px;' ) );
esc_html_e( 'Connected', 'formidable' );
} else {
esc_html_e( 'Not configured', 'formidable' );
}
?>
</div>
</div>
<div style="margin-top: 5px; flex: 1;">
<?php
if ( 'live' === $mode ) {
esc_html_e( 'Live version to process real customer transactions', 'formidable' );
} else {
esc_html_e( 'Simulate payments and ensure everything works smoothly before going live.', 'formidable' );
}
?>
</div>
<?php
if ( is_callable( $extra_content_callback ) ) {
$extra_content_callback( $mode );
}
?>
<div class="frm-card-bottom">
<?php if ( $connected ) { ?>
<a id="frm_disconnect_<?php echo esc_attr( $gateway_slug . '_' . $mode ); ?>" class="button-secondary frm-button-secondary" href="#">
<?php esc_html_e( 'Disconnect', 'formidable' ); ?>
</a>
<?php } else { ?>
<a class="frm-connect-<?php echo esc_attr( $gateway_slug ); ?>-with-oauth button-secondary frm-button-secondary" data-mode="<?php echo esc_attr( $mode ); ?>" href="#">
<?php esc_html_e( 'Connect', 'formidable' ); ?>
</a>
<?php } ?>
</div>
</div>
</div>
8 changes: 6 additions & 2 deletions paypal/helpers/FrmPayPalLiteConnectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,12 @@ private static function render_error( $message, $email = '', $merchant_id = '' )
* @return void
*/
public static function render_settings_for_mode( $mode ) {
$connected = (bool) self::get_merchant_id( $mode );
include FrmPayPalLiteAppHelper::plugin_path() . '/views/settings/connect-settings-box.php';
$connected = (bool) self::get_merchant_id( $mode );
$column_class = 'frm6';
$gateway_slug = 'paypal';
$icon_font_class = 'frm_icon_font';
$extra_content_callback = array( 'FrmPayPalLiteConnectHelper', 'render_seller_status_placeholder' );
include FrmAppHelper::plugin_path() . '/classes/views/shared/payment-connect-mode-box.php';
}

/**
Expand Down
47 changes: 0 additions & 47 deletions paypal/views/settings/connect-settings-box.php

This file was deleted.

56 changes: 6 additions & 50 deletions square/helpers/FrmSquareLiteConnectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,56 +69,12 @@ public static function render_settings_container() {
* @return void
*/
private static function render_settings_for_mode( $mode ) {
// phpcs:disable Generic.WhiteSpace.ScopeIndent
?>
<div class="frm-card-item frm4">
<div class="frm-flex-col" style="width: 100%;">
<div>
<span style="font-size: var(--text-lg); font-weight: 500; margin-right: 5px;">
<?php
echo $mode === 'test' ? esc_html__( 'Test', 'formidable' ) : esc_html__( 'Live', 'formidable' );
?>
</span>
<?php

$connected = (bool) self::get_merchant_id( $mode );
$tag_classes = $connected ? 'frm-lt-green-tag' : 'frm-grey-tag';
?>
<div class="frm-meta-tag <?php echo esc_attr( $tag_classes ); ?>" style="font-size: var(--text-sm); font-weight: 600;">
<?php
if ( $connected ) {
FrmAppHelper::icon_by_class( 'frmfont frm_checkmark_icon', array( 'style' => 'width: 10px; position: relative; top: 2px; margin-right: 5px;' ) );
echo 'Connected';
} else {
echo 'Not configured';
}
?>
</div>
</div>
<div style="margin-top: 5px; flex: 1;">
<?php
if ( 'live' === $mode ) {
esc_html_e( 'Live version to process real customer transactions', 'formidable' );
} else {
esc_html_e( 'Simulate payments and ensure everything works smoothly before going live.', 'formidable' );
}
?>
</div>
<div class="frm-card-bottom">
<?php if ( $connected ) { ?>
<a id="frm_disconnect_square_<?php echo esc_attr( $mode ); ?>" class="button-secondary frm-button-secondary" href="#">
<?php esc_html_e( 'Disconnect', 'formidable' ); ?>
</a>
<?php } else { ?>
<a class="frm-connect-square-with-oauth button-secondary frm-button-secondary" data-mode="<?php echo esc_attr( $mode ); ?>" href="#">
<?php esc_html_e( 'Connect', 'formidable' ); ?>
</a>
<?php } ?>
</div>
</div>
</div>
<?php
// phpcs:enable Generic.WhiteSpace.ScopeIndent
$connected = (bool) self::get_merchant_id( $mode );
$column_class = 'frm4';
$gateway_slug = 'square';
$icon_font_class = 'frmfont';
$extra_content_callback = null;
include FrmAppHelper::plugin_path() . '/classes/views/shared/payment-connect-mode-box.php';
}

/**
Expand Down
Loading