Search code examples
phppayment-gatewaypaymentbraintree

Set the Number of Billing Cycles via the Braintree API


I am implementing Braintree Payments into our website and I have ran into a problem when trying to create a subscription. I want to override a "Plans" detail for a custom subscription. I am trying to set the "number of billing cycles" via the API using PHP. I cannot seem to get it to work. In the API documentation, it says "You can override the plan price, trial duration, start date, number of billing cycles per subscription, and add-on and discount details." Here is the link: https://www.braintreepayments.com/docs/php/subscriptions/create#overriding_plan_details

$result = Braintree_Subscription::create(array(
         'paymentMethodToken' => $payment_method_token,
         'planId' => 'r45g',
         'price' => "{$_SESSION['enroll-draft-amount']}",
         'billingCycles' => '7'
    ));

This billingCycles setting does not work. Anyone know what the correct setting is?

Thanks


Solution

  • I figured it out. Hope this helps someone else. The correct setting is: numberOfBillingCycles