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
// Unfortunately, we don't store that subscription id in the purchase itself,
230
+
// which makes it extra work to local the subscription. But we can get it this
231
+
// way by using the metadata jsonb. Basically the purchase description has the license_id
232
+
// and the subscription metadata also has the same license id, and there is only one
233
+
// subscription for a license. I do select the newest subscription in case there is more
234
+
// than one for the same license (should be impossible).
235
+
logger.debug(
236
+
"getSubscriptionWithPurchaseId -- use license_id metadata and a join",
237
+
);
238
+
consty=awaitpool.query(
239
+
"SELECT subscriptions.id AS id FROM purchases,subscriptions WHERE (purchases.description#>>'{license_id}')::uuid=(subscriptions.metadata#>>'{license_id}')::uuid AND purchases.id=$1 ORDER BY subscriptions.created DESC",
240
+
[purchase_id],
241
+
);
242
+
subscription_id=y.rows[0]?.id;
243
+
if(subscription_id){
244
+
returnsubscription_id;
245
+
}
246
+
throwError(`there is no subscription with purchase id ${purchase_id}`);
247
+
}
248
+
217
249
// This export is only to make some private functions in this file available for unit testing.
218
250
// Don't otherwise use or instead change those to explicit exports if needed for some reason.
0 commit comments