I'm working on getting all the active members in our Braintree account. I can list all customers but I don't know how to list the active ones.
In the Braintree dashboard, I can easily see it by going to subscriptions and filtering all Active subscriptions then clicking the subscription ID. From there I can see which customer has that subscription ID.
Then I tried getting all the active subscriptions first but I can't find any connection with any customers either.
I'm using the PHP SDK.
Here's how I get our active subscriptions.
My subscription code in my library:
function active_subscriptions(){
return Braintree_Configuration::gateway()->subscription()->search([
Braintree_SubscriptionSearch::status()->in([Braintree_Subscription::ACTIVE])
]);
}
Here's for the controller:
function active_subscriptions(){
$active_subscriptions = $this->braintree_lib->active_subscriptions();
$counter = 5;
foreach($active_subscriptions as $subscription) {
if($counter == 0){
die();
}
echo 'Subscription ID: '.$subscription->id.'<br />';
echo 'merchantAccountId: '.$subscription->merchantAccountId.'<br />';
echo 'planId: '.$subscription->planId.'<br /><br />';
$counter--;
}
}
I found this but it's in Ruby on Rails and there are no details about it in the documentation.