Skip to content

Commit 964e542

Browse files
Merge pull request #27 from OWUREE/fix/incorrect-expiredOn-set
fixed the expiredOn parameter bug on subscription
2 parents 3a5c433 + bf46e04 commit 964e542

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

MeprPaystackGateway.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,30 @@ public function record_create_subscription()
383383

384384
// If no trial or trial amount is zero then we've got to make
385385
// sure the confirmation txn lasts through the trial
386-
if (!$sub->trial || ($sub->trial && $sub->trial_amount <= 0.00)) {
387-
$trial_days = ($sub->trial) ? $sub->trial_days : $mepr_options->grace_init_days;
386+
// if (!$sub->trial || ($sub->trial && $sub->trial_amount <= 0.00)) {
387+
// $trial_days = ($sub->trial) ? $sub->trial_days : $mepr_options->grace_init_days;
388+
// $txn->status = MeprTransaction::$confirmed_str;
389+
// $txn->txn_type = MeprTransaction::$subscription_confirmation_str;
390+
// $txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days($trial_days), 'Y-m-d 23:59:59');
391+
// $txn->set_subtotal(0.00); // Just a confirmation txn
392+
// $txn->store();
393+
// }
394+
395+
if (!$sub->trial) {
396+
$txn->status = MeprTransaction::$confirmed_str;
397+
$txn->txn_type = MeprTransaction::$subscription_confirmation_str;
398+
$next_payment_date = $sdata->next_payment_date;
399+
$txn->expires_at = MeprUtils::ts_to_mysql_date(strtotime($next_payment_date), 'Y-m-d 23:59:59');
400+
401+
$txn->store();
402+
}
403+
404+
else if($sub->trial && $sub->trial_amount <= 0.00) {
405+
$trial_days = $sub->trial_days;
388406
$txn->status = MeprTransaction::$confirmed_str;
389407
$txn->txn_type = MeprTransaction::$subscription_confirmation_str;
390408
$txn->expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days($trial_days), 'Y-m-d 23:59:59');
391-
$txn->set_subtotal(0.00); // Just a confirmation txn
409+
392410
$txn->store();
393411
}
394412

main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: MemberPress Paystack
55
* Plugin URI: https://wordpress.org/plugins/paystack-memberpress/
66
* Description: Paystack integration for MemberPress.
7-
* Version: 1.3.2
7+
* Version: 1.3.3
88
* Author: Paystack
99
* Author URI: https://paystack.com/
1010
* Developer: Wisdom Ebong

readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: paystack, billing, subscription, payment, memberpress,
44
Requires at least: 5.1
55
Tested up to: 6.3
66
Requires PHP: 7.2 and higher
7-
Stable tag: 1.3.2
7+
Stable tag: 1.3.3
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -83,6 +83,9 @@ Here you can browse the source, look at open issues and keep track of developmen
8383

8484
== Changelog ==
8585

86+
= 1.3.3 =
87+
* Fixed incorrect date set on expiredOn parameter
88+
8689
= 1.3.2 - Septmber 26, 2023 =
8790
* Compatibility with WordPress 6.3 and PHP 8.2.0
8891

@@ -93,3 +96,6 @@ Here you can browse the source, look at open issues and keep track of developmen
9396

9497
= 1.3.2 =
9598
* Compatibility with WordPress 6.3 and PHP 8.2.0
99+
100+
= 1.3.3 =
101+
* Fixed incorrect date set on expiredOn parameter

0 commit comments

Comments
 (0)