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

monegasy-js

v1.0.6

Published

SDK JavaScript officiel pour intégrer les paiements Monegasy

Readme

Monegasy Payment SDK

npm version npm downloads License

SDK JavaScript officiel pour intégrer les paiements Monegasy à votre application web.

📦 Installation

npm install monegasy-js

Ou avec Yarn:

yarn add monegasy-js

Ou via CDN:

<!-- CDN Monegasy (recommandé) -->
<script src="https://cdn.monegasy.com/v1/monegasy-sdk.umd.min.js"></script>

<!-- Ou via jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/monegasy-js@latest/dist/monegasy-sdk.umd.min.js"></script>

<!-- Ou via unpkg -->
<script src="https://unpkg.com/monegasy-js@latest/dist/monegasy-sdk.umd.min.js"></script>

🚀 Démarrage Rapide

1. Initialiser le SDK

import MonegasySDK from "monegasy-js";

const monegasy = new MonegasySDK({
  apiKey: "YOUR_API_KEY",
  sandbox: false, // true pour le mode test
});

2. Créer un bouton de paiement

await monegasy.renderPaymentButton(
  {
    amount: 50000,
    description: "iPhone 15 Pro",
    buttonText: "Payer avec Monegasy",
    onSuccess: (payment) => {
      console.log("Paiement réussi!", payment);
    },
  },
  "#payment-button"
);

📚 Documentation

Configuration

interface MonegasyConfig {
  apiKey: string; // Clé API (requis)
  baseURL?: string; // URL de l'API (optionnel)
  webURL?: string; // URL de la page de paiement (optionnel)
  sandbox?: boolean; // Mode test (optionnel)
}

Méthodes

createPaymentLink()

Crée un lien de paiement unique.

const payment = await monegasy.createPaymentLink({
  amount: 50000, // Montant en Ariary (requis)
  description: "Description", // Description (requis)
  productName: "Produit", // Nom du produit (optionnel)
  productImage: "https://...", // URL image (optionnel)
  metadata: { key: "value" }, // Données custom (optionnel)
  successUrl: "https://...", // URL succès (optionnel)
  cancelUrl: "https://...", // URL annulation (optionnel)
  webhookUrl: "https://...", // URL webhook (optionnel)
  expiresInHours: 24, // Expiration en heures (défaut: 24)
});

console.log(payment.paymentUrl); // URL de paiement web
console.log(payment.mobileDeepLink); // Deep link mobile

getPaymentLink()

Récupère les détails d'un paiement.

const payment = await monegasy.getPaymentLink("pl_abc123");
console.log(payment.status); // "pending" | "paid" | "expired" | "cancelled"

openPaymentPopup()

Ouvre le paiement dans une popup.

const popup = monegasy.openPaymentPopup("pl_abc123", {
  width: 500,
  height: 700,
});

redirectToPayment()

Redirige vers la page de paiement.

monegasy.redirectToPayment("pl_abc123");

renderPaymentButton()

Crée et affiche un bouton de paiement.

await monegasy.renderPaymentButton(
  {
    amount: 50000,
    description: "Achat produit",
    buttonText: "Payer maintenant",
    buttonStyle: {
      background: "linear-gradient(to right, #2563eb, #9333ea)",
      borderRadius: "12px",
    },
    onSuccess: (payment) => {
      console.log("✅ Paiement réussi!", payment);
    },
    onError: (error) => {
      console.error("❌ Erreur:", error);
    },
    onCancel: () => {
      console.log("ℹ️ Paiement annulé");
    },
  },
  "#payment-container"
);

🌐 Utilisation avec Frameworks

React

import { useEffect } from "react";
import MonegasySDK from "monegasy-js";

function PaymentButton({ amount, productName }) {
  useEffect(() => {
    const monegasy = new MonegasySDK({
      apiKey: process.env.REACT_APP_MONEGASY_API_KEY,
      sandbox: false,
    });

    monegasy.renderPaymentButton(
      {
        amount,
        description: `Achat ${productName}`,
        productName,
        onSuccess: (payment) => {
          window.location.href = `/success?id=${payment.linkId}`;
        },
      },
      "#monegasy-button"
    );
  }, [amount, productName]);

  return <div id="monegasy-button"></div>;
}

Vue.js

<template>
  <div ref="paymentButton"></div>
</template>

<script>
import { onMounted, ref } from "vue";
import MonegasySDK from "monegasy-js";

export default {
  props: ["amount", "productName"],
  setup(props) {
    const paymentButton = ref(null);

    onMounted(() => {
      const monegasy = new MonegasySDK({
        apiKey: import.meta.env.VITE_MONEGASY_API_KEY,
        sandbox: false,
      });

      monegasy.renderPaymentButton(
        {
          amount: props.amount,
          description: `Achat ${props.productName}`,
          productName: props.productName,
        },
        paymentButton.value
      );
    });

    return { paymentButton };
  },
};
</script>

Next.js

"use client";

import { useEffect } from "react";
import MonegasySDK from "monegasy-js";

export default function PaymentButton({ amount, productName }) {
  useEffect(() => {
    const monegasy = new MonegasySDK({
      apiKey: process.env.NEXT_PUBLIC_MONEGASY_API_KEY!,
      sandbox: false,
    });

    monegasy.renderPaymentButton(
      {
        amount,
        description: `Achat ${productName}`,
        onSuccess: (payment) => {
          window.location.href = `/success?id=${payment.linkId}`;
        },
      },
      "#monegasy-button"
    );
  }, [amount, productName]);

  return <div id="monegasy-button"></div>;
}

🔒 Sécurité

  • Ne jamais exposer votre clé API publiquement
  • Utilisez des variables d'environnement
  • Validez toujours les montants côté serveur

📖 Documentation Complète

Pour plus d'informations, consultez :

🐛 Support

📝 Licence

MIT © Monegasy


Fait avec ❤️ à Madagascar 🇲🇬