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

ali-node-sdk

v1.0.4

Published

alipay sdk

Downloads

12

Readme

支付宝SDK


安装

npm install ali-node-sdk --save

使用

const AliClient = require('ali-node-sdk');

const client = new AliClient({
    appId: 'xxxx',
    privateKey: '商户私钥',
    aliPublicKey: '支付宝公钥',
    sandbox: true //可选,设置为 true将会切换为沙箱的网关
});

//根据auth_code获取access_token
client.alipaySystemOauthToken({
     grant_type: 'authorization_code',  //值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取
     code: 'xxxxx',  //支付宝回传的auth_code 
     refresh_token: 'xxxx', //如果是刷新access_token则传入该参数
}).then(res => {
    console.log(res);
})

支持接口

  • alipay.system.oauth.token
  • alipay.user.info.share
  • ssdata.dataservice.risk.rainscore.query

增加接口

  1. ./requests 目录下增加以接口名命名的request文件

  2. ./requests/index.js 文件中注册接口

    注意

    • 具体参数可参考支付宝Api文档
    • 方法名同支付宝method(使用驼峰命名) 如: alipay.system.oauth.token => client.alipaySystemOauthToken

    示例

    ./requests/alipaySystemOauthToken.js

    /**
     * Created on 2017/11/14.
     * @fileoverview 请填写简要的文件说明.
     * @author gauze (Firstname Lastname)
     */
    const Ali = require('../core');
    
    module.exports = class AlipaySystemOauthToken {
        constructor (params) {
            this.method = 'GET';    // http 请求接口方式
            this._method = 'alipay.system.oauth.token'; //接口名 请参考支付宝api文档
            const rules = {     //参数验证规则,使用parameter包进行参数验证
                grant_type: 'string',
                code: 'string',
                refresh_token: {type: 'string', required: false}
            };
    
            //检查参数
            Ali.util.validate(rules, params); //引用的parameter包的 validate方法
            this.params = params;
        }
    };

    ./requests/index.js

    /**
     * Created on 2017/11/14.
     * @fileoverview 请填写简要的文件说明.
     * @author gauze (Firstname Lastname)
     */
    const alipaySystemOauthToken = require('./alipaySystemOauthToken'); //引入接口
    const alipayUserInfoShare = require('./alipayUserInfoShare');
    
    module.exports = {
        alipaySystemOauthToken, //导出并注册接口
        alipayUserInfoShare
    };