MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / onpurchase

Function onpurchase

src/pages/plugin/plugin.js:316–330  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

314 await helpers.promisify(iap.purchase, product.productId);
315
316 async function onpurchase(e) {
317 const purchase = await getPurchase(product.productId);
318 await fetch(Url.join(config.API_BASE, "plugin/order"), {
319 method: "POST",
320 body: JSON.stringify({
321 id: plugin.id,
322 token: purchase?.purchaseToken,
323 package: BuildInfo.packageName,
324 }),
325 });
326 purchaseToken = purchase?.purchaseToken;
327 purchased = !!purchase;
328 $button.textContent = oldText;
329 install();
330 }
331
332 async function onerror(error) {
333 helpers.error(error);

Callers

nothing calls this directly

Calls 2

getPurchaseFunction · 0.70
installFunction · 0.70

Tested by

no test coverage detected