Skip to main content
Home

latest
Works with
This package works with Node.js, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers, Deno
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Publisheda year ago (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 domain represents your personal HeyPay instance domain (e.g. you.heypay.sh).
  • The productId represents 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.
});

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@heypay/effect-sdk

Import symbol

import * as effect_sdk from "@heypay/effect-sdk";
or

Import directly with a jsr specifier

import * as effect_sdk from "jsr:@heypay/effect-sdk";

Add Package

pnpm i jsr:@heypay/effect-sdk
or (using pnpm 10.8 or older)
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
or (using Yarn 4.8 or older)
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";