Skip to content
Merged
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
1 change: 1 addition & 0 deletions assets/js/paybutton-paywall-cashtab-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function renderLoginPaybutton() {
successText: 'Login Successful!',
autoClose: true,
opReturn: 'login',
apiBaseUrl: PaywallAjax.apiBaseUrl,
onSuccess: function (tx) {
paymentInitiated = true;
loginAddr = tx?.inputAddresses?.[0] ?? null;
Expand Down
4 changes: 2 additions & 2 deletions assets/js/paybutton.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/js/paywalled-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jQuery(document).ready(function($) {
theme: configData.theme,
opReturn: configData.opReturn, // carries postID
autoClose: configData.autoClose,
apiBaseUrl: configData.apiBaseUrl,

onSuccess: function (tx) {
paymentInitiated = true;
Expand Down
10 changes: 9 additions & 1 deletion includes/class-paybutton-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ public function process_settings_forms() {
$public_key = sanitize_text_field(
wp_unslash( $_POST['paybutton_public_key'] )
);
$api_base_url = isset( $_POST['paybutton_api_base_url'] )
? esc_url_raw( wp_unslash( $_POST['paybutton_api_base_url'] ) )
: '';
if ( empty( $api_base_url ) ) {
$api_base_url = 'https://paybutton.org';
}
update_option( 'paybutton_public_key', $public_key );
update_option( 'paybutton_api_base_url', $api_base_url );
wp_safe_redirect(
admin_url( 'admin.php?page=paybutton-settings&settings-updated=true' )
);
Expand Down Expand Up @@ -191,7 +198,7 @@ public function enqueue_admin_scripts( $hook_suffix ) {
'paybutton-core',
PAYBUTTON_PLUGIN_URL . 'assets/js/paybutton.js',
array('address-validator'),
'5.0.2',
'5.3.0',
true
);

Expand Down Expand Up @@ -296,6 +303,7 @@ public function settings_page() {

$args = array(
'paybutton_public_key' => get_option( 'paybutton_public_key', '' ),
'paybutton_api_base_url' => get_option( 'paybutton_api_base_url', 'https://paybutton.org' ),
'settings_saved' => isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] === 'true',
);

Expand Down
10 changes: 6 additions & 4 deletions includes/class-paybutton-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function enqueue_public_assets() {
'paybutton-core',
PAYBUTTON_PLUGIN_URL . 'assets/js/paybutton.js', // Local file path
array(),
'5.0.2',
'5.3.0',
false
);

Expand Down Expand Up @@ -126,6 +126,7 @@ public function enqueue_public_assets() {
'userAddress' => sanitize_text_field( PayButton_State::get_address() ),
'defaultAddress' => get_option( 'paybutton_admin_wallet_address', '' ),
'scrollToUnlocked' => get_option( 'paybutton_scroll_to_unlocked', '1' ),
'apiBaseUrl' => get_option( 'paybutton_api_base_url', 'https://paybutton.org' ),
) );
}

Expand All @@ -141,7 +142,7 @@ public function paybutton_generator_shortcode( $atts, $content = null ) {
}

// Encode the config for a data attribute
$encodedConfig = wp_json_encode( $decoded );
$encodedConfig = wp_json_encode( $decoded, JSON_UNESCAPED_SLASHES );

ob_start();
?>
Expand Down Expand Up @@ -237,7 +238,8 @@ public function paybutton_paywall_shortcode( $atts, $content = null ) {
),
),
'opReturn' => (string) $post_id, //This is a hack to give the PB server the post ID to send it back to WP's DB
'autoClose' => true
'autoClose' => true,
'apiBaseUrl' => get_option( 'paybutton_api_base_url', 'https://paybutton.org' )
);

//NEW: If the admin enabled “Show Unlock Count on Front‐end,” and this post is NOT yet unlocked then display unlock count on the front end.
Expand Down Expand Up @@ -272,7 +274,7 @@ public function paybutton_paywall_shortcode( $atts, $content = null ) {
<?php echo wp_kses_post($unlock_label_html) ?>
<div id="paybutton-container-<?php echo esc_attr( $post_id ); ?>"
class="paybutton-container"
data-config="<?php echo esc_attr( json_encode( $config ) ); ?>"
data-config="<?php echo esc_attr( wp_json_encode( $config, JSON_UNESCAPED_SLASHES ) ); ?>"
style="text-align: center;"></div>
</div>
<?php
Expand Down
5 changes: 3 additions & 2 deletions includes/woocommerce/class-wc-gateway-paybutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ public function thankyou_page( $order_id ) {
'opReturn' => (string) $order_id,
'successText' => 'Payment Received! Processing...',
'autoClose' => true,
'size' => 'xl'
'size' => 'xl',
'apiBaseUrl' => get_option( 'paybutton_api_base_url', 'https://paybutton.org' ),
);

echo '<h2>Complete your payment</h2>';
echo '<div class="paybutton-woo-container" data-config="' . esc_attr( wp_json_encode( $config ) ) . '" style="margin: 20px 0;"></div>';
echo '<div class="paybutton-woo-container" data-config="' . esc_attr( wp_json_encode( $config, JSON_UNESCAPED_SLASHES ) ) . '" style="margin: 20px 0;"></div>';
}

/**
Expand Down
18 changes: 18 additions & 0 deletions templates/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ class="regular-text"
</td>
</tr>

<tr>
<th scope="row">
<label for="paybutton_api_base_url">API Base URL (required)</label>
</th>
<td>
<input
type="url"
name="paybutton_api_base_url"
id="paybutton_api_base_url"
class="regular-text"
value="<?php echo esc_attr( $paybutton_api_base_url ); ?>"
required
>
<p class="description">
The API Base URL parameter specifies the URL for the API where information about new transactions, prices, and addresses will come from. Default is <code>https://paybutton.org</code>.
</p>
</td>
</tr>
</table>

<p class="submit">
Expand Down