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

iframe_cashpay

v1.1.1

Published

iframe_cashpay. A plugin to add payments Cash E-wallet to your application.

Downloads

31

Readme

JS iFrame CashPay

alt text alt text

iframe_cashpay. A plugin to add payments Cash E-wallet to your application.

Getting Started

Before you start, create an APIs with the payment providers and follow the setup instructions: https://documenter.getpostman.com/view/17550185/2s93XzwN9o

Installation

 <script src="https://cdn.jsdelivr.net/npm/[email protected]/index.js"></script>

Usage

Typical setup

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>CashPayButton</title>
    <style>
        /*style for CashPayButton*/
        .CashPayButtonStyle {
            color: white;
            font-size: medium;
            background-color: #006666;
            padding: 15px;
            border-radius: 30px;
        }
    </style>
</head>
<body>
 <!-- Use TagName CashPayButton and attribute className,lang in your application -->
    <CashPayButton className="CashPayButtonStyle" lang="en"></CashPayButton>
    <script>
        //You must use function onClickCashPayButton and return iframeURL
        var orderId;
        async function onClickCashPayButton() {
            //Send itemList for your server and post CreateOrder.
            //For example.
            var itemList = [
                {
                    "itemName": "كتاب",
                    "amount": 2000
                },
                {
                    "itemName": "ساعة",
                    "amount": 5000
                }
            ];
            var requestOptions = {
                method: 'POST',
                body: JSON.stringify(itemList),
                redirect: 'follow'
            };
            var iframeURL = "";
            await fetch('https://api.example.com/itemList', requestOptions)
                .then(response => response.json())
                .then(res => {
                    if (res) {
                        if (res.iframeURL) {
                           //iframeURL returned from Response CreateOrder
                            //Documentation https://documenter.getpostman.com/view/17550185/2s93XzwN9o
                            iframeURL = res.iframeURL;
                            //orderID returned from Response CreateOrder
                            //Store the orderID in the orderId variable to use on function onConfirmPayment
                            orderId = res.orderID;
                        }
                    }
                })
                .catch(error => {
                    console.error(error);
                });
            if (iframeURL) {
                //You must return iframeURL to display iframe_cashpay
                return iframeURL;
            }
        };

        //Function callback onConfirmPayment
        function onConfirmPayment(data) {
            //After Confirmatin from CashPayButton.
            if(orderId)
            {
            //Here use CheckOrderStatus on your server to check order status.
            //Documentation https://documenter.getpostman.com/view/17550185/2s93XzwN9o
            }
        };
    </script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/index.js">
    </script>
</body>
</html>

Explanation of the code

How to use the CashPayButton iframe payment library.

Includes the iframe_cashpay payment library. The iframe_cashpay payment library is a JavaScript library that allows you to add the iframe_cashpay payment iframe to your website or application.

First defines a style for the CashPayButton element. The style sets the button's color to white, its font size to medium, its background color to #006666, its padding to 15px, and its border radius to 30px.

Creates a CashPayButton element and sets its className and lang attributes. The className attribute is used to set the style for the CashPayButton element. The lang attribute is used to set the language for the CashPayButton element.

Then defines a function called onClickCashPayButton. This function is called when the CashPayButton element is clicked. The function sends a list of items to the server and posts a CreateOrder request. The CreateOrder request creates an order for the items that were sent to the server. The function then gets the iframe URL from the response to the CreateOrder request. If the iframe URL is not null, the function returns it. The iframe URL is used to display the iframe_cashpay payment iframe.

Then defines a function called onConfirmPayment. This function is called when the user confirms the payment in the iframe_cashpay payment iframe. The function uses the CheckOrderStatus function on your server to check the order status.