npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paysync

v1.2.4

Published

PaySync is a robust TypeScript library designed to offer a unified interface for seamless integration with multiple payment providers, including Stripe, LemonSqueezy, RozerPay and others. By using PaySync, developers can effortlessly switch between differ

Downloads

510

Readme

PaySync

PaySync is a robust TypeScript library designed to offer a unified interface for seamless integration with multiple payment providers, including Stripe, LemonSqueezy, RozerPay and others. By using PaySync, developers can effortlessly switch between different payment gateways without the need to overhaul their existing payment logic. This simplifies the process of managing diverse payment systems, providing flexibility and scalability while maintaining a consistent and efficient codebase.

Features

  • PaySync API: A unified interface to interact seamlessly with multiple payment providers through a single class..
  • 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 extendable to accommodate new payment providers, ensuring scalability and future-proofing the system.

Providers

  • Stripe: (Checkout, Webhook).
  • RazorPay: (comming soon).

Installation

To install the package, run the following command:

npm install paysync

Usage

// Stripe
const stripe = new PaySync.Stripe(process.env.STRIPE_SECRET_KEY!);

//This is just an Example data
const checkoutDetails = {
  payment_method_types: ["card"],
  line_items: [{ price: "price_1HjHdV2eZvKYlo2CtLzk2uIX", quantity: 1 }],
  mode: "payment",
  success_url: "https://example.com/success",
  cancel_url: "https://example.com/cancel",
};

const checkoutUrl = await stripe.generatePaymentURL(checkoutDetails);

Webhook

// Stripe
const stripe = new PaySync.Stripe(process.env.STRIPE_SECRET_KEY!);

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

const webhookPayload = {
  signatureHeader: signatureHeader,
  webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
  requestBody: await context.req.text(),
};

const webhookEvent = await stripe.validateWebhookSignature(webhookPayload);

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

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

  default:
    // Handle other event types if needed
    break;
}

Contributing

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

  1. Fork the Repository: Start by forking the PaySync repository on GitHub.

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

    git clone https://github.com/swarnendu19/PaySync
  3. Create a Branch: Create a new branch for your feature or bug fix.

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

  5. Add Dependencies: Add paysync as a dependencies to the apps/nodejs-project/package.json file.

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

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

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

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

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

Thank You