question

mkonnekt avatar image
mkonnekt asked mkonnekt commented

Billing API returns "not authorized" + doubt on metered billing

Hi,

I want to do metered billing for my merchants. However, I am stuck at 3 places:

  1. I try to get current subscription details using GET /v3/apps/{aId}/merchants/{mId}/billing_info. However, even though I have all possible read, modify permissions for my app, I get not authorized error with no response body

  2. I want to use POST /v3/apps/{aId}/merchants/{mId}/metereds/{meteredId} to bill merchants for going above the allowed limit of free actions by passing the count of extra actions performed during the billing cycle. Do I post this API at the end of the billing cycle? Or do I post on every action beyond the free limit?

  3. If the former in the above question, then if a merchant changes his/her subscription plan in between the billing cycle, then should I charge for all extra actions above free limit at the time of subscription change and start a new billing cycle for the new plan? Or should I include the extra actions from previous plan in the new plan's free limit? eg. 20 free actions for $25 and 50 free actions for $55 If merchant has 30 actions for $25 plan and changes to $55 plan before end of billing cycle, should I a. start new billing cycle and charge $25 + 10 extra or b. start new billing cycle but charge only $25 and assume the $55 plan now has 10 actions already

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mkonnekt avatar image mkonnekt commented ·

Please help with the API not working issue. I am getting "unauthorized" error on calling GET /v3/apps/{aId}/merchants/{mId}/billing_info. However, I have all permissions and the same access token works for other APIs for the merchant

0 Likes 0 ·
Mike M avatar image
Mike M answered mkonnekt commented

In regards to #1, have you reinstalled your app via the App Market (full uninstall + fresh install) since you last modified the permissions of your app? It's possible that the token hasn't been regenerated on our side yet. This is a security precaution to prevent apps gaining permissions without the merchant being aware.

You may always check the permission set of your current access token by calling this GET api. https://api.clover.com/v3/access_tokens/{access token here} Please note that the base url will need to be adjusted accordingly to your environment, such as for Sandbox.


Regarding #2 and #3, you will need to keep track of the action count to verify it against the "free action" limit you've set for each subscription tier. This functionality you are describing is not built in to the Clover billing structure and will need to be implemented on your side.

It is up to you how you want to structure the payment plan. I would only recommend collecting overage events for one batch POST if you intend to roll the events into plan upgrades. Otherwise, it is simpler to POST the event as soon as it occurs.

Because this system is your own architecture, either approach is fine, but you should make it very clear in your app description exactly what causes a metered event, from the merchant perspective.

4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mkonnekt avatar image mkonnekt commented ·

Thanks. 1. I am using a completely new merchant (test merchant created in my developer a/c) and doing a fresh install -> new access token. API: https://api.clover.com:443/v3/apps/X9... RESPONSE: Status Code: 401 Unauthorized Content-Length: 30 Content-Type: application/json; charset=utf-8 X-Frame-Options: SAMEORIGIN

Please help. I need to get the subscription ID from this API to proceed to metered billing for my merchants.

0 Likes 0 ·
mkonnekt avatar image mkonnekt commented ·

Hi there. waiting for a resolution for this issue please.

0 Likes 0 ·
mkonnekt avatar image mkonnekt commented ·

I am using a completely new merchant (test merchant created in my developer a/c) and doing a fresh install -> new access token. API: https://api.clover.com:443/v3/apps/X9... RESPONSE: Status Code: 401 Unauthorized Content-Length: 30 Content-Type: application/json; charset=utf-8 X-Frame-Options: SAMEORIGIN Please help. I need to get the subscription ID from this API to do metered billing. There are no permissions related to APP. We have all read, modify permissions for merchants.

0 Likes 0 ·
Mike M avatar image Mike M commented ·

Sorry for the delayed response. I had to do some additional research, for the Apps endpoint you actually need to use your App Secret as the access token. Please give that a try, I was able to get it working for my app.

0 Likes 0 ·
mkonnekt avatar image
mkonnekt answered

Hey there. Still waiting for your help on resolving this issue please.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community