🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@unify-payment/node

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unify-payment/node

UnifyPayment is a TypeScript package that provides a unified interface for integrating with multiple payment providers, such as Stripe, LemonSqueezy, and more. With UnifyPayment, developers can easily switch between different payment providers without hav

0.0.3
Source
npm
Version published
Weekly downloads
3
-70%
Maintainers
1
Weekly downloads
 
Created
Source

UnifyPayment

UnifyPayment is a TypeScript package that provides a unified interface for integrating with multiple payment providers, such as Stripe, LemonSqueezy, and more. With UnifyPayment, developers can easily switch between different payment providers without having to rewrite their payment logic.

Features

  • Unified API: Use a single class to interact with various payment providers.
  • Provider Agnostic: Switch between different payment providers with minimal code changes.
  • Easy Integration: Simplifies the integration process with well-documented methods and examples.
  • Extensible: Easily add support for new payment providers as needed.

Providers

  • Stripe: (Checkout, Webhook) will add more functionality later.
  • LemonSqueezy: (Checkout, Webhook) will add more functionality later.
  • Paddle: (Checkout, Webhook) will add more functionality later.
  • PayPal: (upcoming).
  • RazorPay: (upcoming).
  • GooglePay: (planing).
  • Shopify: (planing).
  • SSLCommerz: (planing).

Installation

To install the package, run the following command:

npm install @unify-payment/node

Usage

// Stripe
const unify = new UnifyPayment({
  stripe: new Stripe(process.env.STRIPE_API_SECRET_KEY!),
});
const redirect = await unify.stripe.getCheckoutUrl(stripePayload);

// LemonSqueezy
const unify = new UnifyPayment({
  lemonsqueezy: new LemonSqueezy(process.env.LEMON_SECRET_KEY!),
});
const redirect = await unify.lemonsqueezy.getCheckoutUrl(lemonsqueezyPayload);

Webhook

// Stripe
const unify = new UnifyPayment({
  stripe: new Stripe(stripeKey),
});

const sign = c.req.header("Stripe-Signature");
if (!sign) throw new Error("No Signature");

const webhookEvent = await unify.stripe.webhook.verifySignature({
  signature: sign,
  secret: "PUT YOUR WEBHOOK SECRET HERE",
  body: await c.req.text(),
});

if ("error" in webhookEvent) throw new Error(webhookEvent.error.message);

switch (webhookEvent.event.type) {
  case "checkout.session.async_payment_succeeded":
    break;

  default:
    break;
}

// LemonSqueezy
const unify = new UnifyPayment({
  lemonsqueezy: new LemonSqueezy(lemonsqueezyKey),
});

const sign = c.req.header("X-Signature");
if (!sign) throw new Error("No Signature");

const webhookEvent = await unify.lemonsqueezy.webhook.verifySignature({
  signature: sign,
  secret: "PUT YOUR WEBHOOK SECRET HERE",
  body: await c.req.text(),
  x_event: c.req.header("X-Event-Name")!,
});

if ("error" in webhookEvent) throw new Error(webhookEvent.error.message);

switch (webhookEvent.type) {
  case "order_refunded":
    break;

  default:
    break;
}

Contributing

We welcome contributions to UnifyPayment! If you'd like to help improve this package, here's how you can contribute:

  • Fork the Repository: Start by forking the UnifyPayment repository on GitHub.

  • Clone Your Fork: Clone your fork to your local machine for development.

    git clone https://github.com/shakibhasan09/unify-payment
    
  • Create a Branch: Create a new branch for your feature or bug fix.

    git checkout -b feature/your-feature-name
    
  • Create: apps directory and setup a nodejs project inside the apps directory.

  • Add Dependencies: Add @unify-payment/node as a dependencies to the apps/nodejs-project/package.json file.

  • Make Changes: Implement your changes or improvements to the codebase.

  • Test Your Changes: Ensure that your changes don't break any existing functionality and add tests if necessary.

  • Commit Your Changes: Commit your changes with a clear and descriptive commit message.

    git commit -m "Add a brief description of your changes"
    
  • Push to Your Fork: Push your changes to your GitHub fork

    git push origin feature/your-feature-name
    
  • Submit a Pull Request: Go to the original UnifyPayment repository and submit a pull request with a clear description of your changes.

Guidelines

  • Follow the existing code style and conventions.
  • Write clear, concise commit messages.
  • Add or update tests for new features or bug fixes.
  • Update documentation as needed.
  • Be respectful and constructive in discussions and code reviews.

Special Thanks

A special thanks to Piyush Garg (@piyushgargdev) for suggesting the idea behind this package. Piyush is a talented developer and content creator who shares valuable insights and ideas in the world of software development. His suggestion was the spark that led to the creation of UnifyPayment, aiming to simplify payment integrations for developers.

We appreciate Piyush's contribution to the developer community and encourage you to check out his YouTube channel for more inspiring content and innovative ideas in the tech space.

FAQs

Package last updated on 24 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts