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

@filanodev/paygate-react

v0.1.2

Published

PayGateGlobal React hooks and components - Support FLOOZ and T-Money

Readme

@filanodev/paygate-react

npm version

Hooks et composants React pour l'intégration de PayGateGlobal - Support FLOOZ et T-Money.

📝 Package communautaire développé par Filano pour aider les développeurs React à intégrer plus rapidement PayGateGlobal.

Installation

npm install @filanodev/paygate-react
# ou
yarn add @filanodev/paygate-react
# ou
pnpm add @filanodev/paygate-react

Configuration

Provider

Enveloppez votre application avec le PayGateProvider :

import React from 'react'
import ReactDOM from 'react-dom/client'
import { PayGateProvider } from '@filanodev/paygate-react'
import App from './App'

ReactDOM.createRoot(document.getElementById('root')).render(
  <PayGateProvider
    authToken="your-paygate-token"
    verifySSL={false} // pour le développement local uniquement
  >
    <App />
  </PayGateProvider>
)

Usage avec les Hooks

Hook principal

import React from 'react'
import { usePayGate } from '@filanodev/paygate-react'

function PaymentComponent() {
  const { 
    initiatePayment, 
    loading, 
    error, 
    lastPayment, 
    clearError 
  } = usePayGate()

  const handlePayment = async () => {
    const result = await initiatePayment({
      phoneNumber: '+22890123456',
      amount: 1000,
      identifier: `ORDER_${Date.now()}`,
      network: 'FLOOZ',
      description: 'Test paiement React'
    })
    
    if (result) {
      console.log('Paiement initié:', result.txReference)
    }
  }

  return (
    <div>
      <button onClick={handlePayment} disabled={loading}>
        {loading ? 'Traitement...' : 'Payer 1000 FCFA'}
      </button>

      {error && (
        <div style={{ color: 'red' }}>
          {error}
          <button onClick={clearError}>×</button>
        </div>
      )}

      {lastPayment && (
        <div style={{ color: 'green' }}>
          Paiement initié: {lastPayment.txReference}
        </div>
      )}
    </div>
  )
}

Hook spécialisé pour l'initiation

import { usePaymentInitiation } from '@filanodev/paygate-react'

function InitiationComponent() {
  const { 
    initiate, 
    loading, 
    error, 
    paymentResult, 
    isSuccess, 
    reset 
  } = usePaymentInitiation()

  const handlePayment = async () => {
    const result = await initiate({
      phoneNumber: '+22890123456',
      amount: 1500,
      identifier: 'ORDER_123',
      network: 'TMONEY'
    })
    
    if (result) {
      console.log('Paiement:', result)
    }
  }

  return (
    <div>
      <button onClick={handlePayment} disabled={loading}>
        {loading ? 'Initiation...' : 'Initier paiement'}
      </button>
      
      {isSuccess && (
        <p>✅ Paiement réussi: {paymentResult.txReference}</p>
      )}
      
      <button onClick={reset}>Reset</button>
    </div>
  )
}

Hook pour vérification de statut avec polling

import { useState } from 'react'
import { usePaymentStatus } from '@filanodev/paygate-react'

function StatusComponent() {
  const [reference, setReference] = useState('')
  
  const { 
    status, 
    loading, 
    error, 
    isPolling, 
    check, 
    startPolling, 
    stopPolling, 
    reset 
  } = usePaymentStatus(reference, 5000) // polling toutes les 5s

  return (
    <div>
      <input 
        value={reference}
        onChange={(e) => setReference(e.target.value)}
        placeholder="TX_REFERENCE"
      />
      
      <button onClick={() => check()} disabled={loading}>
        Vérifier statut
      </button>
      
      <button onClick={startPolling} disabled={isPolling}>
        📡 Surveillance auto
      </button>
      
      <button onClick={stopPolling} disabled={!isPolling}>
        ⏹ Arrêter
      </button>

      {status && (
        <div>
          <strong>{status.message}</strong><br />
          Montant: {status.amount} FCFA<br />
          Méthode: {status.paymentMethod}
        </div>
      )}
    </div>
  )
}

Composants prêts à l'emploi

PaymentForm

Formulaire de paiement complet avec validation :

import { PaymentForm } from '@filanodev/paygate-react'

