test-apig-flow2.ps1 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Retry timed-out endpoints with longer timeout + get full getApig data
  2. $apigId = "Vo3ROWEvDy"
  3. # --- Step 1: getApig full response ---
  4. Write-Host "=== Step 1: getApig (full) ===" -ForegroundColor Cyan
  5. $body1 = @{ authid = $apigId } | ConvertTo-Json -Compress
  6. try {
  7. $r1 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/getApig" -Method POST -ContentType "application/json" -Body $body1 -TimeoutSec 30
  8. $json1 = $r1 | ConvertTo-Json -Depth 10
  9. Write-Host $json1
  10. } catch {
  11. Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
  12. }
  13. Write-Host ""
  14. Write-Host "---"
  15. Write-Host ""
  16. # --- Step 3 retry: created-apigorder with fcompany (original field) ---
  17. Write-Host "=== Step 3a: created-apigorder (fcompany, original) ===" -ForegroundColor Cyan
  18. $now = Get-Date
  19. $tradeNo = "CTEST" + $now.ToString("yyyyMMddHHmmssfff")
  20. $orderBody3a = @{
  21. fcompany = "test-openclaw-user"
  22. type = "wxpay"
  23. authid = $apigId
  24. params = @{
  25. out_trade_no = $tradeNo
  26. total_fee = 0.01
  27. body = "test"
  28. }
  29. apigid = $apigId
  30. oldCount = 0
  31. count = 100
  32. } | ConvertTo-Json -Depth 3 -Compress
  33. try {
  34. $r3a = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/created-apigorder" -Method POST -ContentType "application/json" -Body $orderBody3a -TimeoutSec 60
  35. Write-Host "Response (fcompany):" -ForegroundColor Green
  36. $r3a | ConvertTo-Json -Depth 8
  37. } catch {
  38. Write-Host "Error (fcompany): $($_.Exception.Message)" -ForegroundColor Red
  39. }
  40. Write-Host ""
  41. # --- Step 3b: created-apigorder with user (new field per Chen Bin) ---
  42. Write-Host "=== Step 3b: created-apigorder (user, new) ===" -ForegroundColor Cyan
  43. $orderBody3b = @{
  44. user = "test-openclaw-user"
  45. type = "wxpay"
  46. authid = $apigId
  47. params = @{
  48. out_trade_no = $tradeNo
  49. total_fee = 0.01
  50. body = "test"
  51. }
  52. apigid = $apigId
  53. oldCount = 0
  54. count = 100
  55. } | ConvertTo-Json -Depth 3 -Compress
  56. try {
  57. $r3b = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/created-apigorder" -Method POST -ContentType "application/json" -Body $orderBody3b -TimeoutSec 60
  58. Write-Host "Response (user):" -ForegroundColor Green
  59. $r3b | ConvertTo-Json -Depth 8
  60. } catch {
  61. Write-Host "Error (user): $($_.Exception.Message)" -ForegroundColor Red
  62. }
  63. Write-Host ""
  64. # --- Step 5 retry: saveRecharge ---
  65. Write-Host "=== Step 5: saveRecharge (endpoint availability) ===" -ForegroundColor Cyan
  66. $rechargeBody = @{
  67. authComp = "test"
  68. authid = $apigId
  69. apigid = "test"
  70. oldCount = 0
  71. count = 100
  72. orderid = "test"
  73. } | ConvertTo-Json -Compress
  74. try {
  75. $r5 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/saveRecharge" -Method POST -ContentType "application/json" -Body $rechargeBody -TimeoutSec 60
  76. Write-Host "Response:" -ForegroundColor Green
  77. $r5 | ConvertTo-Json -Depth 5
  78. } catch {
  79. Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
  80. }