Cannot create / update plan with addons
See original GitHub issueGeneral information
- SDK/Library version: 5.12.0
- Environment: Sandbox
- C# .NET core 6
Issue description
I am able to create / update plans without addons, but when I need to assign addons to a plan (which has not been used for anything yet) or create plan with addon right away. I am getting AuthorizationException when I set Addons property in PlanRequest.
PlanRequest planRequest = new PlanRequest
{
Id = "my-plan",
Name = "My plan",
Description = "Awesome plan",
BillingFrequency = 1,
Price = 20,
CurrencyIsoCode = "EUR",
TrialPeriod = false,
TrialDurationUnit = null,
TrialDuration = null
};
List<AddOn> addons = Gateway.AddOn.All().ToList();
planRequest.AddOns = new List<AddOn>();
foreach (var addonId in addons)
{
planRequest.AddOns.Add(addon);
}
var planResult = await Gateway.Plan.CreateAsync(planRequest);
Braintree.Exceptions.AuthorizationException: Exception of type 'Braintree.Exceptions.AuthorizationException' was thrown.
at Braintree.HttpService.ThrowExceptionIfErrorStatusCode(HttpStatusCode httpStatusCode, String message) in D:\Git\CTB\Ctb.Platform.App\api\IoLabs.BrainTree\Gateway\HttpService.cs:line 340
at Braintree.HttpService.GetHttpResponse(HttpRequestMessage request) in D:\Git\CTB\Ctb.Platform.App\api\IoLabs.BrainTree\Gateway\HttpService.cs:line 137
at Braintree.BraintreeService.GetXmlResponse(String URL, String method, Request requestBody, FileStream file) in D:\Git\CTB\Ctb.Platform.App\api\IoLabs.BrainTree\Gateway\BraintreeService.cs:line 153
at Braintree.BraintreeService.Post(String URL, Request requestBody) in D:\Git\CTB\Ctb.Platform.App\api\IoLabs.BrainTree\Gateway\BraintreeService.cs:line 48
at Braintree.PlanGateway.Create(PlanRequest request) in D:\Git\CTB\Ctb.Platform.App\api\IoLabs.BrainTree\Gateway\PlanGateway.cs:line 46
When creating a plan I am getting all available addons first and the setting them to PlanRequest which allows to set them, sandbox website also allows to configure addons for plans so there is no reason why this library should not be able to do it.
I noticed tests also do not contain use case with addons and looking closer I noticed addons are not being properly serialized into the request.
xml coming to http call:
<?xml version="1.0" encoding="UTF-8"?><plan><billing-frequency>1</billing-frequency><currency-iso-code>EUR</currency-iso-code><description>xxx</description><id>xxx</id><name>xxx</name><price>20.00</price><trial-period>false</trial-period><add-ons>System.Collections.Generic.List'1[Braintree.AddOn]</add-ons></plan>
Delete plan method is missing completely on PlanGateway for no obvious reason, that would be nice as well for full CRUD capability like in sandbox web admin.
We would like to make this work so we can go live. This is part of customer’s admin interface.
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Thanks for noticing and reopening 😃
@saralvasquez awesome, thank you very much!!