npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@joogopay/sdk

v0.4.0

Published

Merchant open API SDK (Ed25519 / RFC 9421 signing, X25519 sealed box body encryption)

Readme

JooGoPay SDK for JavaScript

Official SDK for the merchant open API. Signing, digest and body encryption are handled by the SDK; merchants never assemble Signature-Input, Content-Digest or the sealed box envelope by hand.

The SDK is optional. You may implement the same wire protocol with an approved crypto library and your existing framework; see direct integration.

Protocol

protocol/ is the source of truth; the Go, JavaScript, PHP, Python and Java SDKs are verified against the same set of test vectors:

| Item | Approach | | --- | --- | | Signature | Ed25519 with a fixed RFC 9421 profile | | Digest | RFC 9530 Content-Digest (sha-256) | | POST body | X25519 sealed box envelope; the digest is computed over the encrypted body | | GET | No encryption, no body; the signature covers the public query and the access key | | Webhook | Signed by the platform with Ed25519; the body is not encrypted | | Merchant identity | Located by Merchant-Access-Key only; signature params carry no keyId |

Installation

npm install @joogopay/sdk

Runtime dependency: libsodium-wrappers. Node.js 18 or newer.

Configuration

Six values are needed. Only the private key is generated on the merchant side; the platform never receives it.

| Field | Description | | --- | --- | | baseUrl | HTTPS platform origin, without /api/v1 | | accessKey | Merchant access identifier issued by the platform | | merchantPrivateKeyBase64 | Merchant Ed25519 private key, base64, stored on the merchant side only | | platformBodyKeyId | Current platform body key id (per deployment) | | platformBodyPublicKeyBase64 | Platform X25519 public key, base64, used to encrypt POST bodies | | platformWebhookPublicKeys | Platform webhook Ed25519 public keys, indexed by keyId |

The client rejects non-HTTPS base URLs. Synchronous responses are plaintext JSON whose confidentiality and integrity rely on HTTPS/TLS.

Quick start

import { APIError, Client, RequestError, ResponseError, TransportError } from '@joogopay/sdk';

const client = new Client({
  baseUrl: 'https://panama.joogopay.com',          // production origin; no /api/v1
  accessKey: 'mak_live_xxx',
  merchantPrivateKeyBase64: merchantPrivateKey,          // merchant Ed25519 private key, base64
  platformBodyKeyId: 'body_20260827_01',
  platformBodyPublicKeyBase64: platformBodyPublicKey,    // platform X25519 public key, base64
  platformWebhookPublicKeys: {                           // keyId -> platform Ed25519 public key, base64
    pwhk_20260827_01: platformWebhookPublicKey,
  },
});

const order = await client.createPayment({
  merchantOrderNo: 'M20260101001',
  currency: 'BRL',
  amount: '100.00',                                  // decimal string, never a number
  paymentMethod: { code: 'PIX', pix: { payerName: 'Joao Silva' } },
  webhookUrl: 'https://merchant.example/webhook/payments',
});
console.log(order.orderNo, order.status, order.action?.url);

Two kinds of failure, opposite handling

| Error | Meaning | Handling | | --- | --- | --- | | RequestError | Rejected before it was sent (local validation, a bad parameter, or a request the SDK could not encode or sign) | Safe to mark failed; fix the request and retry under the same merchantOrderNo | | TransportError | Handed to the transport, no usable response (connection failure, timeout, interrupted read) | Outcome unknown; never mark a payout failed. Query by merchantOrderNo, or resend the identical request under the same number | | APIError | The gateway returned a business error (msg / apiMessage / traceId) | Branch on msg. IDEMPOTENCY_CONFLICT: the number is taken but the platform could not return its order, query that number and keep querying rather than switching numbers. CHANNEL_ERROR: the order may already exist, query by merchantOrderNo first and reuse that number only once the query returns ORDER_NOT_FOUND. CHANNEL_BUSY: refused before the order was created, so resend the same number after a back-off; this is the only channel error that needs no query first | | ResponseError | The gateway or CDN returned something that is not an envelope (HTML 502, ...) | Outcome unknown; query before deciding | | ResponseTooLargeError | A response arrived but exceeded the size limit and was discarded | Outcome unknown; the order was most likely created, query before deciding | | Anything else | An unexpected error; assume the request may have arrived | Outcome unknown; query before deciding |

