| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // 测试支付成功触发API
- async function testPaymentTrigger() {
- console.log('=== 测试支付成功触发API ===\n');
- const apiUrl = 'http://localhost:8080/api/v1/payments/payment/trigger-success';
- const testOrderId = 999; // 使用一个不存在的订单ID来测试
- console.log(`测试API: ${apiUrl}`);
- console.log(`测试订单ID: ${testOrderId}\n`);
- try {
- const response = await fetch(apiUrl, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer test-token' // 需要有效的token
- },
- 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('\n✅ API调用成功');
- } else {
- const errorText = await response.text();
- console.log('错误响应:', errorText.substring(0, 500));
- console.log('\n❌ API调用失败');
- }
- } catch (error) {
- console.error('请求失败:', error.message);
- console.error('错误堆栈:', error.stack);
- }
- }
- // 运行测试
- testPaymentTrigger().catch(error => {
- console.error('测试脚本执行失败:', error);
- process.exit(1);
- });
|