{"_id":"@bananobay/accept-banano-client","_rev":"1-5c345445032ca744b85b974f51b42793","name":"@bananobay/accept-banano-client","dist-tags":{"latest":"2.0.3"},"versions":{"2.0.3":{"version":"2.0.3","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"},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"prettier":"@putdotio/prettier-config","name":"@bananobay/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","yarn":"^1.22.11"},"gitHead":"a68a1c476b1b01bae7dfcc2a2c78bf9f27d18767","description":"[![Build Status](https://travis-ci.com/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.com/tigwyk/accept-banano-client)\r [![Coverage Status](https://coveralls.io/repos/github/tigwyk/accept-banano-client/badge.svg?branch=master)](https://","_id":"@bananobay/accept-banano-client@2.0.3","_nodeVersion":"16.6.2","_npmVersion":"7.20.3","dist":{"integrity":"sha512-LsiDOT5TsYAJDLLy5+BjxyQO4cs6S05TsgJ9BCe/B1EfCQZ0r0UsTm9UvM1Ewh8DTDzJENcTmvCm1DFy0X6N2A==","shasum":"cf3d1d3ebbf1bae526e2565b4ad2b0e56423eaa0","tarball":"https://registry.npmjs.org/@bananobay/accept-banano-client/-/accept-banano-client-2.0.3.tgz","fileCount":55,"unpackedSize":1402796,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhG0HACRA9TVsSAnZWagAAMNAP/RAS9pXJFa5fnWbLkh2O\n0uNkqSO8nRCkdfngd/L92OgjJD/KVNW+Su5roGyCaEb9u3ByDBUtOKdK1pRa\nmMBe5aw4BaZWmx6s3riv80xejukvCKq9+QQ7AXuddTTXHukPlZuvW3dYpTI6\nLAb3Xsc2mzf7/bsdVr8OfPEdActgZredwad3GbqNS0kEEerlRgjql41lZp4Y\nd28H/ghr9O7B8Sz43hBb5WsFuE453nH2a6IuuHnd2ekzDKj1znDd/GNUH4Nm\nHmTk2mFKKuRjDW0uXFJ0ZmWPmP8paF3D8ILwVM2H5admi0G/p0nQG7CSqUL6\n9kpDUpULsixnZ1VSwoq4+c2k/C7ohdpivPpTFlOmUwaSQ2JYxsIwO3/ddG3d\nAdbQ0eLRRP1umrgODqCX06vWGh8WFXwl6FXvZ9FmTAVLlMx26BioemMY2dtX\n44VW6KfDXtLLhx71e0jJqDVuLYT76/moAVlBdrzAxf1L1kfdxyNjaTZ8hqMQ\nHjB22ISXGjeGD/AN8jxzzvEKM5KcxzYsnuxlWzOrqHQfsquZ2va3RYWph9wx\nskZXPjt6SZ6McGzXkozWtO6E3jkX+3JdVdGegpDMYWyqCt/mzF0A5PNUpON8\n/7ZqoGr9bA0MjHU7b20z5t8jl2QaaUej6JKjt1RVI4UDlvDZxNPthhwP06BX\nSfCE\r\n=E8P8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHaNtVvJ/cPBGsGToqX0V4kQhJeTACexKe8WFUx6zAZUAiB2HgTm6UnBKc4Estb8zsyD+RYHM1bUu6+KYtrhPYe+eg=="}]},"_npmUser":{"name":"mconstant","email":"bobbaxter@protonmail.com"},"directories":{},"maintainers":[{"name":"mconstant","email":"bobbaxter@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/accept-banano-client_2.0.3_1629176256589_0.2651710593373833"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-17T04:57:36.541Z","2.0.3":"2021-08-17T04:57:36.770Z","modified":"2022-04-04T17:40:53.941Z"},"maintainers":[{"name":"mconstant","email":"bobbaxter@protonmail.com"}],"description":"[![Build Status](https://travis-ci.com/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.com/tigwyk/accept-banano-client)\r [![Coverage Status](https://coveralls.io/repos/github/tigwyk/accept-banano-client/badge.svg?branch=master)](https://","author":{"name":"Lee Ingram"},"license":"MIT","readme":"# accept-banano-client\r\n\r\n[![Build Status](https://travis-ci.com/tigwyk/accept-banano-client.svg?branch=master)](https://travis-ci.com/tigwyk/accept-banano-client)\r\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)\r\n![npm (scoped)](https://img.shields.io/npm/v/@accept-banano/client)\r\n![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@accept-banano/client)\r\n![GitHub](https://img.shields.io/github/license/tigwyk/accept-banano-client)\r\n\r\nPayment gateway for [BANANO](https://banano.cc)\r\n\r\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.\r\n\r\n## Installation\r\n\r\n### via NPM\r\n\r\n```bash\r\nnpm install @accept-banano/client\r\n\r\nyarn add @accept-banano/client\r\n```\r\n\r\n#### ES Modules / TypeScript\r\n\r\n```ts\r\nimport * as acceptBanano from '@accept-banano/client'\r\n```\r\n\r\n#### CommonJS\r\n\r\n```ts\r\nconst acceptBanano = require('@accept-banano/client')\r\n```\r\n\r\n### Directly in Browser, as a UMD module\r\n\r\nAfter the _accept-banano-client_ script is loaded there will be a global variable called _acceptBanano_, which you can access via `window.acceptBanano`\r\n\r\n```HTML\r\n<html>\r\n  <head>\r\n    ...\r\n    <script src=\"https://unpkg.com/@accept-banano/client@2\"></script>\r\n  </head>\r\n  ...\r\n</html>\r\n```\r\n\r\n## Usage\r\n\r\n### Creating a Payment Session\r\n\r\nTo be able to initiate the payment process, you **must create a new payment session.**\r\n\r\n```ts\r\n// 1- create a new payment session\r\ntype CreateSessionParams = {\r\n  apiHost: string // host of your Accept BANANO server, without protocol\r\n  pollInterval?: number // time interval (ms) to re-check for verification of a payment (default: 3s)\r\n  debug?: boolean // enables debug mode and prints some useful stuff to console\r\n}\r\n\r\nconst session = acceptBanano.createSession({\r\n  apiHost: 'accept-nano-demo.put.io',\r\n})\r\n\r\n// 2- register event listeners to shape-up your logic based on session events.\r\ntype PaymentSessionEvents = {\r\n  start: () => void\r\n  end: (error: PaymentError | null, payment: AcceptBananoPayment | null) => void\r\n}\r\n\r\nsession.on('start', () => {\r\n  myApp.paymentStarted()\r\n})\r\n\r\nsession.on('end', (error, payment) => {\r\n  if (error) {\r\n    return myApp.paymentFailed({ reason: error.reason })\r\n  }\r\n\r\n  return myApp.paymentSucceeded({\r\n    amount: payment.amount,\r\n    state: payment.state,\r\n  })\r\n})\r\n```\r\n\r\n### Presenting the Payment Overlay\r\n\r\nAfter creating your session and attaching the event listeners, you can follow one of those options to proceed with the payment flow.\r\n\r\n#### Option 1: Create a Payment Through Client\r\n\r\nIf you want to create and verify an _accept-banano_ payment in your client application, you can use this option.\r\n\r\nAfter the payment is created, _accept-banano-client_ will automatically proceed to the verification step.\r\n\r\n```ts\r\ntype CreatePaymentParams = {\r\n  amount: string // stringified number\r\n  currency: 'BANANO' | 'USD'\r\n  state?: string // payload to share between your client and server, will be embedded into the payment object\r\n}\r\n\r\nsession.createPayment({\r\n  amount: '1',\r\n  currency: 'USD',\r\n  state: '{userId:7}',\r\n})\r\n```\r\n\r\n#### Option 2: Verify a Payment Through Client\r\n\r\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.\r\n\r\n```ts\r\ntype VerifyPaymentParams = {\r\n  token: string // the Accept BANANO payment token created in your backend application\r\n}\r\n\r\nsession.verifyPayment({ token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' })\r\n```\r\n\r\n## Contributing\r\n\r\n- Please [open an issue](https://github.com/tigwyk/accept-banano-client/issues/new) if you have a question or suggestion.\r\n- Don't create a PR before discussing it first.\r\n\r\n## Who is using _accept-nano-client_ in production?\r\n\r\n- Me\r\n\r\nPlease send a PR to list your site if _accept-banano_ is helping you to receive BANANO payments.\r\n","readmeFilename":"README.md"}