🎉 PhaJay is service now. Get Started

v1
Plugin and SDK
React Phajay

React PhaJay NPM Package

Features

  • 🏦 Payment Links - Single integration for all major Lao banks
  • 📱 QR Code Payments - Bank-specific QR codes with real-time monitoring
  • 💳 Credit Card Payments - Secure 3DS credit card processing
  • ⚡ React Components - Ready-to-use components with TypeScript support
  • 🎨 Customizable - Style with CSS classes, Tailwind CSS, or styled-components

Installation

Install the official react-phajay npm package:

npm install react-phajay

Or search for "react-phajay" on npmjs.com (opens in a new tab)

Quick Start

1. Setup Provider

import { PhaJayProvider } from 'react-phajay';
 
function App() {
  return (
    <PhaJayProvider config={{ secretKey: "your-secret-key" }}>
      {/* Your payment components */}
    </PhaJayProvider>
  );
}

2. Payment Components

import { PaymentQR, PaymentLink, PaymentCreditCard } from 'react-phajay';
 
// QR Code Payment
<PaymentQR 
  amount={50000}
  description="Coffee Payment"
  bank="BCEL"
  onSuccess={(response) => {
    console.log('QR Code:', response.qrCode);
    // Display QR code in your UI
  }}
  onPaymentSuccess={(data) => {
    console.log('Payment completed!', data);
  }}
/>
 
// Payment Link (redirects to payment page)
<PaymentLink 
  amount={100000}
  description="Order Payment"
  onSuccess={(response) => {
    // Auto redirects to payment page
    console.log('Redirecting to:', response.redirectURL);
  }}
/>
 
// Credit Card Payment (redirects to card form)
<PaymentCreditCard 
  amount={100}  // Amount in USD
  description="Premium Service"
  onSuccess={(response) => {
    // Auto redirects to card payment
    console.log('Payment URL:', response.paymentUrl);
  }}
/>

3. Custom Styling

// Using CSS classes
<PaymentQR 
  amount={25000}
  bank="BCEL"
  className="bg-blue-500 text-white px-4 py-2 rounded"
  onSuccess={(response) => console.log(response.qrCode)}
>
  Generate QR Code
</PaymentQR>
 
// Using Tailwind CSS
<PaymentLink 
  amount={50000}
  className="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-bold py-3 px-6 rounded-lg shadow-lg transform transition-all duration-200 hover:scale-105"
>
  Create Payment Link
</PaymentLink>

Configuration

Get your secret key from PhaJay Portal:

  1. Register and complete KYC verification
  2. Go to Key Management to get your secret key
  3. Configure callback URLs in Settings
// Basic configuration
const client = new PhaJayClient({
  secretKey: 'your-secret-key' // Required
});

Supported Banks

CodeBank Name
BCELBanque pour le Commerce Extérieur Lao
JDBJoint Development Bank
LDBLao Development Bank
IBIndochina Bank
STBST Bank Laos

Component Props Reference

PaymentQR

PropTypeRequiredDescription
amountnumber✅Payment amount in LAK
bankstring✅Bank code (BCEL, JDB, LDB, IB, STB)
descriptionstring✅Payment description
onSuccess(response) => void✅Required: Handle QR code data
onPaymentSuccess(data) => void❌Real-time payment callback
classNamestring❌Custom CSS classes
childrenReactNode❌Button text (default: "Generate QR Code")

PaymentLink

PropTypeRequiredDescription
amountnumber✅Payment amount in LAK
descriptionstring✅Payment description
onSuccess(response) => void❌Payment link created callback
autoRedirectboolean❌Auto redirect (default: true)
classNamestring❌Custom CSS classes
childrenReactNode❌Button text (default: "Create Payment Link")

PaymentCreditCard

PropTypeRequiredDescription
amountnumber✅Payment amount in USD
descriptionstring✅Payment description
onSuccess(response) => void❌Payment URL created callback
autoRedirectboolean❌Auto redirect (default: true)
classNamestring❌Custom CSS classes
childrenReactNode❌Button text (default: "Pay with Credit Card")

Error Handling

import { PhaJayAPIError } from 'react-phajay';
 
try {
  const paymentLink = await client.paymentLink.createPaymentLink({
    amount: 50000,
    description: 'Test payment'
  });
} catch (error) {
  if (error instanceof PhaJayAPIError) {
    console.error('API Error:', error.code, error.message);
  }
}

Last updated: 6 months ago