Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
paypal-noorijs
Advanced tools
Using npm:-
🖊️ Command 🖊️
npm i -g paypal-noorijs
npm i -save paypal-noorijs
🔥In NodeJS
🔥
//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.
//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.
//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.
});
//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);
});
FAQs
Npm package to ease the API integration of paypal(REST API).
The npm package paypal-noorijs receives a total of 1 weekly downloads. As such, paypal-noorijs popularity was classified as not popular.
We found that paypal-noorijs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.