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

node-yandex-kassa

v0.1.1

Published

Node.js utilities to integrate Yandex.Kassa with your app

Downloads

23

Readme

#node-yandex-kassa

NPM Version Build Status

by Zero One

JavaScript utilities to integrate Yandex.Kassa payment API with your app

Installation

npm install --save node-yandex-kassa

Usage

Example usage with Express in route handler:

import { checkMD5, buildResponse } from 'node-yandex-kassa';
const { KASSA_SHOP_PASSWORD } = process.env; // ... if you store such things there

app.post('/payments/check_order', (req, res, next) => {
  const { body } = req;
  const { invoiceId, shopId } = body;

  if (!checkMD5(body, KASSA_SHOP_PASSWORD)) {
  	return res.status(400).send('Validation of MD5 failed');
  }

  // ...
  //
  // Here you might validate request params (orderNumber of customerNumber, for example)
  // if these parameters were passed to payment form
  // ...

  res.set('Content-Type', 'text/xml');
  res.send(buildResponse('checkOrder', 0, shopId, invoiceId));
});

Functions

checkMD5(requestBody, shopPassword)

Returns boolean.

Checks request body for valid md5 param.

Requests are being made by Yandex.Kassa service and have standart format (with sample data):

| Key | Value | ------ | ----- | | requestDatetime | 2011-05-04T20:38:00.000+04:00 | | action | checkOrder| | md5 | 8256D2A032A35709EAF156270C9EFE2E | | shopId | 13 | | shopArticleId | 456 | | invoiceId | 1234567 | | customerNumber | 8123294469 | | orderCreatedDatetime | 2011-05-04T20:38:00.000+04:00 | | orderSumAmount | 87.10 | | orderSumCurrencyPaycash | 643 | | orderSumBankPaycash | 1001 | | shopSumAmount | 86.23 | | shopSumCurrencyPaycash | 643 | | shopSumBankPaycash | 1001 | | paymentPayerCode | 42007148320 | | paymentType | AC |

buildResponse(action, statusCode, shopId, invoiceId, message = null)

Returns string.

Generates string with valid XML required by Yandex.Kassa API.

Example of successful response:

<?xml version="1.0" encoding="UTF-8"?>
<checkOrderResponse performedDatetime="2011-05-04T20:38:01.000+04:00"
code="0" invoiceId="1234567"
shopId="13"/>

Example of response with error:

<?xml version="1.0" encoding="UTF-8"?>
<checkOrderResponse performedDatetime="2011-05-04T20:38:01.000+04:00"
code="100" invoiceId="1234567"
shopId="13"
message="Given customerNumber does not exist"
techMessage="Wrong phone number"/>

More docs coming soon

For now, for more info on usage and itegration refer to official integration guide and API spec.

License

This project rocks and uses MIT License

Copyright (c) 2015 Zero One