fast-pay-button
v0.1.0
Published
js library for fast pay button
Downloads
2
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付款处理期间按钮上显示的文字 | | success | The text displayed on the button when the payment is successful付款成功后按钮上显示的文字 |
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.
用户支付期间发生错误时的回调。