I am trying to override the discount amount i have created from Braintree control panel by calling the function below.
$result = Braintree_Subscription::create([
'paymentMethodToken' => 'the_payment_method_token',
'planId' => 'the_plan_id',
'addOns' => [
'add' => [
[
'inheritedFromId' => 'abcd',
'amount' => 20.00
]
]
]
]);
But it is returning me this error
NotFound in Util.php line 64:; Util::throwStatusCodeException('404') in Http.php line 47 Appreciate any help. Thanks!
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
The 404 error you're seeing is likely being thrown due to one or more ID's specified in your API call not matching what you have in your control panel. The two ID's from your example code are the following:
A Plan with the ID the_plan_id
An add-on with the ID abcd
You'll want to ensure that you have a plan and add-on with those ID's in your control panel before using them in an API call. Since there isn't a way to generate plans or ID's from the API, you can follow the guide below on how to make them.
The other potential issue here is that in your question, you mentioned you wanted to use a discount, where in your code, you're specifying an add-on. This might itself be the source of the problem. I would change these lines:
'addOns' => [
'add' => [
[
'inheritedFromId' => 'abcd',
'amount' => 20.00
]
]
to
'discounts' => [
'add' => [
[
'inheritedFromId' => 'abcd',
'amount' => 20.00
]
]