Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls to Pricing API with a PUT request fail the the optional "licenses" argument is not specified #15

Open
daigo75 opened this issue Mar 17, 2021 · 0 comments

Comments

@daigo75
Copy link

daigo75 commented Mar 17, 2021

The documentation (https://freemius.docs.apiary.io/#reference/pricing/plans-pricing/update-pricing) indicates the following:

Request Body JSON Data

Key Required Description
monthly_price No  
annual_price No  
lifetime_price No  
licenses No The number of license activation supported by the license. E.g. when the value is 1, the premium license can only be activated on single site.

Based on the above, I made a call as follows:

  • Method: PUT
  • Path: /plugins/123/plans/456/pricing/789.json
  • Body: {"annual_price":"10"}'

Expected result: the annual price for pricing 789 would be changed to 10.
Actual result:

 'error' =>
    object(stdClass)[4452]
      public 'type' => string 'ObjectExist' (length=11)
      public 'message' => string 'There's already another pricing configured for  installs license.' (length=65)
      public 'code' => string 'pricing_exist' (length=13)
      public 'http' => int 401

Notice that the message says "There's already another pricing configured for installs license". There are two spaces between "for" and "installs", which leads me to think that the response was generated by a sprintf() call which tried to embed the "licenses" argument (not passed with the call) into the message.

Hypothesis about the cause, and possible solution

The "PUT" call should update the attributes of the pricing, based on the ID. It should not try to create another pricing. My speculation is that the "licenses" argument is being used to identify the pricing together with the ID. That could make sense with a POST call, to avoid creating a duplicate pricing, but the PUT call should only use the pricing ID, as it's unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant