1.0.0 • Published 10 months ago

payment-gateway-connector v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

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

  1. Create a PaymentGatewayConnector Instance
    const PaymentGatewayConnector = require('./index');
    const connector = new PaymentGatewayConnector();
  2. 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 */ });
  3. 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);
});
1.0.0

10 months ago