Everything you need to integrate PayBridge into your application
All API requests should be made to:
https://your-domain.com/api/
Before accepting payments, add your payment gateway credentials in the dashboard.
Make a POST request to create a payment:
// Create a payment order
const response = await fetch('/api/payments.php?action=create', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 999, // Amount in base currency
currency: 'INR', // Currency code
gateway: 'razorpay', // Payment gateway
customer_name: 'John Doe',
customer_email: 'john@example.com',
customer_phone: '9876543210',
gst_rate: 18, // Optional: GST percentage
description: 'Order #123',
metadata: { // Optional: Custom data
product_id: 'prod_123',
user_id: 'user_456'
}
})
});
const data = await response.json();
// Response:
// {
// order_id: "order_abc123...",
// amount: 999,
// gst_amount: 179.82,
// total_amount: 1178.82,
// razorpay_order_id: "order_XYZ...", // For Razorpay
// razorpay_key: "rzp_test_...",
// status: "pending"
// }
PayBridge uses Razorpay's checkout.js for seamless payment collection.
<!-- Include Razorpay Script -->
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
async function initiatePayment() {
// 1. Create order on backend
const response = await fetch('/api/payments.php?action=create', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
amount: 1000,
currency: 'INR',
gateway: 'razorpay',
customer_name: 'Customer Name',
customer_email: 'customer@email.com',
gst_rate: 18
})
});
const orderData = await response.json();
// 2. Open Razorpay Checkout
const options = {
key: orderData.razorpay_key,
amount: orderData.total_amount * 100,
currency: orderData.currency,
order_id: orderData.razorpay_order_id,
name: 'Your Company',
description: 'Payment Description',
handler: async function(response) {
// 3. Verify payment on backend
const verifyRes = await fetch('/api/payments.php?action=verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
order_id: orderData.order_id,
gateway: 'razorpay',
payment_id: response.razorpay_payment_id,
razorpay_order_id: response.razorpay_order_id,
signature: response.razorpay_signature
})
});
const result = await verifyRes.json();
if (result.verified) {
alert('Payment successful!');
}
},
prefill: {
name: 'Customer Name',
email: 'customer@email.com'
},
theme: { color: '#3B82F6' }
};
new Razorpay(options).open();
}
</script>
Create a new admin account
Login with email and password
Request OTP for passwordless login
Create a new payment order (public)
Verify payment after completion (public)
Get payment status by order ID (public)
List all payment gateways
Create a new gateway
Update gateway settings
Delete a gateway
Configure these webhook URLs in your payment gateway dashboards to receive real-time payment updates:
/api/webhook/razorpay.php
/api/webhook/stripe.php
/api/webhook/cashfree.php
/api/webhook/paytm.php
To add a new payment gateway to PayBridge:
api/payments.phpapi/webhook/{gateway_name}.phpPayBridge auto-creates the following tables with _pcv suffix:
users_pcv - Admin user accountspayment_gateways_pcv - Gateway configurationstransactions_pcv - Payment transactionsinvoices_pcv - Generated invoicessettings_pcv - Application settingswebhook_logs_pcv - Webhook event logsTables are automatically created when you first access the API. Just configure your MySQL credentials in config.php.