alipay / alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
https://docs.open.alipay.com/54/103419/
Other
410 stars 65 forks source link

唉,TypeScript,提高阅读成本 #6

Closed x-da closed 6 years ago

x-da commented 6 years ago

头疼,还要折腾TypeScript的环境

tudou527 commented 6 years ago

看 readme 的文档不是更方便 ?

另外,不用折腾环境,npm install 安装下来是 js 代码,不是 ts

atian25 commented 6 years ago

他的意思估计是,文档都是 ts 的写法的

x-da commented 6 years ago

感谢两位回复,typeScript这块了解的不多,没其他冒犯的意思。

x-da commented 6 years ago
const AlipaySdk = require('alipay-sdk').default;
const Ali = new AlipaySdk({
    appId: '2018082461*****',
    privateKey: fs.readFileSync('./cert/rsa_private_key.pem', 'ascii'),
    alipayPublicKey: fs.readFileSync('./cert/rsa_public_key.pem', 'ascii'),
});

Ali.exec('alipay.system.oauth.token', {
    grantType: 'authorization_code',
    code: 'code'
},{validateSign: true}).catch(function(err){
    console.log(err);
});

分享一下 JS写法