@geovis/paas-payjs
v0.2.6
Published
paas-payjs tool by js
Downloads
40
Readme
paas-payjs
安装
npm i @geovis/paas-payjs
初始化
import {PayMode} from '@geovis/paas-payjs';
import PaasPayClient from "@geovis/paas-payjs";
export class AppComponent {
private paasPayClient: PaasPayClient;
constructor(
private httpClient: HttpClient,
) {
// 初始化 host 可以配置到env文件中
this.paasPayClient = new PaasPayClient(
"https://api3.geovisearth.com/paasvip", // 请配置到env文件中, 根据不同环境进行切换
(action: string, data: any) => { // 订阅支付成功事件
console.log(action, data);
}
);
this.paasPayClient.bindHttpClient(this.httpClient);
}
}
返回结果说明
- 成功返回
{
"statusCode": 0,
"data": {}
}
- 失败返回
{
"statusCode": 1,
// 错误码
"message": 'xxx'
// 错误信息
}
获取SKU,并生成订单
this.paasPayClient.getSkuList({
isCreateDefaultOrder: true, //
}).then((res) => {
console.log(res);
});
{
"statusCode": 0,
"data": [
{
"group": "gu",
"key": "gu10",
"name": "企业VIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu10test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 23900,
"priceUnit": "cent"
},
{
"key": "gu10m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 59900,
"priceUnit": "cent"
},
{
"key": "gu10m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 199000,
"priceUnit": "cent"
}
]
},
{
"group": "gu",
"key": "gu20",
"name": "企业VVIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu20test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 59900,
"priceUnit": "cent"
},
{
"key": "gu20m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 149900,
"priceUnit": "cent"
},
{
"key": "gu20m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 499000,
"priceUnit": "cent"
}
]
},
{
"group": "gu",
"key": "gu30",
"name": "企业SVIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu30test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 119900,
"priceUnit": "cent"
},
{
"key": "gu30m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 299900,
"priceUnit": "cent"
},
{
"key": "gu30m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 999000,
"priceUnit": "cent"
}
]
}
]
}
单纯获取SKU列表, 不生成订单
this.paasPayClient.getSkuList().then((res) => {
console.log(res);
});
{
"statusCode": 0,
"data": [
{
"group": "gu",
"key": "gu10",
"name": "企业VIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu10test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu10m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 23900,
"priceUnit": "cent"
},
{
"key": "gu10m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 59900,
"priceUnit": "cent"
},
{
"key": "gu10m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 199000,
"priceUnit": "cent"
}
]
},
{
"group": "gu",
"key": "gu20",
"name": "企业VVIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu20test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu20m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 59900,
"priceUnit": "cent"
},
{
"key": "gu20m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 149900,
"priceUnit": "cent"
},
{
"key": "gu20m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 499000,
"priceUnit": "cent"
}
]
},
{
"group": "gu",
"key": "gu30",
"name": "企业SVIP",
"isFree": false,
"isPublic": true,
"isDefault": false,
"sell": [
{
"key": "gu30test0",
"name": "明天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 0,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test1",
"name": "1天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 1,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test2",
"name": "2天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 2,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test3",
"name": "3天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 3,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test4",
"name": "4天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 4,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30test5",
"name": "5天过期",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 5,
"sellUnit": "day",
"maxSellCount": 1,
"price": 1,
"priceUnit": "cent"
},
{
"key": "gu30m1",
"name": "1个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 31,
"sellUnit": "month",
"maxSellCount": 1,
"price": 119900,
"priceUnit": "cent"
},
{
"key": "gu30m3",
"name": "3个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 93,
"sellUnit": "month",
"maxSellCount": 1,
"price": 299900,
"priceUnit": "cent"
},
{
"key": "gu30m12",
"name": "12个月",
"isFree": false,
"isPublic": true,
"isDefault": false,
"unit": "day",
"count": 372,
"sellUnit": "month",
"maxSellCount": 1,
"price": 999000,
"priceUnit": "cent"
}
]
}
]
}
切换SKU,生成支付订单
this.paasPayClient.toggleSku(['gu10', 'gu10test5'], PayMode.AliPay).then((res) => {
console.log(res);
})
{
"statusCode": 0,
"data": {
"payUrl": "https://openapi.alipay.com/gateway.do?app_cert_sn=fa4d3373abf0daa04653d61deeca216f&alipay_root_cert_sn=687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6&method=alipay.trade.page.pay&app_id=2021003154652517&charset=utf-8&version=1.0&sign_type=RSA2×tamp=2023-11-20%2016%3A17%3A45¬ify_url=https%3A%2F%2Fapi1.geovisearth.com%2Fpay%2Fv1%2Fnotify%2Falipay%2FPaasBrain&return_url=https%3A%2F%2Fexplorer1.geovisearth.com%2F&sign=Ye5rHKqvBnP4y%2FpPymTulXWfmZ%2FWbDfKVTDuDav6i4BogmPDNZlzSRIxGoeuRB2WhA%2F1dce1bi6SbZw6btTinM2HIQfexsgPgkk6wc1SlWurpbKcer6XJeeKCjOw%2B%2BxiK3B%2Fxiq1pHd8wnapS94hOejtLpLeHzITO2n8nmKgu9DA%2BFzl%2FkJGXhk0oLDOyu0v4OF%2B7B0T1pY8C3jl8Vs4Ya1vtantuDaIl5laCOei4x3M45O0OSJ6zKyPzVfnvswdMfBAoTVrtRIPF5zA0E3ziZGFi%2BUR%2Feh%2BW4gkbaVqTbT16c2m15DK1QzXs6D4KSMD7Ye0q2l3s%2BKGuR75936Y5A%3D%3D&alipay_sdk=alipay-sdk-nodejs-3.6.1&biz_content=%7B%22out_trade_no%22%3A%2249GhN7VuZdUUsE_KAtQHFGFWADnmYaHD%22%2C%22total_amount%22%3A99%2C%22subject%22%3A%22%E6%99%BA%E8%84%91%E5%BC%95%E6%93%8EVIP%22%2C%22product_code%22%3A%22FAST_INSTANT_TRADE_PAY%22%2C%22body%22%3A%22%22%2C%22store_id%22%3A%22PaasBrain%22%2C%22time_expire%22%3A%222023-11-20%2016%3A47%3A45%22%7D",
"order": {
"id": "49GhN7VuZdUUsE_KAtQHFGFWADnmYaHD",
"createTime": "2023-11-20T08:14:36.239Z",
"updateTime": "2023-11-20T08:17:46.139Z",
"orderNo": "20231120161436889488",
"orderType": "VIP",
"userId": "e5d783b9-b2f5-4f9a-a7c8-e8b4297556df",
"userAccount": "paasadmin",
"count": 1,
"totalPrice": 9900,
"orderStatus": 1,
"orderStatusDes": "待支付",
"dataPackSnapshot": {
"key": "vipm12",
"name": "12个月",
"unit": "day",
"count": 372,
"price": 9900,
"right": {
"unit": "GB",
"quota": 100,
"interval": "month"
},
"sellUnit": "month",
"priceUnit": "cent",
"maxSellCount": 1
},
"payMode": "alipay"
}
}
}
获取会员信息
this.paasPayClient.getVipInfo().then((res) => {
console.log(res);
})
{
"statusCode": 0,
"data": {
"isVip": false,
"dataPack": {
"key": "common",
"name": "免费版",
"isFree": true,
"isPublic": true,
"right": {
"interval": "month",
"quota": 50,
"unit": "GB"
}
}
}
}
获取订单列表
this.paasPayClient.orderList(1, 10).then((res) => {
console.log(res);
});
{
"statusCode": 0,
"data": {
"rows": [
{
"id": "49GhN7VuZdUUsE_KAtQHFGFWADnmYaHD",
"createTime": "2023-11-20T08:14:36.239Z",
"updateTime": "2023-11-20T08:14:36.239Z",
"orderNo": "20231120161436889488",
"orderType": "VIP",
"dataPackSnapshot": {
"key": "vipm12",
"name": "12个月",
"unit": "day",
"count": 372,
"price": 9900,
"right": {
"unit": "GB",
"quota": 100,
"interval": "month"
},
"sellUnit": "month",
"priceUnit": "cent",
"maxSellCount": 1
},
"count": 1,
"totalPrice": 9900,
"orderStatus": -1,
"orderStatusDes": "待支付"
},
{
"id": "pkvg_XREv5w4lD7mJ0MQ17qEClcp3Qej",
"createTime": "2023-11-20T08:13:29.821Z",
"updateTime": "2023-11-20T08:13:31.006Z",
"orderNo": "20231120161329594772",
"orderType": "VIP",
"dataPackSnapshot": {
"key": "viptest0",
"name": "1天",
"unit": "day",
"count": 1,
"price": 1,
"right": {
"unit": "GB",
"quota": 100,
"interval": "month"
},
"sellUnit": "day",
"priceUnit": "cent",
"maxSellCount": 1
},
"count": 1,
"totalPrice": 1,
"orderStatus": 1,
"orderStatusDes": "待支付"
}
],
"count": 2,
"current": 1,
"total": 1,
"limit": 10
}
}
获取订单明细
this.paasPayClient.orderDetail('pkvg_XREv5w4lD7mJ0MQ17qEClcp3Qej').then((res) => {
console.log(res);
});
{
"statusCode": 0,
"data": {
"id": "pkvg_XREv5w4lD7mJ0MQ17qEClcp3Qej",
"createTime": "2023-11-20T08:13:29.821Z",
"updateTime": "2023-11-20T08:13:31.006Z",
"orderNo": "20231120161329594772",
"orderType": "VIP",
"dataPackSnapshot": {
"key": "viptest0",
"name": "1天",
"unit": "day",
"count": 1,
"price": 1,
"right": {
"unit": "GB",
"quota": 100,
"interval": "month"
},
"sellUnit": "day",
"priceUnit": "cent",
"maxSellCount": 1
},
"count": 1,
"totalPrice": 1,
"orderStatus": 1,
"orderStatusDes": "待支付"
}
}
手动关闭支付状态检查器
this.paasPayClient.closePayStatusChecker()