Skip to content

Commit

Permalink
Merge pull request #1404 from laterpay/develop
Browse files Browse the repository at this point in the history
Tag 2.9.5
  • Loading branch information
milindmore22 authored May 28, 2020
2 parents 65390ff + c67d36a commit d10087e
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 87 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.4",
"version": "2.9.5",
"config": {
"vendor-dir": "laterpay/vendor",
"secure-http": true
Expand Down
23 changes: 12 additions & 11 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.4' }
default: { version: '2.9.5' }
};
var gulpOptions = minimist(process.argv.slice(2), gulpKnownOptions);
gulpOptions.svn = {};
Expand Down
8 changes: 6 additions & 2 deletions laterpay/README.txt
Original file line number Diff line number Diff line change
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.5 ( May 28, 2020 ) =
* Added proper validation for custom voucher codes.
* Fixes minor issue with cache validation message.

= 2.9.4 ( April 16, 2020 ) =
* Disable additional requests on home page if disabled by merchant.
* Validate account status before `/access` check to avoid unnecessary request.
Expand Down Expand Up @@ -710,8 +714,8 @@ KNOWN BUGS:

== Upgrade notice ==

= 2.9.4 =
Reduces unnecessary API calls to `/validatesignature` and `/access` endpoint.
= 2.9.5 =
Added proper validation for custom voucher codes.

== Arbitrary section ==

Expand Down
2 changes: 1 addition & 1 deletion laterpay/application/Helper/Voucher.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public static function get_all_global_vouchers() {
$vouchers = get_option( self::GLOBAL_VOUCHER_CODES_OPTION );
if ( ! $vouchers || ! is_array( $vouchers ) ) {
update_option( self::GLOBAL_VOUCHER_CODES_OPTION, '' );
$vouchers = [];
$vouchers = [ [] ]; // Ticket #1397.
}

// format prices.
Expand Down
31 changes: 22 additions & 9 deletions laterpay/asset_sources/js/laterpay-backend-pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,12 @@

// generate voucher code
$o.timepass.editor
.on('mousedown', $o.generateVoucherCode, function() {
generateVoucherCode($(this).parents($o.timepass.wrapper));
.on('mousedown', $o.generateVoucherCode, function(e) {
if ( $(this).is('[disabled=disabled]') ) {
e.preventDefault();
return false;
}
generateVoucherCode($(this).parents($o.timepass.wrapper));
})
.on('click', $o.generateVoucherCode, function(e) {
e.preventDefault();
Expand Down Expand Up @@ -551,8 +555,12 @@

// Generate voucher code.
$o.subscription.editor
.on('mousedown', $o.generateVoucherCode, function() {
generateVoucherCode($(this).parents($o.subscription.wrapper));
.on('mousedown', $o.generateVoucherCode, function(e) {
if ( $(this).is('[disabled=disabled]') ) {
e.preventDefault();
return false;
}
generateVoucherCode($(this).parents($o.subscription.wrapper));
})
.on('click', $o.generateVoucherCode, function(e) {
e.preventDefault();
Expand Down Expand Up @@ -692,8 +700,7 @@
validateVoucherCode = function( voucherInput, $wrapper, type ) {
var voucherCode = voucherInput.val();

if (voucherCode.length === 6) {

if (voucherCode.length === 6 ) {
var globalVouchers = $o.globalVouchers.data.vouchers;
if ( typeof $o.globalVouchers.data.vouchers === 'string' ) {
globalVouchers = JSON.parse($o.globalVouchers.data.vouchers);
Expand Down Expand Up @@ -751,7 +758,8 @@
return;
}
$($o.subscription.actions.save).removeAttr('disabled');
$($o.subscription.actions.save).attr('href', '#');
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
$($o.subscription.actions.save).attr('href', 'javascript:void(0);');
} else if ( isGlobal ) {
if (true === voucherExists) {
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.voucherExists);
Expand All @@ -761,7 +769,8 @@
return;
}
$o.saveGlobalDefaultPrice.removeAttr('disabled');
$o.saveGlobalDefaultPrice.attr('href', '#');
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
$o.saveGlobalDefaultPrice.attr('href', 'javascript:void(0);');
} else {
if (true === voucherExists) {
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.voucherExists);
Expand All @@ -771,14 +780,18 @@
return;
}
$($o.timepass.actions.save).removeAttr('disabled');
$($o.timepass.actions.save).attr('href', '#');
$wrapper.find($o.generateVoucherCode).removeAttr('disabled');
$($o.timepass.actions.save).attr('href', 'javascript:void(0);');
}

voucherInput.parent().attr('data-code', voucherCode);
voucherInput.parent().find('input[name="voucher_code[]"]').val(voucherCode);
} else {
$wrapper.find('.lp_js_voucher_msg').text(lpVars.i18n.codeTooShort);
$wrapper.find('.lp_js_voucher_msg').css('display', 'block');
// Disabled save button if there are less than 6 characters. #1397
$wrapper.find('.button-primary').attr('disabled', 'disabled');
$wrapper.find($o.generateVoucherCode).attr('disabled', 'disabled');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@
"Congratulations, you are now accepting payments through LaterPay!": [
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
],
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
],
"Hide message.": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@
"Congratulations, you are now accepting payments through LaterPay!": [
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
],
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
],
"Hide message.": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@
"Congratulations, you are now accepting payments through LaterPay!": [
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
],
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
],
"Hide message.": [
Expand Down
2 changes: 1 addition & 1 deletion laterpay/languages/laterpay-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,7 @@ msgstr "Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!
#, php-format
msgid ""
"We recommend %sclearing your cache%s in order to ensure that the paywall is "
"visible everyone."
"visible to everyone."
msgstr ""
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die "
"Paywall für alle sichtbar ist."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@
"Congratulations, you are now accepting payments through LaterPay!": [
"Herzlichen Glückwunsch, Sie akzeptieren jetzt Zahlungen über LaterPay!"
],
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible everyone.": [
"We recommend %sclearing your cache%s in order to ensure that the paywall is visible to everyone.": [
"Wir empfehlen %sIhren Cache zu leeren%s, um sicherzustellen, dass die Paywall für alle sichtbar ist."
],
"Hide message.": [
Expand Down
Loading

0 comments on commit d10087e

Please sign in to comment.