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

bongloy-client

v0.0.2

Published

React Native Bongloy wrapper that makes using Bongloy with React Native safe and easy in iOS/Android.

Downloads

4

Readme

Bongloy Client

Build Status

React Native Bongloy wrapper that makes using Bongloy with React Native easy in iOS/Android.

Features

  • Collect credit card information and convert it to a Bongloy token in a single line of Javascript.
  • Collect bank account information and convert it to a Bongloy token in a single line of Javascript.
  • Collect personal identification information and convert it to a Bongloy token in a single line of Javascript.

Limitations

  • Bongloy only allows an exchange of card information/bank account information/PII in the front end. This does not verify the payment information, it just checks that it looks reasonable (ex. the expiration date is in the future, the credit card number has the right format). You should take this token and immediately pass it to a backend function that validates it (ex. by creating a charge or assigning it to a customer)
  • As a corollary, you should only embed your Bongloy PUBLISHABLE token in a frontend app.

Installation

npm install bongloy-client --save

Or

yarn add bongloy-client

Creating a token

bongloy.createToken(...) returns a Promise of a token object (https://stripe.com/docs/api/node#token_object).

If the token object creation fails (ex. the expiration date is invalid, the card number is the wrong format), bongloy.createToken(...) returns the corresponding error (https://stripe.com/docs/api/node#errors).

  • Example function call
bongloy.createToken({
  card: {
    "number": '4242424242424242',
    "exp_month": 12,
    "exp_year": 2018,
    "cvc": '123'
  }
});
  • Example return:
{
  "id": "tok_1AWuxsJd4nFN3COfSKY8195M",
  "object": "token",
  "card": {
    "id": "card_1AWuxsJd4nFN3COfUOhQfBVw",
    "object": "card",
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": null,
    "address_zip_check": null,
    "brand": "Visa",
    "country": "US",
    "cvc_check": null,
    "dynamic_last4": null,
    "exp_month": 8,
    "exp_year": 2018,
    "fingerprint": "EL88ufXeYTG02LOU",
    "funding": "credit",
    "last4": "4242",
    "metadata": {
    },
    "name": null,
    "tokenization_method": null
  },
  "client_ip": null,
  "created": 1497998212,
  "livemode": false,
  "type": "card",
  "used": false
}

Example Usage

Creating a credit card token

import React from 'react';
var bongloy = require('bongloy-client')('YOUR_PUBLISHABLE_BONGLOY_API_KEY');

var information = {
  card: {
    number: '4242424242424242',
    exp_month: '02',
    exp_year: '21',
    cvc: '999',
    name: 'Billy Joe'
  }
}

export class App extends React.Component {
  async onPayment() {
    var card = await bongloy.createToken(information);
    var token = card.id;
    // send token to backend for processing
  }

  render() {
    ...
  }
}

Creating a bank account token

import React from 'react';
var bongloy = require('bongloy-client')('YOUR_PUBLISHABLE_BONGLOY_API_KEY');

var information = {
  bank_account: {
    country: 'US',
    currency: 'usd',
    account_holder_name: 'Noah Martinez',
    account_holder_type: 'individual',
    routing_number: '110000000',
    account_number: '000123456789'
  }
}

export class App extends React.Component {
  async onPayment() {
    var bank = await bongloy.createToken(information);
    var token = bank.id;
    // send token to backend for processing
  }

  render() {
    ...
  }
}

Creating a PII token

var bongloy = require('bongloy-client')('YOUR_PUBLISHABLE_BONGLOY_API_KEY');

var information = {
  pii: {
    personal_id_number: '000000000'
  }
}

export class App extends React.Component {
  async onPayment() {
    var pii = await bongloy.createToken(information);
    var token = pii.id;
    // send token to backend for processing
  }

  render() {
    ...
  }
}

Questions and Answers

Where can I find more information about creating tokens in Bongloy?

  • Because of Bongloy and Stripe is almost the same. Please Check out the Stripe docs at https://stripe.com/docs/api/node#tokens .

Help! I don't know where to find 'YOUR_PUBLISHABLE_BONGLOY_API_KEY' ?

  • Make an account on Bongloy (if you haven't already) and check out https://bongloy.com/dashboard/account/edit .

Is it okay to publish my Bongloy API key in the Expo / React Native application?

  • It's 100% fine to publish your Bongloy Publishable key, as the publishable key has no dangerous permissions. Make sure not to publish your Bongloy Secret key, as this is the key that would allow people to charge money when used.

I want to charge a customer with this library. How would I do that?

  • Bongloy only allows you to exchange card information for a payment token on the frontend. You should get this token, and then immediately pass it to a backend function that validates it, either by creating a charge, or else by attaching it to a customer. See the Bongloy API for more information, and this helpful blog post for more on handling Bongloy errors.