Skip to content

Commit 07560af

Browse files
committed
fix: fixed the error of not being able to cancel a subscription.
Fixed the error of "token must be a string". Cause => Previous implementation was treating the value as an array from the database. Fix => Extracted the data from the array and properly placed it in the token key
1 parent 7eadd4a commit 07560af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

MeprPaystackGateway.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,19 @@ public function process_cancel_subscription($sub_id)
818818
{
819819
$sub = new MeprSubscription($sub_id);
820820

821+
//Getting the value of the paystack_email_token from the array and storing the value in a variable
822+
$array = $sub->get_meta('paystack_email_token');
823+
$token = $array[0];
824+
825+
821826
if (!isset($sub->id) || (int) $sub->id <= 0)
822827
throw new MeprGatewayException(__('This subscription is invalid.', 'memberpress'));
823828

824829
$args = MeprHooks::apply_filters('mepr_paystack_cancel_subscription_args', array(
825830
'code' => $sub->subscr_id,
826-
'token' => $sub->get_meta('paystack_email_token'),
831+
'token' => $token,
827832
), $sub);
828-
833+
829834
// Yeah ... we're cancelling here bro ... but this time we don't want to restart again
830835
$res = $this->paystack_api->send_request("subscription/disable", $args);
831836

0 commit comments

Comments
 (0)