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

checkout-risk-sdk

v1.0.1

Published

This in a NPM to checkout risk sdk implementation

Downloads

4

Readme

Checkout Risk SDK Hook

Description

This hook provides an easy-to-use interface for integrating the Checkout.com Risk SDK into your React application. It helps generate a deviceSessionId for fraud detection and risk assessment. The deviceSessionId can be used to analyze device and session data, helping you identify and mitigate potential fraud.

Features

Dynamic SDK Loading: Automatically loads the Risk SDK from the appropriate environment (production or sandbox). State Management: Manages the state of the Risk instance and script loading status. Fraud Detection: Facilitates the collection of risk data to help detect fraudulent activities. Easy Integration: Seamlessly integrates with your existing React application.

Installation

Dillinger requires Node.js v10+ to run.

Install the dependencies and devDependencies and start the server.

npm i checkout-risk-sdk

Usage

Example

import React, { useEffect, useState } from 'react';
import useCheckoutRiskSDK from 'checkout-risk-sdk';

const YourComponent = () => {
  const [deviceSessionId, setDeviceSessionId] = useState<string | null>(null);
  const { risk, isScriptLoaded } = useCheckoutRiskSDK(process.env.REACT_APP_CHECKOUT_PAYMENT_PUBLIC_KEY);

  useEffect(() => {
    const fetchDeviceSessionId = async () => {
      if (isScriptLoaded && risk) {
        try {
          const id = await risk.publishRiskData();
          setDeviceSessionId(id);
        } catch (error) {
          console.error('Error fetching deviceSessionId:', error);
        }
      }
    };

    fetchDeviceSessionId();
  }, [risk, isScriptLoaded]);

  return (
    <div>
      <p>Device Session ID: {deviceSessionId}</p>
      {/* Your component code */}
    </div>
  );
};

export default YourComponent;

Now pass the deviceSession where you needed.

How It Works

Environment Detection: The hook detects the environment (production or sandbox) and loads the appropriate Risk SDK URL. Script Loading: It dynamically loads the Risk SDK script into the document. Risk Instance Initialization: Once the script is loaded, the hook initializes the Risk instance using the provided public key. Data Publishing: The publishRiskData method from the Risk instance is used to obtain the deviceSessionId, which can then be used for further processing or storage.

Configuration

Environment Variables

REACT_APP_ENVIRONMENT: Set this to "prod" or "sandbox" to determine which Risk SDK URL to load. REACT_APP_CHECKOUT_PAYMENT_PUBLIC_KEY: Your public key for initializing the Risk SDK.

Error Handling

The hook provides basic error handling for script loading and initialization. In case of an error, appropriate messages are logged to the console.

License

MIT