JavaScript SDK

Integrate Noxipay into your web applications

JavaScript SDK Installation

The Noxipay JavaScript SDK provides a simple interface for integrating payment processing into your web applications.

Installation via NPM

Terminal
npm install noxipay-js

CDN Installation

HTML
<script src="https://js.noxipay.com/v1/noxipay.js"></script>

Basic Usage

JavaScript
// Initialize the client const noxipay = require('noxipay-js'); const client = new noxipay('pk_live_your_api_key_here'); // Create a payment const payment = await client.payments.create({ amount: 2500, currency: 'EUR', description: 'Payment for order #123', redirect_url: 'https://yoursite.com/success' }); console.log(payment.payment_url);

Payment Methods

Create Payment

JavaScript
const payment = await client.payments.create({ amount: 2500, currency: 'EUR', description: 'Payment for order #123', customer: { email: 'customer@example.com', name: 'John Doe' }, redirect_url: 'https://yoursite.com/success' });

Get Payment

JavaScript
const payment = await client.payments.get('pay_1234567890');

List Payments

JavaScript
const payments = await client.payments.list({ limit: 10, status: 'completed' });

Error Handling

JavaScript
try { const payment = await client.payments.create(data); } catch (error) { if (error.type === 'api_error') { console.log('API Error:', error.message); } else if (error.type === 'invalid_request_error') { console.log('Invalid Request:', error.message); } else { console.log('Other Error:', error.message); } }

Webhook Handling

Node.js
const express = require('express'); const app = express(); app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => { const signature = req.headers['x-noxipay-signature']; const payload = req.body; try { const event = client.webhooks.verify(payload, signature); if (event.type === 'payment.completed') { const paymentId = event.data.id; // Handle successful payment } res.json({received: true}); } catch (err) { res.status(400).send('Webhook signature verification failed'); } });

Browser Support

The Noxipay JavaScript SDK supports all modern browsers:

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+