whatmode-pay

1.2.5 • Public • Published

996.icu

LICENSE

LICENSE

安装

npm install git+ssh://git@git.socialeras.com:frontend/payment.git#v0.1.0

用法

 
    const payment = new Payment('your key')
 
    payment.createOrder((token, currency) => {
      return pay(token, 111, currency).then(
        res => res.payload.tno
      )
    })
 
    payment.addApproveListener((approve)=>{
      console.log(approve)
    })
 
    payment.mount(document.getElementById('root'))
 
只需要三步
  1. new Payment 并且将你的 public key 传入, public key 每个商户都有
  2. 实现 createOrder 的回调函数,你会收到 token 和 currency 两个参数,将它传给后端,后端需要根据它创建订单。后端的返回里面会有 tno。 记住!!一定要将 tno return 回去
  3. addApproveListener的回调会返回onApprove回来的数据。
  4. 最后找个dom,把这个组件mount 上去

参数

Payment Constructor
参数名 接受类型 是否必填 描述
publicKey string 必填 向后端获取,每个商户都有一个
options string 选填 default 默认选中的支付方式,共有两个选项 一个 paypal 一个是 creditCard

例如

 
 const payment = new Payment('your key', { default: 'paypal' })
Payment Method
方法名 接受类型 是否必填 描述
createOrder fn 必填 createOrder 的回调函数
mount dom 必填 要将组件mount到哪个组件

Readme

Keywords

none

Package Sidebar

Install

npm i whatmode-pay

Weekly Downloads

8

Version

1.2.5

License

ISC

Unpacked Size

303 kB

Total Files

44

Last publish

Collaborators

  • mifind