微信小程序支付功能打通
This commit is contained in:
@@ -45,7 +45,7 @@ export class TradeController {
|
||||
@Post(':id/pay')
|
||||
@UseGuards(PhoneVerifiedGuard)
|
||||
pay(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
||||
return this.tradeService.payOrder(user.actorId, BigInt(id));
|
||||
return this.tradeService.payOrder(user.actorId, BigInt(id), user.clientApp);
|
||||
}
|
||||
|
||||
@Put(':id/address')
|
||||
|
||||
@@ -199,7 +199,7 @@ export class TradeService {
|
||||
return serializeBigInt(mapOrderCompat(order));
|
||||
}
|
||||
|
||||
async payOrder(userId: bigint, orderId: bigint) {
|
||||
async payOrder(userId: bigint, orderId: bigint, clientApp?: ClientApp) {
|
||||
const order = await this.prisma.order.findFirst({
|
||||
where: { id: orderId, userId },
|
||||
});
|
||||
@@ -214,7 +214,8 @@ export class TradeService {
|
||||
if (!appConfig.mockPay && !openId) {
|
||||
throw new BadRequestException(WECHAT_AUTH_REQUIRED);
|
||||
}
|
||||
const payResult = await this.payProvider.payOrder(orderId, openId);
|
||||
const payPlatform = clientApp === ClientApp.USER_MINI ? 'mini' : 'h5';
|
||||
const payResult = await this.payProvider.payOrder(orderId, openId, payPlatform);
|
||||
|
||||
if (payResult.mode === 'jsapi') {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user