The PayPath Web SDK is a library designed to make payment integration simple, secure, and scalable for web applications. It provides easy-to-use APIs for performing payment transactions, managing users, and interacting with the PayPath Payment Gateway. This SDK is suitable for merchants and developers who want to integrate payment processing features into their websites.
- Overview
- Features
- Installation
- Quick Start
- Configuration
- API Reference
- Error Handling
- Security Considerations
- Testing
- Contribution
- License
The PayPath Web SDK allows you to easily integrate PayPath Payment Gateway functionality into your web application. It provides methods to:
- Create and process payments with credit cards, virtual bank issuers (VBA), and tokenized cards.
- Handle user management, including CRUD operations for merchants and payers.
- Manage notifications and send receipts.
- Access and manage transaction histories.
- Payment Processing: Interact with Vuiral Bank Issuer (VBA) for verifying and processing payments.
- Tokenization: Securely tokenize sensitive card details.
- User Management: CRUD operations for managing users (merchants and payers).
- Notifications: Send notifications via SMS and email.
- Transaction Handling: Query and manage transaction histories.
- Security: Implements PCI-DSS compliance, encryption, and secure communication standards.
To install the PayPath_Web_SDK, you can use npm:
npm install paypath-web-sdk
Or use yarn:
yarn add paypath-web-sdk
Here’s how you can quickly get started with PayPath_Web_SDK:
-
Initialize the SDK:
import PayPath from 'paypath-web-sdk'; const paypath = new PayPath({ apiKey: 'your-api-key', environment: 'production', // or 'sandbox' });
-
Process a Payment:
paypath.createPayment({ payerId: 'payer123', merchantId: 'merchant456', amount: 100.00, currency: 'USD', cardDetails: { cardNumber: '4111111111111111', expirationDate: '12/25', cvv: '123' } }).then(response => { console.log('Payment successful:', response); }).catch(error => { console.error('Payment failed:', error); });
-
Tokenize Card Information:
paypath.tokenizeCard({ cardNumber: '4111111111111111', expirationDate: '12/25', cvv: '123' }).then(token => { console.log('Token created:', token); }).catch(error => { console.error('Tokenization failed:', error); });
To configure the SDK, pass an options object to the SDK during initialization:
const paypath = new PayPath({
apiKey: 'your-api-key', // Required: API Key from PayPath
environment: 'sandbox', // Optional: Set 'production' or 'sandbox'
baseURL: 'https://api.paypath.com' // Optional: Override default API URL
});
Parameter | Type | Description |
---|---|---|
apiKey | string |
Your PayPath API key (required). |
environment | string |
sandbox or production (default: production ). |
baseURL | string |
API base URL, default is PayPath’s production endpoint. |
To initialize the SDK:
const paypath = new PayPath({
apiKey: 'your-api-key',
environment: 'sandbox'
});
To create a new payment:
paypath.createPayment({
payerId: 'payer123',
merchantId: 'merchant456',
amount: 100.00,
currency: 'USD',
token: 'secure_token' // Optional: Can use tokenized card details
}).then(response => {
console.log('Payment successful:', response);
}).catch(error => {
console.error('Payment failed:', error);
});
To tokenize card details:
paypath.tokenizeCard({
cardNumber: '4111111111111111',
expirationDate: '12/25',
cvv: '123'
}).then(token => {
console.log('Token created:', token);
}).catch(error => {
console.error('Tokenization failed:', error);
});
paypath.createPayer({
email: '[email protected]',
preferredPaymentMethodId: 'method789',
phone: '+1234567890'
}).then(response => {
console.log('Payer created:', response);
}).catch(error => {
console.error('Error creating payer:', error);
});
paypath.updateMerchant({
merchantId: 'merchant456',
email: '[email protected]',
isVerified: true
}).then(response => {
console.log('Merchant updated:', response);
}).catch(error => {
console.error('Error updating merchant:', error);
});
To retrieve a payer’s transaction history:
paypath.getPayerTransactions('payer123').then(transactions => {
console.log('Transactions:', transactions);
}).catch(error => {
console.error('Error fetching transactions:', error);
});
The SDK provides error handling for different types of failures:
paypath.createPayment({
payerId: 'payer123',
amount: 100.00
}).then(response => {
console.log('Payment successful');
}).catch(error => {
if (error.response) {
console.error('Server Error:', error.response.data);
} else {
console.error('Network Error:', error.message);
}
});
- API Errors: Issues with the API request (e.g., invalid API key).
- Validation Errors: Missing or invalid fields (e.g., missing amount).
- Network Errors: Issues connecting to the API.
- PCI-DSS Compliance: Ensure your application complies with PCI-DSS standards when using the PayPath SDK. Sensitive information, such as card details, should never be logged or stored in an insecure way.
- HTTPS: Always use HTTPS for secure communication between your web app and PayPath’s API.
- Tokenization: Use tokenized card details for transactions instead of handling raw card data.
You can run automated tests for PayPath_Web_SDK using a testing framework like Jest or Mocha:
-
Install Jest:
npm install --save-dev jest
-
Run tests:
npm test
-
Writing Tests: Sample unit test:
test('should create a payment', async () => { const payment = await paypath.createPayment({ payerId: 'payer123', amount: 100.00 }); expect(payment.status).toBe('success'); });
If you want to contribute to the PayPath SDK:
- Fork the repository.
- Make changes in your forked copy.
- Submit a pull request with detailed notes on your changes.
The PayPath_Web_SDK is open-sourced software licensed under the MIT License.
This README.md offers a comprehensive guide to help developers get started with the PayPath_Web_SDK in a secure and efficient manner, covering everything from installation to API usage and error handling.