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

@bananobay/accept-banano-client

v2.0.3

Published

[![Build Status](https://travis-ci.com/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.com/tigwyk/accept-banano-client) [![Coverage Status](https://coveralls.io/repos/github/tigwyk/accept-banano-client/badge.svg?branch=master)](https://

Downloads

6

Readme

accept-banano-client

Build Status Coverage Status npm (scoped) npm bundle size (scoped) GitHub

Payment gateway for BANANO

accept-banano-client is a JavaScript package that helps you to communicate with accept-banano for receiving BANANO payments easily in your client-side applications.

Installation

via NPM

npm install @accept-banano/client

yarn add @accept-banano/client

ES Modules / TypeScript

import * as acceptBanano from '@accept-banano/client'

CommonJS

const acceptBanano = require('@accept-banano/client')

Directly in Browser, as a UMD module

After the accept-banano-client script is loaded there will be a global variable called acceptBanano, which you can access via window.acceptBanano

<html>
  <head>
    ...
    <script src="https://unpkg.com/@accept-banano/client@2"></script>
  </head>
  ...
</html>

Usage

Creating a Payment Session

To be able to initiate the payment process, you must create a new payment session.

// 1- create a new payment session
type CreateSessionParams = {
  apiHost: string // host of your Accept BANANO server, without protocol
  pollInterval?: number // time interval (ms) to re-check for verification of a payment (default: 3s)
  debug?: boolean // enables debug mode and prints some useful stuff to console
}

const session = acceptBanano.createSession({
  apiHost: 'accept-nano-demo.put.io',
})

// 2- register event listeners to shape-up your logic based on session events.
type PaymentSessionEvents = {
  start: () => void
  end: (error: PaymentError | null, payment: AcceptBananoPayment | null) => void
}

session.on('start', () => {
  myApp.paymentStarted()
})

session.on('end', (error, payment) => {
  if (error) {
    return myApp.paymentFailed({ reason: error.reason })
  }

  return myApp.paymentSucceeded({
    amount: payment.amount,
    state: payment.state,
  })
})

Presenting the Payment Overlay

After creating your session and attaching the event listeners, you can follow one of those options to proceed with the payment flow.

Option 1: Create a Payment Through Client

If you want to create and verify an accept-banano payment in your client application, you can use this option.

After the payment is created, accept-banano-client will automatically proceed to the verification step.

type CreatePaymentParams = {
  amount: string // stringified number
  currency: 'BANANO' | 'USD'
  state?: string // payload to share between your client and server, will be embedded into the payment object
}

session.createPayment({
  amount: '1',
  currency: 'USD',
  state: '{userId:7}',
})

Option 2: Verify a Payment Through Client

If you create an accept-banano payment in another context (such as your application's backend), you can use this option to perform the verification in your client application.

type VerifyPaymentParams = {
  token: string // the Accept BANANO payment token created in your backend application
}

session.verifyPayment({ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' })

Contributing

  • Please open an issue if you have a question or suggestion.
  • Don't create a PR before discussing it first.

Who is using accept-nano-client in production?

  • Me

Please send a PR to list your site if accept-banano is helping you to receive BANANO payments.