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

@bitcoin-suisse/pay

v1.0.7

Published

Bitcoin Suisse Pay plugin for crypto payments

Downloads

82

Readme

Bitcoin Suisse Pay plugin

npm version

By implementing the @bitcoin-suisse/pay plugin and by having a Bitcoin Suisse merchant account, you will be able accept crypto currencies as online payment method for goods and services, alongside credit cards 💳 and other payment methods in your checkout process.

Pre-requisites

  1. BTCS Pay merchant account. Please sign up here.
  2. Merchant domiciled in Switzerland or Liechtenstein
  3. Legal form GmbH or AG

Get started

1. Installation

Run the following to install the package.

npm install @bitcoin-suisse/pay

2. Add script

Either add the script directly, preferably in <head> tag.

<script type="text/javascript" src="~/node_modules/@bitcoin-suisse/pay/index.js"></script>

Or import the script into a larger codebase.

import { CryptoPayments } from '@bitcoin-suisse/pay';

3. Generate auth-key

The format of the auth-key consists the Terminal ID + secret (found on the Merchant site below Customer Details -> API -> SharedSecret)

MacOS
Run shasum -a 256 /path/to/file

Windows
Run certutil -hashfile /path/to/file SHA256

Example:
TerminalID: 987654321
Secret: 000000001

Format: <terminalID><secret>
input.txt contains: 987654321000000001

shasum -a 256 input.txt
SHA256/auth-key: 360d768442b399b2de3dded67681b3cca5eecde955c44c0b5db63353ec267ae6

4. Instantiate CryptoPayments

At the end of your <body> tag, or directly from within a SPA, instantiate an instance of the CryptoPayments lib.

/*
    Required:

    terminalId: Terminal ID
    auth: The auth-key enables the callback response as part of the paymentCallbackUrl if this is supplied
    paymentId: Adding this instead of amount and fromCurrency directs to specific payments request
    amount: Payment amount (not valid if paymentId is added)
    fromCurrency: Currency (abbriviation e.g. EUR, USD, CHF) (not valid if paymentId is added)
    -------------------------------------

    Optional:

    paymentCallbackUrl: Platform specific callback (avoid querstrings in URL)
    language: en (default), de, fr, it
    target: Append target to an HTML element (default: appended to body)
    referenceId: Adds a reference note to the payment request
*/
new CryptoPayments({
    terminalId: '123456789',
    auth: '0000...',
    paymentId: '0000000001',
    amount: 1337,
    fromCurrency: 'CHF',
    paymentCallbackUrl: 'https://www.example.com',
    language: 'en',
    target: document.getElementById('terminal-container'),
    referenceId: '12345-12345-12345',
})
    .create()
    .then((data) => {
        console.log('data:', data);
        // This is called when a payment has been successfully interacted with.
        // The terminal view will remove itself.

        // Payment states 👇
        // "crypto-payments-status-PAID":
        // "crypto-payments-status-PAIDOVER":
        // "crypto-payments-status-PAIDLATE":
        // "crypto-payments-status-PAIDPARTIAL":

        // Up to the client if they want to redirect to a certain success URL or update SPA accordingly.
    })
    .catch((errorData) => {
        console.log('data:', errorData);
        // This is called when a payment has an error
        // Terminal view will remove itself

        // Payment states 👇
        // "crypto-payments-status-CANCELED":
        // "crypto-payments-status-EXPIRED":

        // Up to the client if they want to redirect to a certain error URL or update SPA accordingly.
    });

Callback response format

CallbackURL will get the following parameters appended (querystring)

?transactionid={payment.Key}
	&orderid={payment.OrderNumberRef}
	&state={state.Enumeration}
	&amount={Convert.ToString(payment.Amount)}
	&currency={payment.FromCurrencyName}
	&date={Date(yyyyMMdd) | ""}
	&time={Date("hhmm") | ""}
	&publickey={payment.CCAddress}
	&paymentType={payment.ToCurrencyName}
	&terminal={payment.TerminalKey}
	&hash={Sha256}

Browser Support

  • ES2015
  • Commonjs