fix(pay): 移除支付沙盒模式 v2沙盒模式已下线
This commit is contained in:
@@ -61,10 +61,10 @@ async def create_order(
|
||||
request.client.host
|
||||
)
|
||||
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'}),
|
||||
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)
|
||||
db_crud = CRUD(db_session, Order)
|
||||
@@ -77,7 +77,7 @@ async def create_order(
|
||||
'status': base_schema.OrderStatusType.WAIT_PAYMENT
|
||||
},
|
||||
filters={
|
||||
'out_trade_no': out_trade_no,
|
||||
'order_id': out_trade_no,
|
||||
}
|
||||
)
|
||||
return {'data': {'payment_params': payment_params, 'order_id': order.order_id}}
|
||||
|
||||
@@ -33,16 +33,17 @@ class BaseClient:
|
||||
r = await self.session.request(
|
||||
method, url, headers=headers, params=params, data=data, json=json, **kwargs
|
||||
)
|
||||
result = r.json()
|
||||
if result.get('errcode'):
|
||||
logger.debug('\n'.join([
|
||||
f'method : {method}'
|
||||
f'url : {url}'
|
||||
f'params : {params}'
|
||||
f'body : {data or json}'
|
||||
f'response: {r.text}'
|
||||
]))
|
||||
raise WechatApiError('used result: {}'.format(result.get('errcode')))
|
||||
if 'json' in r.headers.get('Content-Type') or '':
|
||||
result = r.json()
|
||||
if result.get('errcode'):
|
||||
logger.debug('\n'.join([
|
||||
f'method : {method}'
|
||||
f'url : {url}'
|
||||
f'params : {params}'
|
||||
f'body : {data or json}'
|
||||
f'response: {r.text}'
|
||||
]))
|
||||
raise WechatApiError('used result: {}'.format(result.get('errcode')))
|
||||
return r
|
||||
|
||||
async def get(self, url, headers=None, params=None, **kwargs):
|
||||
@@ -144,8 +145,6 @@ class WechatPayApi(BaseClient):
|
||||
self.appi_key = app_key
|
||||
self.notify_url = notify_url
|
||||
self.base_url = 'https://api.mch.weixin.qq.com'
|
||||
if debug:
|
||||
self.base_url = f'{self.base_url}/sandboxnew'
|
||||
super().__init__()
|
||||
|
||||
@staticmethod
|
||||
@@ -178,6 +177,7 @@ class WechatPayApi(BaseClient):
|
||||
total_fee: int,
|
||||
create_ip: str,
|
||||
):
|
||||
"""https://pay.weixin.qq.com/doc/v2/merchant/4011936530"""
|
||||
url = self.base_url + '/pay/unifiedorder'
|
||||
params = {
|
||||
'appid': self.appid,
|
||||
|
||||
Reference in New Issue
Block a user