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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@payretailers1/h2h-widget

v0.1.26

Published

A secure embedded payment form SDK that enables partners to seamlessly integrate payment processing directly within their websites. Allow customers to complete transactions without redirects while maintaining PCI compliance and security best practices

Readme

🚀 Cards H2H Library

A powerful library for partners to seamlessly integrate a payment form on their website, allowing customers to complete transactions without leaving the site. All payments are processed securely by Pay Retailers.

Installation

First, install the package via NPM:

npm install @payretailers1/h2h-widget

Usage

Import and Setup To use the SDK, import the PrCards class from the package:

import { PrCards } from "@payretailers1/h2h-widget";

Class Initialization

Create an instance of PrCards and use the init method to initialize the payment form.

Basic JavaScript Example

const prCards = new PrCards();

prCards.init({
    transactionId: "123456", // Generado previamente por tu backend
    containerId: "payment-container", // ID del div donde se inyectará el iframe
    styles: {
        width: "100%",
        height: "500px",
        border: "none",
    },
    callbacks: {
        onLoad: () => {
            console.log("Formulario cargado");
        },
        onSuccess: (response) => {
            console.log("Pago exitoso:", response);
        },
        onError: (error) => {
            console.error("Error:", error);
        },
    },
});

Usage with React

import React, { useEffect } from "react";
import { PrCards } from "@payretailers1/h2h-widget";

const PaymentComponent = () => {
    useEffect(() => {
        const prCards = new PrCards();

        prCards.init({
            transactionId: "123456", // Generado previamente
            containerId: "payment-container",
            styles: {
                width: "100%",
                height: "500px",
                border: "none",
            },
            callbacks: {
                onLoad: () => {
                    console.log("Formulario cargado");
                },
                onSuccess: (response) => {
                    console.log("Pago exitoso:", response);
                },
                onError: (error) => {
                    console.error("Error:", error);
                },
            },
        });

        return () => {
            prCards.destroy(); // Limpia el formulario al desmontar el componente
        };
    }, []);

    return <div id="payment-container"></div>;
};

export default PaymentComponent;

Usage in Vue with Nuxt

<template>
    <div id="payment-component"></div>
</template>

<script>
import { PrCards } from '@payretailers1/h2h-widget';


export default {
    name: 'PaymentForm',
    data() {
        return {
            showPaymentComponent: false,
            depositAmount: 0,
            amounts: [20, 50, 100, 200],
            prCards: new PrCards()
        };
    },
    methods: {
        loadWidget() {
            this.prCards.destroy();
            this.prCards.init({
                transactionId: '22aa2247-4b37-4bbc-9718-270179c2780e',
                containerId: 'payment-component',
                styles: {
                    'height': '100%',
                    'width': '100%',
                    'border': 'none',
                    'position': 'absolute',
                    'top': '0',
                    'left': '0',
                    'bottom': '0',
                    'right': '0',
                    'padding-top': '5%',
                    'borderColor': '#ffdjcj',
                    'backgroundColor': '#fffccff',
                    'loadAnimation': '../images/loader.gif'
                },
                callbacks: {
                    onLoad: () => console.log('Form loaded'),
                    onSuccess: (response) => {
                        console.log('Success handeled');
                        this.prCards.destroy();
                    },
                    onError: () => console.log('Error'),
                }
            });
            
        },

    }
};
</script>

Parameters for the init Method

The init method accepts an object of type PrCardsOptions:

export type PrCardsOptions = {
    transactionId: string;       // transaction ID (required)
    containerId: string;         // Div ID where the iframe will be injected (required)
    styles: { [key: string]: string }; // CSS styles for the iframe (optional)
    callbacks: Callbacks;        // Callback functions to handle events (required)
};

Callbacks The callbacks parameter should include the following methods:

  • onLoad: Executes when the iframe finishes loading.
  • onSuccess: Executes when a payment is successfully completed.
  • onError: Executes when an error occurs.

RespuestaEvent Response

The SDK uses the following response types and event codes:

Response Types

type ResponseType = "ValidationError" | "PaymentError" | "PaymentSuccess";

Event Codes

export enum EventCodes {
    VALIDATION_ERROR = "VALIDATION_ERROR",
    PAYMENT_ERROR = "PAYMENT_ERROR",
    PAYMENT_SUCCESS = "PAYMENT_SUCCESS",
    NOT_FOUND = "NOT_FOUND",
    UNEXPECTED_EXCEPTION = "UNEXPECTED_EXCEPTION"
}

Errors and Exceptions

Missing Parameters

If any required parameter in the PrCardsOptions object (other than callbacks) is missing, a ValidationError will be logged to console.error:

export declare class ValidationError extends Response {
    constructor(message: string, details?: string | null);
}

Missing Callbacks

If any required callback is not defined, a CallbackError will be returned:

export declare class CallbackError extends ValidationError {
    constructor(message: string, details?: string | null);
}

Invalid Transaction

If the form does not find a transaction in a PENDING state, a PaymentError will be thrown:

export declare class PaymentError extends Response {
    readonly transactionId: string;
    constructor(transactionId: string, message: string, details?: string | null);
}

Successful Response

If the payment is successfully processed, the onSuccess callback will receive a PaymentSuccess object:

export declare class PaymentSuccess extends Response {
    readonly transactionId: string;
    constructor(transactionId: string, details?: string | null);
}

destroy Method

To clear the iframe from the container:

prCards.destroy();

This removes the form and stops any associated processes.