Skip to content

Commit

Permalink
Merge pull request #1389 from laterpay/develop
Browse files Browse the repository at this point in the history
Tag 2.9.3
  • Loading branch information
thrijith authored Mar 19, 2020
2 parents 7a97108 + 53dc5c7 commit 134db3f
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 150 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "laterpay/laterpay-wordpress-plugin",
"description": "This is the official LaterPay plugin for selling digital content with WordPress",
"license": "MIT",
"version": "2.9.2",
"version": "2.9.3",
"config": {
"vendor-dir": "laterpay/vendor",
"secure-http": true
Expand Down
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var gulp = require('gulp'),
// OPTIONS -------------------------------------------------------------------------------------------------------------
var gulpKnownOptions = {
string: 'version',
default: { version: '2.9.2' }
default: { version: '2.9.3' }
};
var gulpOptions = minimist(process.argv.slice(2), gulpKnownOptions);
gulpOptions.svn = {};
Expand Down
10 changes: 7 additions & 3 deletions laterpay/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tags: contribution, conversion, earn-money, micropayment, monetization, monetize
Requires at least: 4.6
Tested up to: 5.3.2
Requires PHP: 5.6
Stable tag: 2.9.2
Stable tag: 2.9.3
Author URI: https://laterpay.net
Plugin URI: https://github.com/laterpay/laterpay-wordpress-plugin
License: MIT
Expand Down Expand Up @@ -90,6 +90,10 @@ Yes!
7. The plugin provides a variety of advanced settings to customize the LaterPay plugin and adjust it to your needs.

== Changelog ==
= 2.9.3 ( March 19, 2020 ) =
* Lower Pay Now limit from 1.49€ to 1.00€ for EU region.
* Reduce unnecessary API request to `validatesignature` endpoint.

= 2.9.2 ( January 22, 2020 ) =
* Fix voucher price validation in "LaterPay > Paywall" tab.

Expand Down Expand Up @@ -702,8 +706,8 @@ KNOWN BUGS:

== Upgrade notice ==

= 2.9.2 =
Fixes voucher price validation in "LaterPay > Paywall" tab.
= 2.9.3 =
Reduces unnecessary API call to `validatesignature` endpoint.

== Arbitrary section ==

Expand Down
2 changes: 1 addition & 1 deletion laterpay/application/Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ protected function render_add_edit_post_page_help() {
<strong>Pay Now</strong><br>
If you sell your content as <strong>Pay Now</strong>, a user has to <strong>log in</strong> to LaterPay and <strong>pay</strong> for your content <strong>immediately</strong>.<br>
Pay Now are especially suitable for higher-value content and / or content that immediately occasions costs (e. g. license fees for a video stream).<br>
Pay Now are possible for prices between (including) <strong>1.49 € (in Europe) / $ 1.99 (in the U.S.)</strong> and (including) <strong>149.99</strong>.
Pay Now are possible for prices between (including) <strong>1.00 € (in Europe) / $ 1.99 (in the U.S.)</strong> and (including) <strong>149.99</strong>.
</p>', 'laterpay'
),
) );
Expand Down
28 changes: 0 additions & 28 deletions laterpay/application/Controller/Admin/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,32 +512,4 @@ private function get_client_instance_for_config( $api_root = '', $web_root = ''

return $client;
}

