Skip to main content

latest

Effect-based SDK for interacting with the HeyPay platform

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 Score
100%
Published
3 weeks ago (0.0.6)

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";