JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 26
  • Score
    100M100P100Q83961F
  • License ISC

Administrative API client for the Crablr platform, providing backend management capabilities and administrative operations.

Package Exports

  • @crablr/admin

Readme

@crablr/admin

Official Node.js SDK for the Crablr payment platform. Manage payment intents and handle webhooks in your server-side applications.

Installation

npm install @crablr/admin

Quick Start

  1. Create a Crablr admin client:

    import { createCrablrAdmin } from "@crablr/admin";
    
    const crablr = createCrablrAdmin({
      apiKey: "as_your_admin_secret_key_here",
    });
  2. Create a payment intent:

    const paymentIntent = await crablr.createPaymentIntent({
      payerAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
      amount: 1000,
      currencyId: "507f1f77bcf86cd799439011",
    });

API Reference

Authentication

createCrablrAdmin(options)

Creates an authenticated Crablr admin client.

import { createCrablrAdmin } from "@crablr/admin";

const crablr = createCrablrAdmin({
  apiKey: "as_your_admin_secret_key_here", // Required: Admin secret API key
});

Parameters:

  • apiKey (string, required) - Your admin secret API key (must start with as_)

Payment Intents

createPaymentIntent(input)

Create a new payment intent for accepting cryptocurrency payments.

const result = await crablr.createPaymentIntent({
  payerAddress: "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  amount: 1000,
  currencyId: "507f1f77bcf86cd799439011",
});

console.log(result.paymentIntent.id); // Payment intent ID
console.log(result.paymentIntent.status); // Payment status
console.log(result.payload); // Transaction payload for client

Parameters:

  • payerAddress (string, required) - The wallet address that will make the payment
  • amount (number, required) - Payment amount
  • currencyId (string, required) - MongoDB ObjectId of the supported currency

getPaymentIntent(input)

Retrieve a specific payment intent by ID.

const paymentIntent = await crablr.getPaymentIntent({
  id: "507f1f77bcf86cd799439011",
});

console.log(paymentIntent.id);
console.log(paymentIntent.status);

Parameters:

  • id (string, required) - MongoDB ObjectId of the payment intent

getPaymentIntents(input)

List payment intents for a specific customer with pagination.

const result = await crablr.getPaymentIntents({
  customer: "507f1f77bcf86cd799439011",
  startingAfter: "507f1f77bcf86cd799439012", // Optional: for pagination
});

console.log(result.items); // Array of payment intents
console.log(result.hasMore); // Boolean indicating if more items exist

Parameters:

  • customer (string, required) - MongoDB ObjectId of the customer
  • startingAfter (string, optional) - MongoDB ObjectId for pagination cursor

Webhook Handling

createWebhook(options)

Create a webhook handler for verifying and processing webhook events.

import { createWebhook, Webhook } from "@crablr/admin";

const crablrWebhook = createWebhook({
  webhookSecret: "whs_your_webhook_secret_here",
});

webhook.assertSignature(payload, signature)

Verify webhook signature and extract payment intent ID.

Configuration

The SDK requires your API credentials from the Crablr dashboard:

  • Admin Secret API Key: Get from your Crablr dashboard (starts with as_)
  • Webhook Secret: Configure in your Crablr shop settings (starts with whs_)

Troubleshooting

Common Issues

"Invalid admin secret API key" error:

  • Ensure your API key starts with as_
  • Verify the key is correct in your Crablr dashboard

"Invalid webhook secret" error:

  • Ensure your webhook secret starts with whs_
  • Check the webhook configuration in your shop settings

Webhook signature verification fails:

  • Verify the webhook secret is correct
  • Ensure you're using the raw request body (not parsed JSON)
  • Use Webhook.parseHeaders() to extract the signature from headers
  • Check that the x-crablr-hmac-sha256 header is present

License

ISC