Giter VIP home page Giter VIP logo

youcan-payment-nodejs-sdk's Introduction

youcan-payment-nodejs-sdk

This package allows the developer to interact easily with the YouCan Pay API. (this package is in early development)

NPM Version Codecov License

This package allows the developer to interact easily with the YouCan Pay API.

This documentation is separated in two integrations: Default Integration and the Standalone Integration. you have the choice to do one integration or both integrations in your checkout page.

YouCan Pay SDK Setup

Instructions for adding the YouCan Pay SDK to your NodeJS Applications.

Quick start

yarn add youcan-payment-nodejs-sdk
const youCanPayment = new YouCanPay(
  'pri_sandbox_72c4f469-afeb-4eed-b840-9c0c9', // you can private key
  true // is sandbox mode
);
const token = await youCanPayment.getToken({
  amount: 2000, //required
  currency: CurrencyCode.MAD, //required
  customer_ip: '127.0.0.1', //required
  order_id: 'XXXXXX', //required
  success_url: 'https://yourdomain.com/orders-status/success', //required
  error_url: 'https://yourdomain.com/orders-status/error', //optional
  customer: {
    name: '',
    address: '',
    zip_code: '',
    city: '',
    state: '',
    country_code: '',
    phone: '',
    email: '',
  }, //optional
});

console.log(token.id); // 71d8c27-2416-41ee-b750-d6382f72a565

YouCan Pay: Standalone Integration

const youCanPayment = new YouCanPay(
  'pri_sandbox_72c4f469-afeb-4eed-b840-9c0c9',
  true
);
const paymentUrl = await youCanPayment.getPaymentUrl(
  {
    amount: 2000,
    currency: CurrencyCode.MAD,
    customer_ip: '127.0.0.1',
    order_id: 'XXXXXX',
    success_url: 'https://yourdomain.com/orders-status/success',
    error_url: 'https://yourdomain.com/orders-status/error',
  },
  Lang.AR
);
console.log(paymentUrl); // https://youcanpay.com/sandbox/payment-form/1bd269e0-62d9-4a37-822c-191b28d7af5c?lang=ar

youcan-payment-nodejs-sdk's People

Contributors

lynvi avatar yassinebridi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

youcan-payment-nodejs-sdk's Issues

Payment URL not working in live mode(throwing 404 error)

  • I'm submitting a ...
    [โœ…] bug report

  • Screenshot 2024-02-01 at 7 59 57 PM

Hey, I used this sdk, it was working fine in sandbox mode, but in the live mode the payment url is showing 404 not found, what could be the issue? and why the library doesnt accept public key? in the official php sdk there is a option to pass public key.

HERE Is My code
exports.generateYouCanPayPaymentUrl = functions.https.onRequest(
async (req, res) => {
const ip = req.ip
cors(req, res, async () => {
const { userId, amount, order_id, selectedPlan } = req.body;
try {
const youCanPayment = new YouCanPay(
"priv_key"
);
const paymentUrl = await youCanPayment.getPaymentUrl(
{
amount: amount * 100,
currency: CurrencyCode.MAD,
order_id,
customer_ip: ip,
success_url: -----,
error_url: ----,
},
Lang.AR
);
res.json({ paymentUrl });
} catch (error) {
console.error(error);
res.status(500).json({ error: "Internal Server Error" });
}
});
}
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.