@heypay/effect-sdk@0.0.6
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({ productId: Config.succeed("Your HeyPay Product ID") });
The productId
represents your digital product on the HeyPay platform.
Usage
Getting the Checkout URL
The SDK exposes a function for getting the checkout URL.
const checkoutUrl = yield* heypay.checkoutUrl; console.log(checkoutUrl); // https://heypay.sh/...
Your customers can purchase a license key via this URL then.
Activating a License Key
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const { license } = yield* heypay.activate({ key: "KEY-...", }); });
This will activate a purchased license key. The resulting license
needs to be persisted within your app.
Offline Licence Verification
Verifying a license without connectivity.
const program = Effect.gen(function* () { const heypay = yield* HeyPay; const isValid = yield* heypay.verify({ license: "ADeykJi...", }); console.log(isValid); // `boolean` });
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 isValid = yield* heypay.verify({ license: "ADeykJi...", }, {online: true}); console.log(isValid); // `boolean` });
Add Package
deno add jsr:@heypay/effect-sdk
Import symbol
import * as mod from "@heypay/effect-sdk";
---- OR ----
Import directly with a jsr specifier
import * as mod from "jsr:@heypay/effect-sdk";
Add Package
npx jsr add @heypay/effect-sdk
Import symbol
import * as mod from "@heypay/effect-sdk";
Add Package
yarn dlx jsr add @heypay/effect-sdk
Import symbol
import * as mod from "@heypay/effect-sdk";
Add Package
pnpm dlx jsr add @heypay/effect-sdk
Import symbol
import * as mod from "@heypay/effect-sdk";
Add Package
bunx jsr add @heypay/effect-sdk
Import symbol
import * as mod from "@heypay/effect-sdk";