Skip to content

Commit b1f8fe9

Browse files
committed
feat(pay): complete pay module
1 parent 68360b0 commit b1f8fe9

27 files changed

+512
-147
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/node_modules
44
/build
55

6-
/cert
7-
86
# Logs
97
logs
108
*.log

example.env

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ OBB_GOOGLE_CLIENT_SECRET=
3434
OBB_GOOGLE_REDIRECT_URI=
3535

3636
OBB_ALIPAY_APPID=
37-
OBB_ALIPAY_CERT_PATH=
38-
OBB_ALIPAY_KEY_PATH=
39-
OBB_ALIPAY_RETURN_URL=
37+
OBB_ALIPAY_CERT=
38+
OBB_ALIPAY_KEY=
4039

4140
OBB_WECHAT_APP_KEY=
4241
OBB_WECHAT_PAY_APPID=
4342
OBB_WECHAT_PAY_MCHID=
4443
OBB_WECHAT_PAY_SERIAL=
45-
OBB_WECHAT_PAY_CERT_PATH=
46-
OBB_WECHAT_PAY_KEY_PATH=
44+
OBB_WECHAT_PAY_CERT=
45+
OBB_WECHAT_PAY_KEY=

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"meilisearch": "^0.50.0",
9696
"minio": "^8.0.6",
9797
"nanoid": "^5.1.6",
98+
"nest-wechatpay-node-v3": "^1.0.2",
9899
"nestjs-i18n": "^10.5.1",
99100
"nestjs-otel": "^7.0.1",
100101
"nodemailer": "^6.10.1",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ import { isEmpty } from 'omniboxd/utils/is-empty';
7676
import { Files1761556143000 } from 'omniboxd/migrations/1761556143000-files';
7777
import { FilesModule } from 'omniboxd/files/files.module';
7878
import { AddFileIdToResources1761726974942 } from 'omniboxd/migrations/1761726974942-add-file-id-to-resources';
79+
import { Products1762847077000 } from 'omniboxd/migrations/1762847077000-products';
80+
import { Orders1762847078000 } from 'omniboxd/migrations/1762847078000-orders';
81+
import { AddMetadataToUserBindings1762847685000 } from 'omniboxd/migrations/1762847685000-add-metadata-to-user-bindings';
7982

8083
@Module({})
8184
export class AppModule implements NestModule {
@@ -206,6 +209,9 @@ export class AppModule implements NestModule {
206209
ShareUser1760171824000,
207210
Files1761556143000,
208211
AddFileIdToResources1761726974942,
212+
Products1762847077000,
213+
Orders1762847078000,
214+
AddMetadataToUserBindings1762847685000,
209215
...extraMigrations,
210216
],
211217
migrationsRun: true,

src/auth/google/google.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export class GoogleService {
200200
userId,
201201
loginType: 'google',
202202
loginId: userData.sub,
203+
metadata: userData,
203204
});
204205
const returnValue = {
205206
id: existingUser.id,
@@ -231,6 +232,7 @@ export class GoogleService {
231232
userId: linkedAccount.id,
232233
loginType: 'google',
233234
loginId: userData.sub,
235+
metadata: userData,
234236
});
235237
const returnValue = {
236238
id: existingUser.id,
@@ -266,6 +268,7 @@ export class GoogleService {
266268
loginId: userData.sub,
267269
email: userData.email,
268270
lang,
271+
metadata: userData,
269272
} as CreateUserBindingDto,
270273
manager,
271274
);

src/auth/wechat/wechat.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ import { AppException } from 'omniboxd/common/exceptions/app.exception';
1010
import { I18nService } from 'nestjs-i18n';
1111

1212
export interface WechatUserInfo {
13-
unionid: string;
14-
nickname: string;
1513
openid: string;
14+
nickname: string;
15+
sex: number;
16+
province: string;
17+
city: string;
18+
country: string;
19+
headimgurl: string;
20+
privilege: Array<string>;
21+
unionid: string;
1622
}
1723

1824
@Injectable()
@@ -200,6 +206,7 @@ export class WechatService {
200206
userId,
201207
loginType: 'wechat',
202208
loginId: userData.unionid,
209+
metadata: userData,
203210
});
204211
const returnValue = {
205212
id: existingUser.id,
@@ -236,6 +243,7 @@ export class WechatService {
236243
loginType: 'wechat',
237244
loginId: userData.unionid,
238245
lang,
246+
metadata: userData,
239247
} as CreateUserBindingDto,
240248
manager,
241249
);

src/i18n/en/pay.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"errors": {
33
"invalidParameter": "Invalid parameter",
4-
"signatureVerificationFailed": "Signature verification failed",
5-
"missingRequiredParameters": "Missing required parameters",
6-
"orderAmountMismatch": "Order amount mismatch",
7-
"cannotGetUserIP": "Cannot get user's valid IP, unable to create order"
4+
"cannotGetUserIP": "Cannot get user's valid IP, unable to create order",
5+
"wechatNotBound": "WeChat account is not bound or missing openid"
86
}
97
}

src/i18n/en/product.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"errors": {
3-
"productNotFound": "Product not found"
3+
"productNotFound": "Product not found",
4+
"productNotAvailable": "Product not available"
45
}
56
}

src/i18n/zh/pay.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"errors": {
33
"invalidParameter": "参数错误",
4-
"signatureVerificationFailed": "签名验证失败",
5-
"missingRequiredParameters": "缺少必要参数",
6-
"orderAmountMismatch": "订单金额不匹配",
7-
"cannotGetUserIP": "无法获取用户有效IP,无法创建订单"
4+
"cannotGetUserIP": "无法获取用户有效IP,无法创建订单",
5+
"wechatNotBound": "微信账号未绑定或缺少openid"
86
}
97
}

0 commit comments

Comments
 (0)