merchantOrderNo is the only key that prevents a duplicate order. A second create with the same number never creates a second order: the platform answers with the original order, or with IDEMPOTENCY_CONFLICT when it recognises the number as taken but cannot return that order. The idempotency key travels with the request for tracing and is not a deduplication key.

Two rules follow:

  • After an unknown outcome, never allocate a new merchantOrderNo. Query the existing one, or resend the same request under the same number.
  • A resend must carry identical parameters. The platform returns the original order without comparing fields, so a changed amount or account silently has no effect. To change anything, use a new merchantOrderNo and reconcile the original order first.

The SDK validates locally before signing (top-level required fields and formats, method code structure and required extras); the rules are defined in protocol/merchant-api.md. Format checks such as phone number length or email syntax are deliberately left to the gateway so the SDK never drifts from it.

Next steps

Querying, idempotent retries and webhook verification are covered by the platform documentation at https://docs.joogopay.com; its examples map one to one onto this SDK. The wire protocol is in protocol/webhook.md and protocol/merchant-api.md. Key points:

  • After a create request times out, query by merchantOrderNo first instead of sending a new order; a deliberate retry repeats the same call with the same merchantOrderNo.
  • For webhooks, pass method, path, headers and the raw, unparsed body bytes to client.parsePaymentWebhook({ method, path, headers, body }); the SDK verifies the digest, event id, time window and Ed25519 signature. Respond 2xx once handled and deduplicate by eventId.

Supplementing a payment with the payer's transfer reference

When a payment stays PROCESSING and the payer has a transfer reference (for example a 12-digit UPI UTR), submit it with supplementPayment so the platform can have the channel match the transfer. Identify the order by exactly one of orderNo or merchantOrderNo. The request is signed and encrypted like createPayment and resolves with the payment order.

const order = await client.supplementPayment({ orderNo: 'P20260101001', tradeNo: '123456789012' });

Resolving only means the channel accepted the reference; the final status still arrives by webhook or query. The reference format is validated by the platform, not the SDK. APIError msg values to expect: INVALID_FIELD (bad or missing tradeNo), ORDER_NOT_FOUND, IDEMPOTENCY_CONFLICT (the order is no longer PROCESSING), UNSUPPORTED_METHOD, and CHANNEL_ERROR (the channel did not accept the reference; the order stays PROCESSING).

Amounts

Amounts, fees and rates in requests, responses, webhooks, balances, rates and receipts are always decimal strings, e.g. "100.00". Never use floating point.

Order status

Only six external statuses exist: PENDING PROCESSING SUCCEEDED FAILED EXPIRED CANCELED.

Troubleshooting

| Situation | Action | | --- | --- | | Create request timed out | Query by merchantOrderNo; do not resend a new order | | Deliberate retry | Call the same method again with the same merchantOrderNo and identical parameters; the SDK generates a fresh nonce per request | | Signature rejected | Check the server clock, accessKey, merchant private key and the public key registered with the platform | | Body decryption failed | Check that platformBodyKeyId and the public key belong to the current environment | | Webhook signature rejected | Check that the webhook key set contains the keyid from the header |

Tests

npm test

The tests assert directly against the vectors in protocol/testdata: Signature-Input, signature base and signature value are compared byte for byte, and body encryption is verified by decrypting ciphertext produced by the reference implementation.

Webhook order matching

Save the platform orderNo returned by creation under the expected merchant. After verification, match that number to the saved order and check order type, merchant order number, currency and applicable amounts before updating state. Do not credit or refund using merchantOrderNo alone. For an unknown platform order, reliably queue the event and query by orderNo with your own credentials before applying it. Deduplicate by eventId, commit the business update or durable queue acceptance before returning 2xx, and retry queued failures internally. See webhook processing.

Aggregate hosted checkout

Create a payment through the existing payment endpoint with a specific currency and paymentMethod: {"code":"ALL"}. Do not include method-specific payloads. The payer selects an available method and provides any required payer details on action.url. Availability depends on the merchant configuration and enabled payment capabilities; an SDK rule does not imply that a currency is enabled.

Keep the complete action.url, including its fragment. Treat it as a private checkout link. Queries keep returning that entry URL after selection, while the order's payment method changes from ALL to the selected method. A successful create or browser return does not prove payment: verify the signed webhook or query the order. On timeout, query or retry with the same merchant order number and unchanged business fields. ALL is unavailable for payouts and subscriptions.