fix(pay): 移除支付沙盒模式 v2沙盒模式已下线
This commit is contained in:
@@ -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}}
|
||||||
|
|||||||
@@ -33,16 +33,17 @@ 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
|
||||||
)
|
)
|
||||||
result = r.json()
|
if 'json' in r.headers.get('Content-Type') or '':
|
||||||
if result.get('errcode'):
|
result = r.json()
|
||||||
logger.debug('\n'.join([
|
if result.get('errcode'):
|
||||||
f'method : {method}'
|
logger.debug('\n'.join([
|
||||||
f'url : {url}'
|
f'method : {method}'
|
||||||
f'params : {params}'
|
f'url : {url}'
|
||||||
f'body : {data or json}'
|
f'params : {params}'
|
||||||
f'response: {r.text}'
|
f'body : {data or json}'
|
||||||
]))
|
f'response: {r.text}'
|
||||||
raise WechatApiError('used result: {}'.format(result.get('errcode')))
|
]))
|
||||||
|
raise WechatApiError('used result: {}'.format(result.get('errcode')))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
async def get(self, url, headers=None, params=None, **kwargs):
|
async def get(self, url, headers=None, params=None, **kwargs):
|
||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user