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

b2b-sprinque-tools

v1.10.12

Published

UI lib to reuse Sprinque B2B solutions

Downloads

318

Readme

Javascript library to help you speedup Sprinque integration.

Sprinque is the most flexible B2B payment platform. This package includes some reusable code we use in our team and can share with you.

Sprinque for developers

Codepen demo for b2b-sprinque-tools

This package allows you to:

1. Validate B2B company reg.number

  1. Validate B2B company registration number;
  2. Display error message translated to different languages;
  3. Support different reg. number format per country;
  4. Supported countries: 'nl', 'be', 'es', 'fr', 'de', 'pl'.
  5. For other countries just allows entering alphanumeric, "/" and empty symbol.

Example how it can be used

Usage

Script tag

<!DOCTYPE html>
<html>
  <head>
    <title>Sprinque JS SDK</title>
    <script src="https://unpkg.com/b2b-sprinque-tools/dist/index.umd.min.js" crossorigin></script>
  </head>
  <body>

    <script>
      Sprinque.checkRegNumber('56944306', 'nl', 'nl'); // {isValid: true, message: ''}
    </script>
    Or
    <script>
      Sprinque.checkRegNumber('569443060000', 'nl', 'nl'); // {isValid: true, message: ''}
    </script>
  </body>
</html>

Import

import { checkRegNumber } from "b2b-sprinque-tools";

checkRegNumber('844815263', 'be', 'en') // {isValid: true, message: ''}
checkRegNumber('invalid844815263', 'be', 'en') // {isValid: true, message: 'Registration number format should be like "071194951"'}

2. Reuse translations

import { getTranslatedLanguage } from "b2b-sprinque-tools";

getTranslatedLanguage('es', 'fr') // 'Francés'
import { getTranslatedCountry } from "b2b-sprinque-tools";

getTranslatedCountry('es', 'fr') // 'Francia'
import { getTranslatedApiError } from "b2b-sprinque-tools";
// converts Sprinque API error code to user friendly translated message
// more about Sprinque error codes - https://sprinque.readme.io/docs/error-reasons#http-error-codes
getTranslatedApiError('en', 'AuthCreditPendingError') // 'Credit limit for this buyer is not approved yet'

3. Parse Sprinque API errors

If Sprinque doesn't have translation - English version of message will be returned:

import { parseSprinqueErrorsToString } from "b2b-sprinque-tools";
parseSprinqueErrorsToString({
  address: {
    country_code: ['This field may not be blank.'],
  },
}, 'nl') // 'country_code > This field may not be blank.'

If Sprinque has translation, we'll reuse getTranslatedApiError function:

import { parseSprinqueErrorsToString } from "b2b-sprinque-tools";
parseSprinqueErrorsToString({
  AuthBuyerUnderReviewError: ['This text ignored, the one from translations is used'],
}, 'nl') // 'Het bedrijf wordt nog onderzocht'

4. Format money amount

Based on https://currency.js.org/

import {formatMoneyAmount} from "b2b-sprinque-tools";
formatMoneyAmount(1234.56); // '1,234.56'
formatMoneyAmount(1234.56, 'nl'); // '1.234,56'

4. Get current and lower payment terms

import {getEligiblePaymentTerms} from "b2b-sprinque-tools";
getEligiblePaymentTerms('NET15'); // ['NET7', 'NET15']
getEligiblePaymentTerms('NET90', ['NET60', 'NET90', 'PAY_IN_3']); // ['NET60', 'NET90']

5. Display search tips

import {getSearchTipsByCountry} from "b2b-sprinque-tools";
// 'be' - country, 'en' - language
getSearchTipsByCountry('be', 'en', false); // 'For sole proprietorship please use your last name and first name'
getSearchTipsByCountry('be', 'en', true); // 'For VAT Number use BE0+Registration number. No spaces'

6. Reuse Sprinque translations

import {getTranslatedText} from "b2b-sprinque-tools";
getTranslatedText('en', 'privacyPolicy'); // HTML like 'Sprinque B.V. conducts an automated credit check to...'