Skip to content

Instantly share code, notes, and snippets.

@ibrahimlawal
Last active July 16, 2016 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibrahimlawal/4a76070866d5a54036e992609078f981 to your computer and use it in GitHub Desktop.
Save ibrahimlawal/4a76070866d5a54036e992609078f981 to your computer and use it in GitHub Desktop.
Enable or disable Paystack subscriptions in PHP, knowing the token and code // Uses Paystack Class : https://github.com/yabacon/paystack-class
<?php
// Get this from https://github.com/yabacon/paystack-class
require 'Paystack.php';
$paystack = new Paystack('sk_test_xxx');
// ... some code previously to obtain $token and $code for this subscription
// (both can be obtained by capturing `subscription.create` event)
// the code below throws an exception if there was a problem completing the request,
// else returns an object created from the json response
$subscription_credentials = [
'token' => $token,
'code' => $code,
];
$trx = $paystack->subscription->disable($subscription_credentials);
// status should be true if there was a successful call
if($trx->status){
// disabled successfully
echo($trx->message);
}
<?php
// Get this from https://github.com/yabacon/paystack-class
require 'Paystack.php';
$paystack = new Paystack('sk_test_xxx');
// ... some code previously to obtain $token and $code for this subscription
// (both can be obtained by capturing `subscription.create` event)
// the code below throws an exception if there was a problem completing the request,
// else returns an object created from the json response
$subscription_credentials = [
'token' => $token,
'code' => $code,
];
$trx = $paystack->subscription->enable($subscription_credentials);
// status should be true if there was a successful call
if($trx->status){
// enabled successfully
echo($trx->message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment