You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First-time LS here. I have a graduated product that generates a license key for the customer. Then can them use that license key on my API to send requests, and those are billed individually. I can pass the license key as a header and validate the license successfully, the steps that seem necessary to be able to create a usage record seem numerous to my LS novice eyes.
const{data: user,error: userError}=awaitgetAuthenticatedUser();constlicenseKey=req.headers['x-license-key'];const{error: licenseError,data: license}=awaitvalidateLicense(licenseKeyasstring);const{data: subscriptions}=awaitlistSubscriptions({filter: {orderItemId: license.meta.order_item_id},include: ['subscription-items']});constsubscription=subscriptions.data.shift();constusageRecordData={quantity: 1,subscriptionItemId: subscription.relationships['subscription-items'].data.shift().id};const{error: usageRecordError,data: usageRecord}=awaitcreateUsageRecord(usageRecordData);// Process user request...
This is the shortest path I see, but it's still 4 LS API requests per customer request. It feels heavy. Any idea how I can streamline this process?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
First-time LS here. I have a graduated product that generates a license key for the customer. Then can them use that license key on my API to send requests, and those are billed individually. I can pass the license key as a header and validate the license successfully, the steps that seem necessary to be able to create a usage record seem numerous to my LS novice eyes.
This is the shortest path I see, but it's still 4 LS API requests per customer request. It feels heavy. Any idea how I can streamline this process?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions