1.0.0 • Published 8 months ago
@mjekott/payment v1.0.0
@mjekott/payment
A React library for integrating payment processing into your applications.
Installation
npm install @mjekott/payment
# or
yarn add @mjekott/paymentUsage
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