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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dimepay/web-sdk

v1.0.14

Published

Dime Pay JavaScript SDK for embedding payment widget

Readme

🌐 Dime Pay - Web SDK

Web SDK

The official JavaScript SDK for embedding the Dime Pay secure payment widget into any web application.
Supports React, Angular, Vue, and plain JavaScript environments.

This sdk supports 2 flows.

  1. Payment widget for embedded payment processing.
  2. Saving cards for your customers

🚀 Installation

Install via npm:

npm install @dimepay/web-sdk
yarn add @dimepay/web-sdk

🧩 Usage

Step 1: Add a container to your HTML

<div id="dimepay-widget"></div>

Step 2: Initialize the SDK

Payment flow

import { initPayment } from '@dimepay/web-sdk';

const widget = initPayment({
  mountId: "dimepay-widget",
  total: 5000,
  currency: "JMD",
  test: false,
  order_id: "TEST-001",
  client_id: "ck_jtfEtqbrX2Nf7U_evqKVy",
  origin: window.origin,
  styles: {
    primaryColor: '#000000',
    buttonColor: '#000000',
    buttonTextColor: '#FFFFFF',
    noBorderRadius: false,
    backgroundColor: '#FFFFFF'
  },
  data: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlRFU1QtMDAxIiwidG90YWwiOjUwMDAsInN1YnRvdGFsIjo1MDAwLCJkZXNjcmlwdGlvbiI6IlRoaXMgaXMgYW4gb3JkZXIgZnJvbSB0aGUgc2RrIiwidGF4IjowLCJjdXJyZW5jeSI6IkpNRCIsImZlZXMiOltdLCJpdGVtcyI6W10sImZ1bGZpbGxlZCI6dHJ1ZSwic2hpcHBpbmdQZXJzb24iOnsibmFtZSI6IlNoYW1pciBTYWRkbGVyIiwic3RyZWV0IjoiMSBUZXN0IEF2ZSIsImNpdHkiOiJLaW5nc3RvbiA2Iiwic3RhdGVPclByb3ZpbmNlTmFtZSI6IktpbmdzdG9uIiwicG9zdGFsQ29kZSI6IjAwMDAwIiwiY291bnRyeU5hbWUiOiJKYW1haWNhIn0sImJpbGxpbmdQZXJzb24iOnsibmFtZSI6IlNoYW1pciBTYWRkbGVyIiwic3RyZWV0IjoiMSBUZXN0IEF2ZSIsImNpdHkiOiJLaW5nc3RvbiA2Iiwic3RhdGVPclByb3ZpbmNlTmFtZSI6IktpbmdzdG9uIiwicG9zdGFsQ29kZSI6IjAwMDAwIiwiY291bnRyeU5hbWUiOiJKYW1haWNhIn0sImlhdCI6MTc0Njc2NDQ3NX0.PL18At7kR4i3i3TS2pR2_csKtlUT1EetLgV1z5PfL_g",
  onReady: (data) => console.log("✅ Ready:", data),
  onSuccess: (data) => console.log("✅ Success:", data),
  onFailed: (err) => console.log("❌ Failed:", err),
  onError: (err) => console.log("❌ Error:", err),
  onCancel: () => console.log("⚠️ Cancelled"),
  onLoading: () => console.log("⏳ Loading...")
});

Saving cards

import { initCard } from '@dimepay/web-sdk';

const payload = {
  id: 'CARD-001', //Generated from the requester
  webhookUrl: 'https://webhook.com/callback'
};

const signedData = jwt.sign(payload, 'sk_hokHTudA3hGsz_1rrs-70');

const finalPayload = {
  data: signedData
};

const resp = await fetch(
  `https://sandbox.api.dimepay.app/dapi/v1/card-request`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      client_key: "ck_jtfEtqbrX2Nf7U_evqKVy"
    },
    body: JSON.stringify(finalPayload)
  }
);

const cardRequestResponse = await resp.json();

const widget = initCard({
  mountId: "dimepay-widget",
  test: false,
  card_request_token: cardRequestResponse.token,
  client_id: "ck_jtfEtqbrX2Nf7U_evqKVy",
  origin: window.origin,
  styles: {
    primaryColor: '#000000',
    buttonColor: '#000000',
    buttonTextColor: '#FFFFFF',
    noBorderRadius: false,
    backgroundColor: '#FFFFFF'
  },
  data: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTc0ODAyOTk5MjcyOCwiY3VycmVuY3kiOiJVU0QiLCJjYXJkaG9sZGVyX2ZpcnN0X25hbWUiOiJKb2huIiwiY2FyZGhvbGRlcl9sYXN0X25hbWUiOiJEb2UiLCJjYXJkaG9sZGVyX2VtYWlsIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJjYXJkX251bWJlciI6IjUxMDAyNzAwMDAwMDAwMjMiLCJjYXJkX2N2diI6IjEyMyIsImNhcmRfZXhwaXJ5IjoiMjUxMiIsImNhcmRfYWRkcmVzcyI6IjEyMyBNYWluIFN0cmVldCIsImNhcmRfY2l0eSI6Ik5ldyBZb3JrIiwiY2FyZF9jb3VudHJ5IjoiVVMiLCJjYXJkX3Bvc3RhbF9jb2RlIjoiMTAwMDEiLCJpYXQiOjE3NDgwMjk5OTJ9.xEDHEUojWibmT6Pxzo1nhd83Xtv-RPdmcUDZCE5i35w",
  onReady: (data) => console.log("✅ Ready:", data),
  onSuccess: (data) => console.log("✅ Success:", data),
  onFailed: (err) => console.log("❌ Failed:", err),
  onError: (err) => console.log("❌ Error:", err),
  onCancel: () => console.log("⚠️ Cancelled"),
  onLoading: () => console.log("⏳ Loading...")
});

🔐 Secure Flows with JWT

You must generate a signed JWT on your backend and pass it to the SDK.

Example data, JWT payload:

{
  "id": "ORDER-001",
  "total": 5000,
  "subtotal": 5000,
  "description": "This is an order from the sdk",
  "tax": 0,
  "currency": "JMD",
  "fees": [ ],
  "items": [
    {
      "id": "xxxx-xxxx-xxxx-xxxx",
      "price": 1060,
      "sku": "ABCA-IAC",
      "quantity": 1,
      "shortDescription": "",
      "name": "iMac",
      "imageUrl": "https://example.com/images/xxxxxx.jpg",
      "merchant_id": null, // Only required for Dime bridge
      "selectedOptions": [
        {
          "name": "Color",
          "value": "red",
          "type": "CHOICE"
        }
      ]
    }
  ],
  "fulfilled": true,
  "shippingPerson": {
    "name": "Michael Scott",
    "email": "[email protected]",
    "companyName": "",
    "street": "555 Lackawanna Ave",
    "city": "Scranton",
    "countryCode": "US",
    "countryName": "United States",
    "postalCode": "18508",
    "stateOrProvinceCode": "PA",
    "stateOrProvinceName": "Pennsylvania",
    "phone": ""
  },
  "billingPerson": {
    "name": "Michael Scott",
    "email": "[email protected]",
    "companyName": "",
    "street": "555 Lackawanna Ave",
    "city": "Scranton",
    "countryCode": "US",
    "countryName": "United States",
    "postalCode": "18508",
    "stateOrProvinceCode": "PA",
    "stateOrProvinceName": "Pennsylvania",
    "phone": ""
  },
  "split": null, // Only required for Dime bridge
  "webhookUrl": "https://your-service/path"
}

For Dime Bridge, add the block below to the payload:

      split: [
        {
          fee: 10,
          merchant_id: 'm4D8mQ1wMrdTUIg',
          amount: 500,
        },
        {
          fee: 30,
          merchant_id: 'm7UarSiV9zWxN6v',
          amount: 1500,
        }
      ]

Also for Dime bridge the corresponding item needs to be tagged with a merchant_id

Use a backend library like jsonwebtoken (Node.js) to sign the token using your Dime Pay secret. Please do not expose your secret token on the client for security reasons.

const jwt = require('jsonwebtoken'); const payload = { /* fields above */ }; const signedData = jwt.sign(payload, 'your_secret_key');


⚙️ Configuration Options

| Option | Type | Required | Description | |--------------------------|-----------|---------|--------------------------------------------------------------------| | mountId | string | ✅ | The ID of the DOM element to mount the iframe | | currency | string | ✅ | The Currency for the order | | total | string | ✅ | The total amount the customer is paying | | data | string | ✅ | JWT containing payment info | | client_id | string | ✅ | Client id provided by your pair of API keys | | order_id | string | ✅ | Order id for the payment request. Order Id and data.id is the same | | card_request_token | string | ✅ | Card request token for the card tokenization request | | payment_methods | object | optional | Defines payment methods to enable | | styles | object | optional | Defines styles for the payment form | | styles.primaryColor | string | optional | Primary color in hex format | | styles.buttonColor | string | optional | Button color in hex format | | styles.buttonTextColor | string | optional | Button text color in hex format | | styles.backgroundColor | string | optional | Background color in hex format | | styles.noBorderRadius | boolean | optional | Border radius can be rounded or squared | | test | boolean | optional | Set to true if testing in sandbox | | onReady | func | optional | Callback when payment form is ready | | onSuccess | func | optional | Callback when payment is successful | | onFailed | func | optional | Callback when a payment failed | | onError | func | optional | Callback when an error occurs and payment form is invalid | | onLoading | func | optional | Callback when widget starts loading |


