npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coinchat-js-sdk

v0.1.11

Published

Coinchat Official JS-SDK

Downloads

18

Readme

COINCHAT JS SDK文档

如何使用

传统用法

  1. 在网页中引入./src/build/index.js的JS文件。
  2. 在网页前端调用coinchat.config()接口来执行config动作。
  3. 完成后在coinchat.ready()中传入config完成后的执行代码。

目前最新版本号为0.1.10

模块引入

npm install coinchat-js-sdk

在文件中引入

import coinchat from 'coinchat-js-sdk'

示例

1.网页引入JS文件

<script src="../src/build/js/index.js"></script>

2.在服务器通过API_KEY和SECRET_KEY签名,把签名后的sign传入网页,具体签名文档见签名文档

3.在网页上执行config动作

coinchat.config({
    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
    partner_no  : '1528949462419631"', // 必填,唯一标识
    timestamp: timestamp, // 必填,生成签名的时间戳
    nonce    : 'nonce_str', // 必填,生成签名的随机串
    sign     : 'ad4b36a22f78c6d9409dd21644702cc6ec9c0b08a9d1b00cd0c2436bd9fbd58f'
});

4.在网页上用coinchat.ready(function(){}) 来执行你的代码。

coinchat.ready(function(){
    console.log('coinchat签名通过')
    coinchat.getLoginUserInfo();
});

JS-SDK方法

获得是否在Coinchat中打开

coinchat.isCoinchat();

获得Coinchat当前版本号

coinchat.getVersion();

获得Coinchat当前的语言环境

coinchat.getLanguage();

获得签名

coinchat.getSign(data,api_secret);

获得登录用户信息

COINCHAT采用OAUTH的方法来获得当前用户的ID,如果你需要调用支付等,也需要通过此方案获得当前的登录用户ID。

获得用户信息

支付订单(至第三方托管账户)

需要config后才可以调用支付

coinchat.entrustPay({
    'deposit_no':json.data.deposit.deposit_no,
    'timestamp':timestamp,
    'nonce':timestamp,
    'partner_no':'1528949462419631',
    'callback_url' : 'your callback notify url',
    'success' : function(res) {
        console.log('支付成功',res)
   },
   'fail'    : function(res) {
        console.log('支付失败',res);
   }
})

支付的订单号deposit_no需要由服务器端通过API“/v1/entrust_wallet/deposit/add.html”下单后得到 支付成功会回调你设置的回调地址。

同时提供了退款,执行智能合约的API。在API文档可以查看。

支付订单(至商家账户余额)

需要config后才可以调用支付

coinchat.Pay({
    'order_no'  :'order_no',
    'timestamp' :timestamp,
    'nonce'     :timestamp,
    'partner_no':'1528949462419631',
    'callback_url' : 'your callback notify url',
    'success'   : function(res) {
        console.log('支付成功',res)
   },
   'fail'    : function(res) {
        console.log('支付失败',res);
   },
   'cancel'  :  function(res) {
        console.log('支付被用户取消',res);
   },
   'complete'  :  function(res) {
        console.log('支付完成',res);
   }
})

支付的订单号order_no需要由服务器端通过API“/v1/pay/order/add.html”下单后得到 支付成功会回调你设置的回调地址

支付订单(至ETH智能合约)

(需要config后才可以调用支付)

coinchat.contractPay({
    'address'   :   '0Xasdasdasdasdasdasd',
    'amount'    :   '0.1',
    'coin'      :   'ETH',
    'data'      :   "0xdc6dd1520000000000000000000000000000000000000000000000000000000000000040",
    'partner_no' :  "123123123123",
    'success'   : function(res) {
        console.log('支付成功',res)
    },
    'fail'    : function(res) {
        console.log('支付失败',res);
    },
    'cancel'  :  function(res) {
        console.log('支付被用户取消',res);
    },
    'complete'  :  function(res) {
        console.log('支付完成',res);
    }
})

关于“支付订单”2个接口,“至第三方托管账户“和“至商家账户余额“的区别和使用场景说明。

简单的说,支付至第三方托管账户仅提供给智能合约提供商,需要让用户去执行智能合约的第三方来调用。

  • 支付至第三方托管账户代表的是金额存入了一个小的热钱包,商家拥有完全的管理权限,可以调用接口执行转账,发起智能合约等操作。Coinchat仅托管了此钱包,对于商家发起的任意请求,都会签名发布到网络上。在发起转账,调智能合约等请求,都需要此钱包额外的支付矿工费用。因此在最初存入的时候,请预估好未来需要的矿工费。
  • 支付至商家账户,商家立即可以获得收款,此笔收款提现在商户账户上;此账户仅可转账给商家创建人的Coinchat个人账户,转账到创建人账户并不会收取手续费,在实际提现的时候才会有手续费。