@heypay/effect-sdk@0.1.9
Effect-based SDK for interacting with the HeyPay platform
HeyPay Effect SDK
Installation
The package is hosted on JSR. You can install it via:
# pnpm pnpm dlx jsr add @heypay/effect-sdk # Deno deno add jsr:@heypay/effect-sdk # bun bunx jsr add @heypay/effect-sdk # npm npx jsr add @heypay/effect-sdk # yarn yarn dlx jsr add @heypay/effect-sdk
Initialization
The SDK exposes an Effect Layer which can be initialized via:
import { HeyPay } from "@heypay/effect-sdk"; const HeyPayLive = HeyPay.layer({ domain: Config.succeed("<Your HeyPay instance domain>"), productId: Config.succeed("<Your HeyPay Product ID>") });
- The
domainrepresents your personal HeyPay instance domain (e.g.you.heypay.sh). - The
productIdrepresents your digital product on the HeyPay platform.
Usage
Activating a License Key
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const code = prompt("Please enter the code of your license key"); const { license } = yield* heypay.activate({ code, }); });
This will activate a purchased license key. The resulting license needs to be persisted within your app.
Online License Verification
It is highly recommended to verify the license against the HeyPay platform from time to time.
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const { license } = yield* heypay.verify({ license: "eyA...", }, { online: true }); });
This will connect to the HeyPay platform and performs an online verification of the license. It will return a refreshed license which needs to be persisted within your app. The HeyPay platform might refresh the license in certain scenarios, like when the license got revoked or it was extended by a subscription renewal.
Offline Licence Verification
Verifying a license without connectivity.
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const { license } = yield* heypay.verify({ license: "eyA...", }); });
Get Supporter Information
The following returns information about the supporter who purchased the license.
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const { supporter } = yield* heypay.getSupporter({ license: "eyA...", }); console.log(supporter.number); // The consecutive supporter number. It indicates how many supporters have bought this product so far. console.log(supporter.name); // The full name of the supporter. console.log(supporter.email); // The email address of the supporter. });
Add Package
deno add jsr:@heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";
Import directly with a jsr specifier
import * as effect_sdk from "jsr:@heypay/effect-sdk";
Add Package
pnpm i jsr:@heypay/effect-sdk
pnpm dlx jsr add @heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";
Add Package
yarn add jsr:@heypay/effect-sdk
yarn dlx jsr add @heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";
Add Package
vlt install jsr:@heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";
Add Package
npx jsr add @heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";
Add Package
bunx jsr add @heypay/effect-sdk
Import symbol
import * as effect_sdk from "@heypay/effect-sdk";