/**
* Get a client instance based on current region and set plugin mode to test.
*/
public static function validate_current_credentials() {

// Get current client options, and new client instance.
$client_options = LaterPay_Helper_Config::get_php_client_options();
$client = new LaterPay_Client(
$client_options['cp_key'],
$client_options['api_key'],
$client_options['api_root'],
$client_options['web_root'],
$client_options['token_name']
);

// Check if current config is valid or not.
$response = json_decode( $client->check_health( true ), true );

// Change plugin mode to test.
if ( false === $response['is_valid'] ) {
update_option( 'laterpay_plugin_is_in_live_mode', '0' );
return false;
}

return true;
}

}
4 changes: 2 additions & 2 deletions laterpay/application/Controller/Admin/Pricing.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function load_assets() {
'confirmDeleteSubscription' => __( 'Do you really want to discontinue this subscription? If you delete it, it will continue to renew for users who have an active subscription until the user cancels it. Existing subscribers will still have access to the content in their subscription. New users won\'t be able to buy the subscription anymore. Do you want to delete this subscription?', 'laterpay' ),
'voucherText' => __( 'reduces the price to', 'laterpay' ),
'payLaterToolTip' => esc_html__( 'Pay Later allows users to gain access now by committing to pay once their invoice reaches $5 or 5€; it is available for posts with pricing between 0.05 and 5.00', 'laterpay' ),
'payNowToolTip' => esc_html__( 'Pay Now requires users pay for purchased content immediately; available for posts with pricing above $1.99 or 1.49', 'laterpay' ),
'subVoucherMinimum' => esc_html__( 'Subscriptions, like other Pay Now content, must have pricing above $1.99 or 1.49', 'laterpay' ),
'payNowToolTip' => esc_html__( 'Pay Now requires users pay for purchased content immediately; available for posts with pricing above $1.99 or 1.00', 'laterpay' ),
'subVoucherMinimum' => esc_html__( 'Subscriptions, like other Pay Now content, must have pricing above $1.99 or 1.00', 'laterpay' ),
'subVoucherMaximumPrice' => esc_html__( 'The voucher price must be less than or equal to the subscription price.', 'laterpay' ),
'tpVoucherMaximumPrice' => esc_html__( 'The voucher price must be less than or equal to the time pass price.', 'laterpay' ),
'codeTooShort' => esc_html__( 'Please enter a six-digit voucher code.', 'laterpay' ),
Expand Down
1 change: 0 additions & 1 deletion laterpay/application/Controller/Frontend/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static function get_subscribed_events() {
return array(
'laterpay_post_content' => array(
array( 'laterpay_on_plugin_is_working', 250 ),
array( 'laterpay_on_valid_account_credential', 200 ),
array( 'modify_post_content' ),
),
'laterpay_posts' => array(
Expand Down
17 changes: 15 additions & 2 deletions laterpay/application/Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class LaterPay_Helper_Config {
'limits' => array(
'default' => array(
'ppu_min' => 0.05,
'ppu_only_limit' => 1.48,
'ppu_only_limit' => 0.99,
'ppu_max' => 5.00,
'sis_min' => 1.49,
'sis_min' => 1.00,
'sis_only_limit' => 5.00,
'sis_max' => 1000.00
)
Expand Down Expand Up @@ -387,12 +387,20 @@ public static function erase_plugin_data() {
delete_option( 'laterpay_api_fallback_behavior' );
delete_option( 'laterpay_api_enabled_on_homepage' );

// Delete GA related configurations.
delete_option( 'laterpay_user_tracking_data' );
delete_option( 'laterpay_tracking_data' );

// Delete appearance config.
delete_option( 'laterpay_main_color' );
delete_option( 'laterpay_hover_color' );
delete_option( 'laterpay_overlay_header_bg_color' );
delete_option( 'laterpay_overlay_header_title' );
delete_option( 'laterpay_overlay_main_bg_color' );
delete_option( 'laterpay_overlay_main_text_color' );
delete_option( 'laterpay_overlay_description_color' );
delete_option( 'laterpay_overlay_button_bg_color' );
delete_option( 'laterpay_overlay_button_hover_color' );
delete_option( 'laterpay_overlay_button_hover_text_color' );
delete_option( 'laterpay_overlay_button_text_color' );
delete_option( 'laterpay_overlay_link_main_color' );
Expand All @@ -406,11 +414,16 @@ public static function erase_plugin_data() {
delete_option( 'laterpay_show_cache_msg' );
delete_option( 'lp_tabular_info' );
delete_option( 'lp_custom_overlay_options' );
delete_option( 'laterpay_overlay_show_footer' );
delete_option( 'laterpay_global_voucher_codes' );
delete_option( 'laterpay_plugin_version' );
delete_option( 'lp_custom_overlay_options' );
delete_option( 'lp_wisdom_tracking_info' );

// Delete internal counters for time pass and subscription.
delete_option( 'lp_pass_count' );
delete_option( 'lp_sub_count' );

// unset wisdom tracking data.
LaterPay_Controller_Admin_Advanced::unset_wisdom_tracking_info();

Expand Down
2 changes: 1 addition & 1 deletion laterpay/application/Helper/Pricing.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public static function get_dynamic_prices( WP_Post $post, $price = null ) {
// Single Sale (sis), if price >= 5.01
$end_price = $currency['sis_only_limit'];
} elseif ( $post_price >= $currency['sis_min'] ) {
// Single Sale or Pay-per-Use, if 1.49 >= price <= 5.00
// Single Sale or Pay-per-Use, if 1.00 >= price <= 5.00
$end_price = $currency['sis_min'];
} else {
// Pay-per-Use (ppu), if price <= 1.48
Expand Down
18 changes: 17 additions & 1 deletion laterpay/application/Helper/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,24 @@ public static function laterpay_api_get_access( $article_ids, $product_key = nul

$result = $client->get_access($article_ids, $product_key);

// Check if current config is valid or not.
$health_check = json_decode( $client->check_health( true ), true );

// Change plugin mode to test, if invalid account configuration.
if ( false === $health_check['is_valid'] ) {
// Activate test mode.
update_option( 'laterpay_plugin_is_in_live_mode', '0' );

// Recheck plugin is working, to disable the paywall.
$event = new LaterPay_Core_Event();
$event->set_echo( false );
laterpay_event_dispatcher()->dispatch( 'laterpay_on_plugin_is_working', $event );

return false;
}

// Possible value of status is ok or error in case of wrong params which means api is working.
if ( ( is_array( $result ) && array_key_exists( 'status', $result ) ) || ( empty( $result ) && $client->check_health() ) ) {
if ( ( is_array( $result ) && array_key_exists( 'status', $result ) ) || ( empty( $result ) && array_key_exists( 'status', $health_check ) ) ) {
self::$lp_api_availability = true;
} else {
throw new Exception( 'Unable to reach LaterPay API' );
Expand Down
14 changes: 0 additions & 14 deletions laterpay/application/Module/Appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public static function get_shared_events() {
'laterpay_on_enabled_post_type' => array(
array( 'on_enabled_post_type' ),
),
'laterpay_on_valid_account_credential' => array(
array( 'on_valid_account_credential' ),
),
'laterpay_on_ajax_user_can_activate_plugins' => array(
array( 'on_ajax_user_can_activate_plugins' ),
),
Expand Down Expand Up @@ -177,17 +174,6 @@ public function on_enabled_post_type( LaterPay_Core_Event $event ) {
}
}

/**
* Stops bubbling if account credentials are not valid.
*
* @param LaterPay_Core_Event $event
*/
public function on_valid_account_credential( LaterPay_Core_Event $event ) {
if ( true === (bool) get_option( 'laterpay_plugin_is_in_live_mode' ) && ! LaterPay_Controller_Admin_Account::validate_current_credentials() ) {
$event->stop_propagation();
}
}

/**
* Modify the post content of paid posts.
*
Expand Down
1 change: 0 additions & 1 deletion laterpay/application/Module/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static function get_subscribed_events() {
'laterpay_post_content' => array(
array( 'laterpay_on_view_purchased_post_as_visitor', 200 ),
array( 'is_purchasable', 100 ),
array( 'laterpay_on_valid_account_credential', 100 ),
array( 'modify_post_content', 5 ),
),
'laterpay_check_user_access' => array(
Expand Down
1 change: 0 additions & 1 deletion laterpay/application/Module/TimePasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static function get_shared_events() {
public static function get_subscribed_events() {
return array(
'laterpay_post_content' => array(
array( 'laterpay_on_valid_account_credential', 100 ),
array( 'modify_post_content', 5 ),
),
'laterpay_time_passes' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
// Pay-per-Use purchases are not allowed for prices > 5.00 Euro
$singleSale.prop('checked', 'checked');
} else if (price < lpVars.currency.sis_min && currentRevenueModel === $o.singleSale) {
// Single Sale purchases are not allowed for prices < 1.49 Euro
// Single Sale purchases are not allowed for prices < 1.00 Euro
$payPerUse.prop('checked', 'checked');
}

Expand Down
2 changes: 1 addition & 1 deletion laterpay/asset_sources/js/laterpay-backend-pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@
// Pay-per-Use purchases are not allowed for prices > 5.00 Euro
$singleSale.prop('checked', 'checked');
} else if (price < lpVars.currency.sis_min && currentRevenueModel === $o.singleSale) {
// Single Sale purchases are not allowed for prices < 1.49 Euro
// Single Sale purchases are not allowed for prices < 1.00 Euro
$payPerUse.prop('checked', 'checked');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var DynamicPricingWidget = function (container) {
this.minPrice = 0;
this.maxPrice = 5;
this.defaultPrice = 0.49;
this.payLaterPrice = ( lpVars.currency === 'USD' ) ? 1.99 : 1.49;
this.payLaterPrice = ( lpVars.currency === 'USD' ) ? 1.99 : 1.00;
this.currentPrice = 0;
this.pubDays = 0;
this.currency = lpVars.currency;
Expand Down
2 changes: 1 addition & 1 deletion laterpay/asset_sources/js/laterpay-post-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
// Pay-per-Use purchases are not allowed for prices > 5.00 Euro
$singleSale.prop('checked', true);
} else if (price < lpVars.limits.sis_min && currentRevenueModel === $o.singleSale) {
// Single Sale purchases are not allowed for prices < 1.49 Euro
// Single Sale purchases are not allowed for prices < 1.00 Euro
$payPerUse.prop('checked', true);
}

Expand Down
Loading

0 comments on commit 134db3f

Please sign in to comment.