💡 Example (Plain HTML + Script)

<script type="module">
  import { initPayment } from '@dimepay/web-sdk';

  initPayment({
    mountId: "dimepay-widget",
    total: 5000,
    currency: "JMD",
    test: false,
    order_id: "TEST-001",
    client_id: "ck_jtfEtqbrX2Nf7U_evqKVy",
    payment_methods: {
      apple_pay: true,
      google_pay: true,
      samsung_pay: true
    },
    origin: window.origin,
    styles: {
      primaryColor: '#000000',
      buttonColor: '#000000',
      buttonTextColor: '#FFFFFF',
      noBorderRadius: false,
      backgroundColor: '#FFFFFF'
    },
    data: { jwt_token },
    onReady: (data) => console.log("✅ Ready:", data),
    onSuccess: (data) => console.log("✅ Success:", data),
  });
</script>

Table: Test Card Numbers

| Card Brand | BIN | Card Number | Expiration Date | CVV | |-------------------|---------|-----------------|-----------------|------| | Visa | 411111 | 1111111111 | 12/2025 | 123 | | Mastercard | 555555 | 55555554444 | 02/2026 | 265 | | American Express | 378282 | 246310005 | 03/2026 | 7890 | | Cartes Bancaires | 436000 | 0001000005 | 04/2040 | 123 | | Carnet | 506221 | 0000000009 | 04/2024 | 123 | | China UnionPay | 627988 | 6248094966 | 04/2040 | 123 | | Diners Club | 305693 | 09025904 | 04/2040 | 123 | | Discover | 644564 | 4564456445 | 04/2040 | 123 | | JCB | 353011 | 13333 0000 | 04/2040 | 123 | | Maestro | 675964 | 9826438453 | 04/2040 | 123 | | Mada | 446404 | 0000000007 | 04/2040 | 123 | | ELO | 451416 | 0000000003 | 04/2040 | 123 | | JCrew | 515997 | 1500000005 | 04/2040 | 123 | | EFTPOS | 401795 | 000000000009 | 04/2040 | 123 | | Meeza | 507808 | 3000000002 | 04/2040 | 123 |


Using a CDN

The dimepay web-sdk script is also available on the unpkg CDN.

Option 1: Use type="module" in your HTML

If you're loading the SDK in a browser and want to use ESM syntax:

<script type="module">
  import { initPayment } from 'https://unpkg.com/@dimepay/[email protected]/dist/dimepay.es.js';

  initPayment({
    mountId: 'dimepay-widget',
  });
</script>

Option 2: Use UMD format in your HTML

UMD format is the most compatible format for usage via script tag in any browser.

<script type="module">
  import { initPayment } from 'https://unpkg.com/@dimepay/[email protected]/dist/dimepay.umd.js';

  initPayment({
    mountId: 'dimepay-widget',
  });
</script>

Test Card Numbers

| Card Brand | BIN | Card Number | Expiration Date | CVV | |-------------------|---------|-----------------|-----------------|------| | Visa | 411111 | 1111111111 | 12/2025 | 123 | | Mastercard | 555555 | 55555554444 | 02/2026 | 265 | | American Express | 378282 | 246310005 | 03/2026 | 7890 | | Cartes Bancaires | 436000 | 0001000005 | 04/2040 | 123 | | Carnet | 506221 | 0000000009 | 04/2024 | 123 | | China UnionPay | 627988 | 6248094966 | 04/2040 | 123 | | Diners Club | 305693 | 09025904 | 04/2040 | 123 | | Discover | 644564 | 4564456445 | 04/2040 | 123 | | JCB | 353011 | 13333 0000 | 04/2040 | 123 | | Maestro | 675964 | 9826438453 | 04/2040 | 123 | | Mada | 446404 | 0000000007 | 04/2040 | 123 | | ELO | 451416 | 0000000003 | 04/2040 | 123 | | JCrew | 515997 | 1500000005 | 04/2040 | 123 | | EFTPOS | 401795 | 000000000009 | 04/2040 | 123 | | Meeza | 507808 | 3000000002 | 04/2040 | 123 |


🧾 Changelog

[1.0.11] - 2025-08-19

  • Add support for Dime Bridge

[1.0.10] - 2025-06-25

  • Add support for Apple Pay, Google Pay, Samsung Pay

[1.0.9] - 2025-05-27

  • Add support for ES and UMD usages

[1.0.7] - 2025-05-23

  • Add support for saving cards

[1.0.5] - 2025-05-14

  • Add support for webhook urls

[1.0.0] - 2025-05-06

  • 🚀 Initial public release
  • 🧱 iframe-based payment widget injection
  • ✅ Supports onSuccess, onError callbacks
  • 🧩 Configurable via mountId, data

🛡️ License

MIT License © Dime Pay