fix(pay): 移除支付沙盒模式 v2沙盒模式已下线

This commit is contained in:
xingc
2025-05-06 21:10:22 +08:00
parent 3a49fd1665
commit 4a111fcbdd
2 changed files with 15 additions and 15 deletions

View File

@@ -61,10 +61,10 @@ async def create_order(
request.client.host request.client.host
) )
out_trade_no = generate_order_number() out_trade_no = generate_order_number()
prepay_id = wechat_pay_api.create_unified_order( prepay_id = await wechat_pay_api.create_unified_order(
**payload.model_dump(exclude_none=True, exclude={'product_id'}), **payload.model_dump(exclude_none=True, exclude={'product_id'}),
out_trade_no=out_trade_no, out_trade_no=out_trade_no,
spbill_create_ip=client_ip create_ip=client_ip
) )
payment_params = wechat_pay_api.generate_payment_params(prepay_id) payment_params = wechat_pay_api.generate_payment_params(prepay_id)
db_crud = CRUD(db_session, Order) db_crud = CRUD(db_session, Order)
@@ -77,7 +77,7 @@ async def create_order(
'status': base_schema.OrderStatusType.WAIT_PAYMENT 'status': base_schema.OrderStatusType.WAIT_PAYMENT
}, },
filters={ filters={
'out_trade_no': out_trade_no, 'order_id': out_trade_no,
} }
) )
return {'data': {'payment_params': payment_params, 'order_id': order.order_id}} return {'data': {'payment_params': payment_params, 'order_id': order.order_id}}

View File

@@ -33,6 +33,7 @@ class BaseClient:
r = await self.session.request( r = await self.session.request(
method, url, headers=headers, params=params, data=data, json=json, **kwargs method, url, headers=headers, params=params, data=data, json=json, **kwargs
) )
if 'json' in r.headers.get('Content-Type') or '':
result = r.json() result = r.json()
if result.get('errcode'): if result.get('errcode'):
logger.debug('\n'.join([ logger.debug('\n'.join([
@@ -144,8 +145,6 @@ class WechatPayApi(BaseClient):
self.appi_key = app_key self.appi_key = app_key
self.notify_url = notify_url self.notify_url = notify_url
self.base_url = 'https://api.mch.weixin.qq.com' self.base_url = 'https://api.mch.weixin.qq.com'
if debug:
self.base_url = f'{self.base_url}/sandboxnew'
super().__init__() super().__init__()
@staticmethod @staticmethod
@@ -178,6 +177,7 @@ class WechatPayApi(BaseClient):
total_fee: int, total_fee: int,
create_ip: str, create_ip: str,
): ):
"""https://pay.weixin.qq.com/doc/v2/merchant/4011936530"""
url = self.base_url + '/pay/unifiedorder' url = self.base_url + '/pay/unifiedorder'
params = { params = {
'appid': self.appid, 'appid': self.appid,