# fast-pay-button

> js library for fast pay button

Latest version **0.1.0** (published 2020-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-pay-button
pnpm add fast-pay-button
yarn add fast-pay-button
bun add fast-pay-button
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-01-15 |
| First published | 2020-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | fastpaybutton |
| Maintainers | llddzh |
| Keywords | fpb, fastpb, fastpaybutton |

## Links

- npm: https://www.npmjs.com/package/fast-pay-button
- npm.io page: https://npm.io/package/fast-pay-button

## Recent versions

- 0.1.0 (latest) — 2020-01-15

## README

This module is a js library for FastPayButton

#Install
npm i fast-pay-button

#Usage

Add a element with unique id in your html first
~~~
<div
  id="forbsv"
  style={{ height: 36, width: 80 }}
/>
~~~

and then use render function to show FastPayButton, the button will be placed inside your html
```
const FastPayButton = require('fast-pay-button')
const fastPayButton = new FastPayButton()

fastPayButton.render({
  buttonId: 'forbsv',
  buttonFrom: '9d6c****4e73',
  buttonKey: 'F5iG****zR5d',
  outputs: [{
    address: '1K8p****Gt4i',
    amount: 0.01,
    currency: 'BSV'
  }],
  words: {
    process: 'processing',
    success: 'ok',
  },
  styles: {
    initBackColor: 'green',
    textColor: 'white',
  },
  onPayment: () => {
    console.log('succ')
  },
  onError: (err) => {
    console.log(err)
  },
})
```

The render parameters are as follows

| Option        | Type     | Required |
| ------------- | -------- | -------- |
| buttonId      | string   | true     |
| buttonFrom    | string   | true     |
| buttonKey     | string   | true     |
| outputs       | array    | true     |
| words         | string   | false    |
| styles        | string   | false    |
| onPayment     | function | false    |
| onError       | function | false    |

#Discription

>buttonId

This attribute is the unique identifier of FastPayButton and must be consistent with the id of the dom node defined in the html

该属性是FastPayButton的唯一标识，必须与html中定义的dom节点的id保持一致

>buttonFrom

This attribute is the client id given to the caller by FastPayButton

该属性是FastPayButton赋予调用方的客户端id

>buttonKey

This property is the encrypted string of the client private key and buttonId.

该属性是客户端私钥和buttonId拼接后的加密字符串

>outputs

This attribute is used to specify a lists of outputs on the BSV transaction.It is an array of object lists, each element has the following properties.

此属性用于BSV支付的指定目标输出列表，它是个对象列表的数组，每个元素具有如下属性。

| Option   | Discription              |
| -------- | -----------------------  |
| user_id  | user id of FastPayButton |
| address  | bsv address              |
| script   | script                   |
| amount   | amount                   |
| currency | currency                 |

>words

This property is used to display the text of the button, including sub properties.

此属性用于按钮显示文字，包含以下属性

| Option   | Discription                                                                               |
| -------- | ----------------------------------------------------------------------------------------  |
| process  | Text displayed on the button during payment processing<br>付款处理期间按钮上显示的文字         |
| success  | The text displayed on the button when the payment is successful<br>付款成功后按钮上显示的文字 |

>styles


This property is used to customize the style of the button and contains the following properties.

此属性用于定制按钮的样式，包含以下属性

| Option        | Discription                                     |
| ------------- | ----------------------------------------------- |
| buttonzIndex  | z-Index of FastPayButton                        |
| initBackColor | back color of FastPayButton before slide button |
| textColor     | text color of FastPayButton                     |
| circleSrc     | image source of the slide circle button         |
| backSrc       | background image source of FastPayButton        |

>onPayment

A function that is called when the user makes a successful payment.

用户成功支付时的回调。

>onError

A function that is called when an error occurs during the payment.

用户支付期间发生错误时的回调。

---
_Source: https://npm.io/package/fast-pay-button · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
