1.0.0 • Published 8 months ago

@mjekott/payment v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@mjekott/payment

A React library for integrating payment processing into your applications.

Installation

npm install @mjekott/payment
# or
yarn add @mjekott/payment

Usage

First, wrap your application with the PaymentProvider:

import { PaymentProvider } from "@mjekott/payment";

function App() {
  return (
    <PaymentProvider
      config={{
        apiKey: "your-api-key",
        environment: "sandbox", // or 'production'
      }}
    >
      <YourApp />
    </PaymentProvider>
  );
}

Then, use the PaymentButton component in your application:

import { PaymentButton } from "@mjekott/payment";

function Checkout() {
  return (
    <PaymentButton
      config={{
        amount: "10000", // Amount in base unit (e.g., 10000 = $100.00)
        phoneNumber: "+2348081234567",
        currencyCollected: "USD",
        currencySettled: "USD",
        email: "customer@example.com",
        payerId: "customer_123",
        redirectUrl: "https://your-domain.com/payment/success",
        webhookUrl: "https://your-domain.com/api/webhook",
        transactionId: "txn_123456789",
      }}
      onError={(error) => {
        console.error("Payment error:", error);
      }}
    />
  );
}

Types

PaymentConfig

interface PaymentConfig {
  amount: string;
  phoneNumber: string;
  currencyCollected: string;
  currencySettled: string;
  email: string;
  payerId: string;
  redirectUrl?: string;
  webhookUrl?: string;
  transactionId?: string;
}

License

MIT

1.0.0

8 months ago

0.0.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago