Skip to content

Commit 8302e2e

Browse files
author
Owuree
committed
fixed the expiredOn parameter bug on subscription
1 parent 3a5c433 commit 8302e2e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
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

0 commit comments

Comments
 (0)