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

mileston-payment-client-preview

v0.7.6

Published

Preview version of customizable payment components, hooks and functions for Mileston payments

Readme

Mileston Payment Client

Mileston Payment Client is a versatile payment button component library designed for seamless integration into projects using plain JavaScript, React, Angular, and Vue. It provides a customizable button that triggers a payment popup and notifies you when the payment process is complete. Other components will be added in future updates. Feel free to open a PR! Contact [email protected] if you have any issues integrating this.

Installation

First, install the package via npm:

npm install mileston-payment-client

Usage

Core Class (Vanilla JavaScript)

For plain JavaScript users, the library provides the MilestonPayButton class that can be instantiated and used directly.

Example

import { MilestonPayButton } from 'mileston-payment-client';

const container = document.getElementById('payment-button-container');

const payButton = new MilestonPayButton(container, {
  buttonText: 'Pay Now',
  onPaymentComplete: () => {
    console.log('Payment complete!');
  },
  onPaymentDataReceived: (data) => {
    console.log('Payment data received:', data);
  },
  onPaymentError: (error) => {
    console.error('Payment error:', error);
  },
  paymentUrl: 'https://example.com/payment',
});

// Optional: Update button text or styles later
payButton.updateButtonText('Checkout');
payButton.updateButtonStyle({ backgroundColor: 'blue', color: 'white' });

React Integration

For React projects, the library provides a dedicated React component.

Example

import React from 'react';
import { PayButton } from 'mileston-payment-client';

function App() {
  return (
    <div>
      <PayButton
        onPaymentComplete={() => console.log('Payment complete!')}
        onPaymentDataReceived={(data) => console.log('Payment data received:', data)}
        onPaymentError={(error) => console.error('Payment error:', error)}
        paymentUrl="https://checkout.mileston.co/payment"
        style={{ backgroundColor: 'green', color: 'white' }}
      >
        Pay Now
      </PayButton>
    </div>
  );
}

export default App;

Angular Integration

For Angular projects, the library provides a dedicated Angular component.

Example

import { Component } from '@angular/core';
import { MilestonPayButton } from 'mileston-payment-client';

@Component({
  selector: 'app-root',
  template: `<div id="payment-button-container"></div>`,
})
export class AppComponent {
  ngOnInit() {
    const container = document.getElementById('payment-button-container');

    const payButton = new MilestonPayButton(container, {
      buttonText: 'Pay Now',
      onPaymentComplete: () => {
        console.log('Payment complete!');
      },
      onPaymentDataReceived: (data) => {
        console.log('Payment data received:', data);
      },
      onPaymentError: (error) => {
        console.error('Payment error:', error);
      },
      paymentUrl: 'https://example.com/payment',
    });
  }
}

Vue Integration

For Vue projects, the library provides a dedicated Vue component.

Example

<template>
  <div id="payment-button-container"></div>
</template>

<script>
import { MilestonPayButton } from 'mileston-payment-client';

export default {
  name: 'App',
  mounted() {
    const container = this.$el.querySelector('#payment-button-container');

    const payButton = new MilestonPayButton(container, {
      buttonText: 'Pay Now',
      onPaymentComplete: () => {
        console.log('Payment complete!');
      },
      onPaymentDataReceived: (data) => {
        console.log('Payment data received:', data);
      },
      onPaymentError: (error) => {
        console.error('Payment error:', error);
      },
      paymentUrl: 'https://example.com/payment',
    });
  },
};
</script>

Customization Options

Configuration Options

All integrations support the following options:

| Option | Type | Required | Description | |---------------------|-----------------------|----------|-------------------------------------------------------------| | container | HTMLElement | Yes | The DOM element to attach the button to (Core only). | | buttonText | string | Yes | Text displayed on the button. | | onPaymentComplete | () => void | Yes | Callback triggered when the payment is complete. | | onPaymentDataReceived | (data: { walletAddress: string, id: string }) => void | Yes | Callback triggered when payment data is received. | | onPaymentError | (error: Error) => void | Yes | Callback triggered when payment fails. | | paymentUrl | string | No | URL of the payment page. | | paymentType | "payment-link" \| "invoice" \| "recurring-payment" | No | Type of payment (used to auto-generate paymentUrl). | | paymentId | string | No | ID of the payment (used to auto-generate paymentUrl). | | buttonStyle | Partial<CSSStyleDeclaration> | No | Custom styles for the button. |

API Methods

  • updateButtonText(text: string): void: Updates the button's text.
  • updateButtonStyle(styles: Partial<CSSStyleDeclaration>): void: Updates the button's styles.
  • destroy(): void: Removes the button from the DOM and cleans up event listeners.

Development Notes

Common Issues

  • TypeScript Errors: Ensure your tsconfig.json includes:

    {
      "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
    }
  • JSX Error: If you see errors about JSX not being set, make sure your tsconfig.json has:

    {
      "jsx": "react-jsx"
    }

Why vite/client?

If you see references to vite/client in the project, it's likely because your Vue component requires specific module resolution for .vue files. Ensure you include it in tsconfig.json under types:

{
  "compilerOptions": {
    "types": ["vite/client"]
  }
}

License

This library is licensed under the MIT License. See the LICENSE file for details.