| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // 测试触发支付成功事件API
- const testApiPaths = async () => {
- const apiPaths = [
- '/api/v1/payments/payment/trigger-success',
- '/api/v1/payment/trigger-success'
- ];
- const testOrderId = 1; // 使用一个测试订单ID
- for (const apiPath of apiPaths) {
- console.log(`\n测试路径: ${apiPath}`);
- try {
- const response = await fetch(apiPath, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- orderId: testOrderId
- })
- });
- console.log(`状态码: ${response.status}`);
- console.log(`状态文本: ${response.statusText}`);
- if (response.ok) {
- const result = await response.json();
- console.log('成功响应:', JSON.stringify(result, null, 2));
- console.log(`✅ 路径 ${apiPath} 可用`);
- return apiPath;
- } else if (response.status === 401) {
- console.log('❌ 需要认证');
- } else if (response.status === 404) {
- console.log('❌ 路径不存在');
- } else {
- const errorText = await response.text();
- console.log('错误响应:', errorText.substring(0, 200));
- }
- } catch (error) {
- console.log('请求失败:', error.message);
- }
- }
- console.log('\n❌ 所有路径都不可用');
- return null;
- };
- // 运行测试
- console.log('开始测试触发支付成功事件API路径...');
- testApiPaths().then(successfulPath => {
- if (successfulPath) {
- console.log(`\n🎉 可用的API路径: ${successfulPath}`);
- } else {
- console.log('\n😞 没有找到可用的API路径');
- }
- }).catch(error => {
- console.error('测试失败:', error);
- });
|