{"_id":"@accept-banano/client","_rev":"3-d8dc2912b9c2cb81105c3a0a510cafa0","name":"@accept-banano/client","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.0":{"version":"2.0.0","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","unpkg":"umd/index.js","umd:main":"umd/index.js","engines":{"node":">=10"},"scripts":{"start":"tsdx watch","start:umd":"parcel src/example/index.html --global acceptBanano --no-cache","clean":"rm -rf dist && rm -rf umd","prebuild":"yarn clean","build":"tsdx build && yarn build:umd && yarn build:example","build:umd":"parcel build src/index.ts --global acceptBanano --no-cache -d umd --out-file index.js","build:example":"cp src/example/index.html example/index.html && replace-in-file ../index.ts https://unpkg.com/@accept-banano/client@2 example/index.html","test":"tsdx test","lint":"tsdx lint","prepare":"yarn build","size":"size-limit","analyze":"size-limit --why","coveralls":"tsdx test --coverage && cat ./coverage/lcov.info | coveralls"},"peerDependencies":{},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":"@putdotio/prettier-config","name":"@accept-banano/client","author":{"name":"Lee Ingram"},"devDependencies":{"@putdotio/prettier-config":"^1.0.0","@size-limit/preset-small-lib":"^4.6.0","@testing-library/dom":"^7.26.0","@types/big.js":"^6.0.0","@types/jest":"^26.0.14","@types/qrcode":"^1.3.5","axios-mock-adapter":"^1.18.2","coveralls":"^3.1.0","husky":"^4.3.0","jest-canvas-mock":"^2.3.0","mock-socket":"^9.0.3","parcel-bundler":"^1.12.4","replace-in-file":"^6.1.0","size-limit":"^4.6.0","tsdx":"^0.14.1","tslib":"^2.0.3","typescript":"^4.0.3"},"size-limit":[{"path":"dist/client.cjs.production.min.js","limit":"60 KB"},{"path":"dist/client.esm.js","limit":"60 KB"}],"publishConfig":{"access":"public"},"dependencies":{"@byungi/event-emitter":"^1.2.2","axios":"^0.21.1","big.js":"^6.0.1","qrcode":"^1.4.4","redom":"^3.27.1","xstate":"^4.13.0"},"gitHead":"f75bb0a66e42e8f6c068f96d58cdf160edb41484","description":"[![Build Status](https://travis-ci.org/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.org/tigwyk/accept-banano-client) [![Coverage Status](https://coveralls.io/repos/github/tigwyk/accept-banano-client/badge.svg?branch=master)](https://c","_id":"@accept-banano/client@2.0.0","_nodeVersion":"15.8.0","_npmVersion":"7.5.3","dist":{"integrity":"sha512-/NDatXDq0cfxZXBB4/BFWSdXtbuD1gz+4SZgilNehkPyUM2O0HaQP2zJ3Pt0aXgc7KQ22T9pdBDWawcFprPM8w==","shasum":"3c06111c33a35268949e8e71727d669b3327e0d2","tarball":"https://registry.npmjs.org/@accept-banano/client/-/client-2.0.0.tgz","fileCount":55,"unpackedSize":1346468,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYlwQCRA9TVsSAnZWagAADj4P/1c3ZJ6Nl/fTuVCkKaOs\nnPqYLYHLrYa8Qwu2qF8051i/iBw8XjY6QnXXJD+0DcU8f7LzUMkJrFmsBkPb\nKAKd8RQc5C+KPA038uFerSHZPqwV/b1P9x5mKu1ucOAPhmzJMel4jdjT4xK8\nMseOMb2olk6/sKsVYmR10zXmAskK5WhNfkW73f7XNkfOhEDCYEXXNAt1Zg8M\n9ZwhFvbWKeoBZmDWQtJenRM8/HW0FpvaQGE6RRc58z20BMX8TpigwALAHrU5\n1rQ+w88k4AaQXE09Ajo0Hcg16LpsZ6iOkKZzCAn/B96pRShOrvhc9mtZSL9s\nyZ3COVSHjRZJlFnpdFg22obQCKBQNGg7K/e/MeEilLQVaumn2sFa2HhrThuQ\nmS8meJp1yWps0zcHV03+Qo+oQnVSMQtS489KdnuDOZ8njZ9kBzShhrAiLQno\nL1d2c+WfrcQxAvzYvrj0RybSJ+gmpBWgVkEPtN5yf63Ngk1s/ewlMeGD4O1h\nxeCmUpa0QzEK93+Yn3VIn/uQvU9tGUD3cBbVRWCQwsfNaQbULuTXeW1XXnYw\njhxWDB/iOsSrR5UTg4Vlsa0bdUKvzJ0OKn2evQjHLFKur6j9ZVyOpOigJP5m\neF0gQDI0+K3hL7+qJ7nJNuveMXhv7cpVeRPMB0hy/dPYBoxT4muihRPGlHCY\n/N2h\r\n=dLo8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFR3Zm2RjPM1QaxhaNi3wC+ZJt3YukSk+V1IFIinrFHaAiBCqjdAut+ybLePxYDpHb0EZOjuISp4EwDVwjOSfOkW+A=="}]},"_npmUser":{"name":"tigwyk","email":"lee@soylentcola.com"},"directories":{},"maintainers":[{"name":"tigwyk","email":"lee@soylentcola.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/client_2.0.0_1617058832299_0.24061429355266406"},"_hasShrinkwrap":false},"2.0.1":{"version":"2.0.1","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","unpkg":"umd/index.js","umd:main":"umd/index.js","engines":{"node":">=10"},"scripts":{"start":"tsdx watch","start:umd":"parcel src/example/index.html --global acceptBanano --no-cache","clean":"rm -rf dist && rm -rf umd","prebuild":"yarn clean","build":"tsdx build && yarn build:umd && yarn build:example","build:umd":"parcel build src/index.ts --global acceptBanano --no-cache -d umd --out-file index.js","build:example":"cp src/example/index.html example/index.html && replace-in-file ../index.ts https://unpkg.com/@accept-banano/client@2 example/index.html","test":"tsdx test","lint":"tsdx lint","prepare":"yarn build","size":"size-limit","analyze":"size-limit --why","coveralls":"tsdx test --coverage && cat ./coverage/lcov.info | coveralls"},"peerDependencies":{},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":"@putdotio/prettier-config","name":"@accept-banano/client","author":{"name":"Lee Ingram"},"devDependencies":{"@putdotio/prettier-config":"^1.0.0","@size-limit/preset-small-lib":"^4.6.0","@testing-library/dom":"^7.26.0","@types/big.js":"^6.0.0","@types/jest":"^26.0.14","@types/qrcode":"^1.3.5","axios-mock-adapter":"^1.18.2","coveralls":"^3.1.0","husky":"^4.3.0","jest-canvas-mock":"^2.3.0","mock-socket":"^9.0.3","parcel-bundler":"^1.12.4","replace-in-file":"^6.1.0","size-limit":"^4.6.0","tsdx":"^0.14.1","tslib":"^2.0.3","typescript":"^4.0.3"},"size-limit":[{"path":"dist/client.cjs.production.min.js","limit":"60 KB"},{"path":"dist/client.esm.js","limit":"60 KB"}],"publishConfig":{"access":"public"},"dependencies":{"@byungi/event-emitter":"^1.2.2","axios":"^0.21.1","big.js":"^6.0.1","qrcode":"^1.4.4","redom":"^3.27.1","xstate":"^4.13.0"},"gitHead":"662c4d4c5d707939d714b6c87df21e7f28e431f4","description":"[![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://c","_id":"@accept-banano/client@2.0.1","_nodeVersion":"15.8.0","_npmVersion":"7.5.3","dist":{"integrity":"sha512-YjZhtRrXmGTvtIvga6HBlqT774TFO3i7xL4P9cTTNwBAVhFSy2iKESvHo2JSodFjFysyjUuDiBGIvreCj2M9LA==","shasum":"78c90342cd6191097debcd67ee8b660bdeb47e00","tarball":"https://registry.npmjs.org/@accept-banano/client/-/client-2.0.1.tgz","fileCount":55,"unpackedSize":1346875,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaOjrCRA9TVsSAnZWagAAW+8P/25G8rLmC2IiKYS79GVk\nzsNYkBFFvMzipXDyo1XDey+ZhM/ebPX1U2PdQWXR82lk2bhD0WCqqv1LYlGi\nxfxEUl3lYwSTorlsWx1+/oS8DtA95n7yKgjY04mWQ4RDk6JRiHvEY5M+jnMt\nAXRTHM68YUi8mgl7Qz+fFKIW+S5XqDo+DddzmyL8xoRjiddkk1+wzrzOzXxs\ndtBWG2eo4ASH+dW2V3BNRgVSwU5dpkqLV7SLF+SX/Wx2Cy1rF5Bi9OmnYOxf\nF88is95ff2mXk9vAMuhYmjNMqKBQB9sO7CXrxvyGwpRegHaOuYJ5ByZDm3d6\npwf16SvdFMUUkEVv+2shcAMs3d1/kaoYYlUTPVH2m8Qq9So244cH4DGoW+Eo\nh1LHSgz1PlV+RB+3Va1psAq4WiH4R4X7AFXfscTUlqZxWRsjjMAyN/BbMzDW\nMbt9Q28tw78BKMCbQwy4WCmcOTRCb+5ew5qGHRyh+sGBno1jQh1gCT2YU20W\niHe74JzTzNIvVVk4qQCVlSbhB/1ZBdnrZD+c+eMpLjzWBHwt4PQjbDai8YYV\nstGMZ//FPe4i+2SWOWi1OyvzGfN856YBDdGcSNzll/3AVHMnRN8Y+N3box9r\nWdXSdJD7av3srABeHygwe/VARrd19LVb81EwCiIAy2tSs/2bZWJbDgoBQl5E\nCF5C\r\n=FqxB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCx3EQd+Ao7DkLJMzrpyp2hVY8fiNdIFdrqKmROKGGQcwIgOYiCtamt11Va0Fu8/R0qVO82QJgEMyn/xQXJgPvkTQA="}]},"_npmUser":{"name":"tigwyk","email":"lee@soylentcola.com"},"directories":{},"maintainers":[{"name":"tigwyk","email":"lee@soylentcola.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/client_2.0.1_1617488106483_0.8684691477784037"},"_hasShrinkwrap":false},"2.0.2":{"version":"2.0.2","license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","unpkg":"umd/index.js","umd:main":"umd/index.js","engines":{"node":">=10"},"scripts":{"start":"tsdx watch","start:umd":"parcel src/example/index.html --global acceptBanano --no-cache","clean":"rm -rf dist && rm -rf umd","prebuild":"yarn clean","build":"tsdx build && yarn build:umd && yarn build:example","build:umd":"parcel build src/index.ts --global acceptBanano --no-cache -d umd --out-file index.js","build:example":"cp src/example/index.html example/index.html && replace-in-file ../index.ts https://unpkg.com/@accept-banano/client@2 example/index.html","test":"tsdx test","lint":"tsdx lint","prepare":"yarn build","size":"size-limit","analyze":"size-limit --why","coveralls":"tsdx test --coverage && cat ./coverage/lcov.info | coveralls"},"peerDependencies":{},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":"@putdotio/prettier-config","name":"@accept-banano/client","author":{"name":"Lee Ingram"},"devDependencies":{"@putdotio/prettier-config":"^1.0.0","@size-limit/preset-small-lib":"^4.6.0","@testing-library/dom":"^7.26.0","@types/big.js":"^6.0.0","@types/jest":"^26.0.14","@types/qrcode":"^1.3.5","axios-mock-adapter":"^1.18.2","coveralls":"^3.1.0","husky":"^4.3.0","jest-canvas-mock":"^2.3.0","mock-socket":"^9.0.3","parcel-bundler":"^1.12.4","replace-in-file":"^6.1.0","size-limit":"^4.6.0","tsdx":"^0.14.1","tslib":"^2.0.3","typescript":"^4.0.3"},"size-limit":[{"path":"dist/client.cjs.production.min.js","limit":"60 KB"},{"path":"dist/client.esm.js","limit":"60 KB"}],"publishConfig":{"access":"public"},"dependencies":{"@byungi/event-emitter":"^1.2.2","axios":"^0.21.1","big.js":"^6.0.1","qrcode":"^1.4.4","redom":"^3.27.1","xstate":"^4.13.0"},"gitHead":"843de9ff6c0bf750fa3064f37b5bc9c28e13a3c4","description":"[![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://c","_id":"@accept-banano/client@2.0.2","_nodeVersion":"15.8.0","_npmVersion":"7.5.3","dist":{"integrity":"sha512-k1eQ1/OpItRnBzT2c40Q35YIIb5r1ius+HpeKxrKdL9cMZ7F4By8FS7/oD/n7MYGi/Rd6BowEwsyZu5q7gn6EQ==","shasum":"dfbabd35ec007af7c765eaabe3bc775953a482ef","tarball":"https://registry.npmjs.org/@accept-banano/client/-/client-2.0.2.tgz","fileCount":55,"unpackedSize":1389058,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaPHyCRA9TVsSAnZWagAADx8P/jA/RCVjQCY9OWwND8tB\nB4lywEgnP+6sfOM1erg2eXOfxJ3gzcAciUKSVUiQp4B48ncfR6naMJ6YSNF1\nZYhyJ7//gjLkQzOMrwBcNWmquhhl89YsuBd3WPqf1AOn77xGFbhwQTaHwdGe\n3HtYT7fXNcUvffVRLoG7OsBWmpFrk+lDVsUw/6qDLF5PpYkbrVYuJUUpQbGd\nzpqeMdnRDCfq1ue5FP9ue18PRu/x+5XluT4we5WFB9lCIWSFPwczr7llEL+j\nqHQGXAbjwBA1nOyZpkAn2NwjLtvIJvETy0X7uABGUetgDBUNh1v4ZwdZpscz\nhrpmUidJegs98NCAme1gpELcfoBq2Gd5UNZc0Vz4OkxriDHcIlUfm/URu8uX\n2hR/ti9wkks7X0OueiCmRxJrTnVLj6fD5ybmTWB1GP+FntxgJUZ9TccErFG2\nnFIDsd5Sbz9PlppiVEer+h1eO+9UbVFK/YZ7ZkZj06E0LtWkOcpLKDKjGw5d\nr7wbrqIiGjPeF6qWmkLqufehTLnAJxTQfVThG4tLz1GJG7gCuAo00btIRlUw\nLVQD+l1UPyYdCksa7fXj8oJCRhB/8+J0dLWvY1DitDU3/UeJf6C/V5zlA1Ae\nUnPUB4emVvPVohHxyB54yTG0YXMdt8QgcAK2YzT7PCFur6gNIGkzk1ZRtVoo\nDNc6\r\n=k5Jj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDSCJzBQtDJcOGJxv8JtnFJloa2nM8wYpDuukLQp7y6MAIgO/kChWMpy6sD7Bgy+qC9Ybp1hBSnWr5c4bztBa+1Bz8="}]},"_npmUser":{"name":"tigwyk","email":"lee@soylentcola.com"},"directories":{},"maintainers":[{"name":"tigwyk","email":"lee@soylentcola.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/client_2.0.2_1617490418224_0.5665975970063306"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-29T23:00:32.055Z","2.0.0":"2021-03-29T23:00:32.502Z","modified":"2022-04-04T11:06:51.030Z","2.0.1":"2021-04-03T22:15:06.667Z","2.0.2":"2021-04-03T22:53:38.409Z"},"maintainers":[{"name":"tigwyk","email":"lee@soylentcola.com"}],"description":"[![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://c","author":{"name":"Lee Ingram"},"license":"MIT","readme":"# accept-banano-client\n\n[![Build Status](https://travis-ci.com/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.com/tigwyk/accept-banano-client)\n[![Coverage Status](https://coveralls.io/repos/github/tigwyk/accept-banano-client/badge.svg?branch=master)](https://coveralls.io/github/tigwyk/accept-banano-client?branch=master)\n![npm (scoped)](https://img.shields.io/npm/v/@accept-banano/client)\n![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@accept-banano/client)\n![GitHub](https://img.shields.io/github/license/tigwyk/accept-banano-client)\n\nPayment gateway for [BANANO](https://banano.cc)\n\n_accept-banano-client_ is a JavaScript package that helps you to communicate with [_accept-banano_](https://github.com/tigwyk/accept-banano) for receiving BANANO payments easily in your client-side applications.\n\n## Installation\n\n### via NPM\n\n```bash\nnpm install @accept-banano/client\n\nyarn add @accept-banano/client\n```\n\n#### ES Modules / TypeScript\n\n```ts\nimport * as acceptBanano from '@accept-banano/client'\n```\n\n#### CommonJS\n\n```ts\nconst acceptBanano = require('@accept-banano/client')\n```\n\n### Directly in Browser, as a UMD module\n\nAfter the _accept-banano-client_ script is loaded there will be a global variable called _acceptBanano_, which you can access via `window.acceptBanano`\n\n```HTML\n<html>\n  <head>\n    ...\n    <script src=\"https://unpkg.com/@accept-banano/client@2\"></script>\n  </head>\n  ...\n</html>\n```\n\n## Usage\n\n### Creating a Payment Session\n\nTo be able to initiate the payment process, you **must create a new payment session.**\n\n```ts\n// 1- create a new payment session\ntype CreateSessionParams = {\n  apiHost: string // host of your Accept BANANO server, without protocol\n  pollInterval?: number // time interval (ms) to re-check for verification of a payment (default: 3s)\n  debug?: boolean // enables debug mode and prints some useful stuff to console\n}\n\nconst session = acceptBanano.createSession({\n  apiHost: 'accept-nano-demo.put.io',\n})\n\n// 2- register event listeners to shape-up your logic based on session events.\ntype PaymentSessionEvents = {\n  start: () => void\n  end: (error: PaymentError | null, payment: AcceptBananoPayment | null) => void\n}\n\nsession.on('start', () => {\n  myApp.paymentStarted()\n})\n\nsession.on('end', (error, payment) => {\n  if (error) {\n    return myApp.paymentFailed({ reason: error.reason })\n  }\n\n  return myApp.paymentSucceeded({\n    amount: payment.amount,\n    state: payment.state,\n  })\n})\n```\n\n### Presenting the Payment Overlay\n\nAfter creating your session and attaching the event listeners, you can follow one of those options to proceed with the payment flow.\n\n#### Option 1: Create a Payment Through Client\n\nIf you want to create and verify an _accept-banano_ payment in your client application, you can use this option.\n\nAfter the payment is created, _accept-banano-client_ will automatically proceed to the verification step.\n\n```ts\ntype CreatePaymentParams = {\n  amount: string // stringified number\n  currency: 'BANANO' | 'USD'\n  state?: string // payload to share between your client and server, will be embedded into the payment object\n}\n\nsession.createPayment({\n  amount: '1',\n  currency: 'USD',\n  state: '{userId:7}',\n})\n```\n\n#### Option 2: Verify a Payment Through Client\n\nIf 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.\n\n```ts\ntype VerifyPaymentParams = {\n  token: string // the Accept BANANO payment token created in your backend application\n}\n\nsession.verifyPayment({ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' })\n```\n\n## Contributing\n\n- Please [open an issue](https://github.com/tigwyk/accept-banano-client/issues/new) if you have a question or suggestion.\n- Don't create a PR before discussing it first.\n\n## Who is using _accept-nano-client_ in production?\n\n- Me\n\nPlease send a PR to list your site if _accept-banano_ is helping you to receive BANANO payments.\n","readmeFilename":"README.md"}