Comments (3)
我们只支持 nodejs 的官方 api,类似 bun 这种兼容 nodejs api 的运行时应该是可以运行的。
from alipay-sdk-nodejs-all.
实际上并不能,在使用sdk发送curl请求时,会将密钥对内容进行签名,但实际上密钥是base64的,在签名时使用node:crypto模块对密钥显式解码时,爆出私钥的base64无法解码
以下是逻辑代码和测试文件内容
`deno.json
{
...
"imports": {
"alipaysdk": "npm:alipay-sdk@latest"
}
...
}
javascript
// projectroot/tools/sdk/alipay.ts
import { AlipaySdk } from "alipaysdk";
const urlObj = new URL(import.meta.url);
const query = Object.fromEntries(urlObj.searchParams.entries());
/**
- 如果当前是测试模式,需要自动加载环境变量
*/
if ("test" in query) {
await import("$std/dotenv/load.ts");
}
let alipaySdk: AlipaySdk;
export function getAlipaySDKInstane() {
if (alipaySdk) {
return alipaySdk;
}
return alipaySdk = new AlipaySdk({
appId: Deno.env.get("ALIPAY_APPID") as string,
privateKey: Deno.env.get("APP_PRIVATE_KEY") as string,
alipayPublicKey: Deno.env.get("ALIPAY_PUBLIC_KEY"),
gateway: "https://openapi.alipay.com/gateway.do",
// keyType: "PKCS8",
});
}
javascript
// projectroot/test/alipay.test.ts
import { getAlipaySDKInstane } from "../tools/sdk/alipay.ts?test";
Deno.test("test alipay sdk", async (t) => {
const alipay = getAlipaySDKInstane();
await t.step("test query", async (t) => {
const result = await alipay.curl("POST", "alipay.trade.page.pay", {
body: {
bizContent: {
outTradeNo: "123456",
productCode: "FAST_INSTANT_TRADE_PAY",
totalAmount: "0.01",
},
},
});
console.log(result);
});
});
`
from alipay-sdk-nodejs-all.
deno 不支持 nodejs api,是不支持的。
from alipay-sdk-nodejs-all.
Related Issues (20)
- 引入SDK有报错信息 HOT 4
- Invalid signature HOT 1
- invalid-signature 错误原因: 验签出错 HOT 1
- 授权信息加载失败 HOT 1
- 生成的wap 订单链接,无法拉起沙盒版支付宝
- 生成的wap 订单链接,无法拉起沙盒版支付宝 HOT 2
- 针对 SPI接口, 有没有完整例子可以参考 HOT 1
- npm audit有高危,也许升级一下urllib?
- 重构使用 支付宝 API v3 接口规范 HOT 3
- alipay.system.oauth.token未返回错误但抛出异常 HOT 2
- v4:支持请求内容加密
- v4:签名算法支持 SM2WithSM3
- alipay.open.file.upload上传超出限制 HOT 4
- v4 支持证书加签
- exec 方法支持 AlipayFormStream HOT 7
- 请求内容驼峰会被意外的转换 HOT 11
- 需要批量付款的api和case HOT 6
- 接口内容加密方式如何验证 HOT 10
- update URL for gateway HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alipay-sdk-nodejs-all.