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

paypal-noorijs

v1.0.30

Published

Npm package to ease the API integration of paypal(REST API).

Downloads

40

Readme

paypal-noorijs v1.0.30

Installation

Using npm:-

🖊️ Command 🖊️

npm i -g paypal-noorijs
npm i -save paypal-noorijs

🔥In NodeJS🔥

PayPal Application Configuration

//Require the package(Load the full build).
const nooriNPM = require('paypal-noorijs');

//Now configure your paypal with Mode + Your paypal application Client_ID + Your paypal Secret_ID from your application.

//String
const Appmode = 'sandbox'; 
//Client ID from your PayPal Application.
const your_application_client_id = 'PasteYourPaypalClientIDHere';
//Secret ID from your PayPal Application.
const your_application_secret_id = 'PasteYourPaypalSecretIDHere';

//After successfully assigning your all essentials above, now you can proceed for configuration.
nooriNPM.configure(Appmode, your_application_client_id, your_application_secret_id);
//Above method configures the application of our PayPal.

Create PayPal Checkout Payment

//importing npm.
const nooriNPM = require('paypal-noorijs');

//Declare all of your mandatory variables that is getting passed to the 'one_time_payment_setup' module.
let return_url; //*required
let cancel_url; //*required
let payment_name; //*required
let price; //*required
let currency; //*required
let descriptioin; //Optional

//Here we are executing our one time payment checkout that returns the payment url link at the end of the response object.
nooriNPM.one_time_payment_setup(req, res, return_url, cancel_url, payment_name, price, currency, descriptioin);

>req:- request parameter of your API.

>res:- response parameter of your API.

>return_url:- Your success URL where you want to redirect after your payment gets successful.
NOTE:- You can pass extra things for your convenience in the URL which you can use after successful payment. eg, userID.
eg---> `http://localhost:5000/paypal/success/?_id=${userID}`;

>cancel_url:- Redirected to this URL when your payment gets failed for some reason.

>payment_name:- This specifies the payment purpose(String).
eg---> "Buying some product"

>price:- The price that you want to charge your customer/user.

>currency:- Whatever the currency you want your users to pay in. 
NOTE:- This is simple string but should be in UPPERCASE.
eg---> 'USD' 

>descriptioin:- This is optional(String). Helps for uniquely identifying something if needed.

After successful checkout, You will get 'payment_link' object at the bottom of the response object. That link redirects you to the next step where you put all of your needed details(Your Paypal account id and password) and pay.

Execute Payment

//importing npm.
const nooriNPM = require('paypal-noorijs');

//Your mandatory variable that is getting passed as parameter in the "oneTimePaymentExecution" function.
let PayerID = req.query.PayerID; //*required - coming from url.
let PaymentID = req.query.paymentId; //*required - coming from url.
let price; //*required - Same as checkout (Unacceptable if it varies from Checkout payment's price.)
let currency; //*required - Same as checkout (Unacceptable if it varies from Checkout payment's currency.)

>req:- request parameter of your API

>res:- response parameter of your API.

nooriNPM.oneTimePaymentExecution(req, res, PayerID, PaymentID, price, currency, function (result) {
        //This call back function's result holds all of the payment details.

            console.log(result);

            //Use below sale_id variable that contains the transaction id for the refund if needed.
            const sale_id = result.transactions[0].related_resources[0].sale.id;

            >sale_id:- You can save this and use it for the refund or to get payment details.
        });

Refund Payment

//importing npm.
const nooriNPM = require('paypal-noorijs');

//Your mandatory variable that is getting passed as parameter in the "refundPayment" function.
const amount = req.body.amount; //Should not vary from original price.
const currency = req.body.currency; //Should not vary from original currency.
const sale_id = req.body.sale_id; //The ID that callback returns in the object of result in "oneTimePaymentExecution" function.

>req:- request parameter of your API

>res:- response parameter of your API.

nooriNPM.refundPayment(req, res, amount, currency, sale_id, async function (result) {
    //At this point payment should be refunded.
            console.log("Refunded successfully");

            //result variable gives all the details regarding refund.
            console.log(result);
        });

👍 That's it 👍