3.0.4 • Published 4 months ago

spayd v3.0.4

Weekly downloads
74
License
MIT
Repository
-
Last release
4 months ago

build status dependencies npm version

spayd-js

An implementation of Short-Payment-Descriptor library in JavaScript/TypeScript. Primarily used for generating QR-Payments.

Installation

# yarn
yarn add spayd

# npm
npm install spayd --save

Usage

import spayd from 'spayd';

const payment = {
  acc: 'CZ2806000000000168540115',
  am: '450.00',
  cc: 'CZK',
  msg: 'Payment for some stuff',
  xvs: '1234567890'
};

// print just the SPAYD string
console.log(spayd(payment));
import qrcode from 'qrcode';
import spayd from 'spayd';

const qrCodeEl = document.getElementById('qr');

const payment = {
  acc: 'CZ2806000000000168540115',
  am: '450.00',
  cc: 'CZK',
  msg: 'Payment for some stuff',
  xvs: '1234567890'
};

const spaydString = spayd(payment);

// generate and assign qr-payment to an image element
qrcode.toDataURL(spaydString)
  .then((url) => {
    qrCodeEl.setAttribute('src', url);
  })
  .catch(console.error);

Options

RequiredDescriptorFormatDescriptionExample
accstringaccount number in IBAN format or IBAN+BIC format"CZ5855000000001265098001+RZBCCZPP"
altAccstring[]array of alternative accounts (usage of these accounts depends on the bank app implementation) "CZ5855000000001265098001+RZBCCZPP", "CZ5855000000001265098001"
amstringamount of money to transfer in floating point number string"480.55"
ccstringcurrency in ISO 4217 format"CZK"
rfnumberpayment identifier for the receiver1234567890123456
rnstringreceiver's name"PETR DVORAK"
dtDatedue datenew Date(2018, 3, 20)
ptstringpayment type"P2P"
msgstringmessage for receiver"Payment for some stuff"
crc32stringCRC32 hashsum of this SPAYD payment"1234ABCD"
xperstringnumber of days to retry the payment"7"
xvsstringvariable symbol"1234567890"
xssstringspecific symbol"1234567890"
xksstringconstant symbol"1234567890"
xidstringpayment identifier for the payer"ABCDEFGHIJ1234567890"

For more info about SPAYD descriptors, see:

Package variants

As of version >=3.0, the default export is in the UMD format. This enables you to use the package both in the browser and in nodejs. Plus, it allows it to target legacy browsers, like IE11. If you encounter no troubles with the default export, feel free to keep using it.

If you wanted import specifically an ES6 or CommonJS version of spayd, use the "/esm" or "/cjs" subpath respectively.

// pure ES6 version
import spayd from "spayd/esm";

// CommonJS version
const spayd = require("spayd/cjs");
3.0.4

4 months ago

3.0.3

3 years ago

3.0.2

3 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

6 years ago