payment-gateway-connector
v1.0.0
Published
Payment Gateway Connector is a modular package that allows you to connect to various payment gateways such as Stripe and PayPal. It provides a unified interface for processing payments across different platforms.
Downloads
2
Readme
Payment Gateway Connector
Payment Gateway Connector is a modular package for connecting to various payment gateways. It supports adding new gateways and processing payments using a unified interface.
Features
- Modular Design: Easily add support for new payment gateways.
- Unified API: Use a consistent API for processing payments.
- Dynamic Gateway Loading: Automatically load and configure supported gateways.
Installation
Install the package and its dependencies:
npm install stripe @paypal/checkout-server-sdk
Usage
- Create a PaymentGatewayConnector Instance
const PaymentGatewayConnector = require('./index'); const connector = new PaymentGatewayConnector();
- Configure and Use a Payment Gateway
- Stripe
connector.useGateway('stripe', { apiKey: 'YOUR_STRIPE_API_KEY' });
- PayPal
connector.useGateway('paypal', { sandbox: true, clientId: 'YOUR_PAYPAL_CLIENT_ID', clientSecret: 'YOUR_PAYPAL_CLIENT_SECRET' });
- Example Gateway
connector.useGateway('exampleGateway', { /* options */ });
- Process a Payment
const paymentDetails = {
paymentMethodId: 'YOUR_PAYMENT_METHOD_ID' // For Stripe
// For PayPal or other gateways, additional details may be needed
};
connector.processPayment(10, 'USD', paymentDetails)
.then(result => {
console.log('Payment processed successfully:', result);
})
.catch(error => {
console.error('Payment processing error:', error);
});