function App() {
  const handleSuccess = (result) => {
    console.log('Paiement réussi:', result)
    // Rediriger ou afficher confirmation
  }

  const handleError = (error) => {
    console.error('Erreur paiement:', error)
  }

  return (
    <PaymentForm 
      onSuccess={handleSuccess}
      onError={handleError}
      submitLabel="Payer maintenant"
      showReset={true}
      defaultDescription="Achat produit XYZ"
      identifierPrefix="SHOP"
    />
  )
}

StatusChecker

Composant pour vérifier les statuts :

import { StatusChecker } from '@filanodev/paygate-react'

function App() {
  const handleStatusUpdate = (status) => {
    console.log('Nouveau statut:', status)
  }

  const handleError = (error) => {
    console.error('Erreur:', error)
  }

  return (
    <StatusChecker 
      showPolling={true}
      pollInterval={3000}
      onStatusUpdated={handleStatusUpdate}
      onError={handleError}
    />
  )
}

API des Hooks

usePayGate()

Hook principal avec toutes les fonctionnalités :

const {
  // État
  loading: boolean,
  error: string | null,
  lastPayment: PaymentResponse | null,
  lastStatus: PaymentStatus | null,

  // Actions
  clearError: () => void,
  initiatePayment: (params) => Promise<PaymentResponse | null>,
  generatePaymentUrl: (params) => PaymentUrlResponse | null,
  checkPaymentStatus: (reference) => Promise<PaymentStatus | null>,
  checkPaymentStatusByIdentifier: (identifier) => Promise<PaymentStatus | null>,
  checkStatus: (reference) => Promise<PaymentStatus | null>,
  disburse: (params) => Promise<PaymentResponse | null>,
  checkBalance: () => Promise<Balance | null>,

  // Client direct
  client: PayGateClient
} = usePayGate()

usePaymentInitiation()

Hook spécialisé pour l'initiation de paiements :

const {
  loading: boolean,
  error: string | null,
  paymentResult: PaymentResponse | null,
  isSuccess: boolean,
  initiate: (params) => Promise<PaymentResponse | null>,
  reset: () => void,
  clearError: () => void
} = usePaymentInitiation()

usePaymentStatus(reference?, pollInterval?)

Hook pour la vérification de statut avec polling optionnel :

const {
  status: PaymentStatus | null,
  loading: boolean,
  error: string | null,
  isPolling: boolean,
  check: (ref?) => Promise<PaymentStatus | null>,
  startPolling: () => void,
  stopPolling: () => void,
  reset: () => void
} = usePaymentStatus(reference, pollInterval)

Types TypeScript

Le package inclut tous les types TypeScript :

import type { 
  PayGateProviderProps,
  UsePayGateState,
  PayGateNetwork,
  InitiatePaymentParams,
  PaymentStatus 
} from '@filanodev/paygate-react'

Gestion des erreurs

import { usePayGate, PayGateError } from '@filanodev/paygate-react'

function PaymentComponent() {
  const { initiatePayment } = usePayGate()

  const handlePayment = async () => {
    try {
      await initiatePayment(params)
    } catch (error) {
      if (error instanceof PayGateError) {
        console.error('Erreur PayGate:', error.status, error.message)
      }
    }
  }

  return <button onClick={handlePayment}>Payer</button>
}

Utilisation avec TypeScript

import React from 'react'
import { 
  PayGateProvider, 
  usePayGate,
  type PayGateNetwork,
  type InitiatePaymentParams 
} from '@filanodev/paygate-react'

interface PaymentFormData {
  phoneNumber: string
  amount: number
  network: PayGateNetwork
}

function TypedComponent() {
  const { initiatePayment } = usePayGate()

  const handleSubmit = async (data: PaymentFormData) => {
    const params: InitiatePaymentParams = {
      phoneNumber: data.phoneNumber,
      amount: data.amount,
      identifier: `ORDER_${Date.now()}`,
      network: data.network,
      description: 'Paiement TypeScript'
    }

    const result = await initiatePayment(params)
    console.log(result?.txReference)
  }

  // ... rest of component
}

Support

Pour toute question sur ce package, créez une issue sur GitHub.

Pour le support PayGateGlobal officiel :

Licence

MIT