Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-yandex-kassa

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-yandex-kassa

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

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

#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):

KeyValue
requestDatetime2011-05-04T20:38:00.000+04:00
actioncheckOrder
md58256D2A032A35709EAF156270C9EFE2E
shopId13
shopArticleId456
invoiceId1234567
customerNumber8123294469
orderCreatedDatetime2011-05-04T20:38:00.000+04:00
orderSumAmount87.10
orderSumCurrencyPaycash643
orderSumBankPaycash1001
shopSumAmount86.23
shopSumCurrencyPaycash643
shopSumBankPaycash1001
paymentPayerCode42007148320
paymentTypeAC

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

Keywords

FAQs

Package last updated on 27 Sep 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc