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

@tiltbike/razorpay-checkout-js

v1.0.0

Published

Razorpay checkout.js loading utility

Downloads

17

Readme

Razorpay checkout.js ES Module

This is not an official package by Razorpay. It's just a simple wrapper for Razorpay's checkout.js script inspired from a similar wrapper by Stripe.

Use Razorpay checkout.js as an ES module.

Note: To be PCI compliant, you must load checkout.js directly from https://checkout.razorpay.com. You cannot include it in a bundle or host it yourself. This package wraps the global Razorpay function provided by the checkout.js script as an ES module.

Tests npm version

Installation

Use npm to install the checkout.js module:

npm install @tiltbike/razorpay-checkout-js

Usage

loadCheckout

This function returns a Promise that resolves with a newly created Razorpay object once checkout.js has loaded. If necessary, it will load checkout.js for you by inserting the checkout.js script tag. If you call loadCheckout in a server environment it will resolve to null.

import { loadCheckout } from '@tiltbike/razorpay-checkout-js';

const razorpay = await loadCheckout('rzp_test_ThB8MHSwsn2cQPU');

We’ve placed a random API key in this example. Replace it with your actual publishable API keys to test this code through your Razorpay account.

For more information on how to use checkout.js once it loads, please refer to the checkout.js API reference or learn to accept a payment with Razorpay.

Ensuring checkout.js is available everywhere

It is recommended that checkout.js is loaded on every page, not just your checkout page. This might help detect anomalous behavior that may be indicative of fraud as customers browse your website.

By default, this module will insert a <script> tag that loads checkout.js from https://checkout.razorpay.com. This happens as a side effect immediately upon importing this module. If you utilize code splitting or only include your JavaScript app on your checkout page, the checkout.js script will only be available in parts of your site. To ensure checkout.js is available everywhere, you can perform either of the following steps:

Import as a side effect

Import @tiltbike/razorpay-checkout-js as a side effect in code that will be included throughout your site (e.g. your root module). This will make sure the checkout.js script tag is inserted immediately upon page load.

import '@tiltbike/razorpay-checkout-js';

Manually include the script tag

Manually add the checkout.js script tag to the <head> of each page on your site. If an existing script tag is already present, this module will not insert a new one. When you call loadCheckout, it will use the existing script tag.

<!-- Somewhere in your site's <head> -->
<script src="https://checkout.razorpay.com/v1/checkout.js" async></script>

Razorpay Documentation

Credits

Most of the code and documentation for this package has been picked up from the open-source loading wrapper for Stripe.js. Thanks to the Stripe team!