修正快手行业回调域名
This commit is contained in:
@@ -5,7 +5,7 @@ import { getKuaishouIndustryConfig } from './config.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kuaixiaodian.com'
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kwaixiaodian.com'
|
||||
|
||||
type ConsumeCallbackInput = {
|
||||
oid: string
|
||||
@@ -128,9 +128,7 @@ export async function consumeCallback(input: ConsumeCallbackInput): Promise<{ su
|
||||
return { success: ok, response: json }
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
logWarn('[kuaishou-industry/consume-callback]', `核销回调异常 oid=${input.oid}`, {
|
||||
error: message,
|
||||
})
|
||||
logWarn('[kuaishou-industry/consume-callback]', `核销回调异常 oid=${input.oid}`, resolveCallbackErrorDetail(err))
|
||||
return { success: false, error: message }
|
||||
}
|
||||
}
|
||||
@@ -156,3 +154,31 @@ function stringifySignValue(value: unknown): string {
|
||||
if (typeof value === 'object') return JSON.stringify(value, Object.keys(value as Record<string, unknown>).sort())
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function resolveCallbackErrorDetail(error: unknown): JsonObject {
|
||||
const detail: JsonObject = {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
}
|
||||
const cause = error && typeof error === 'object' && 'cause' in error
|
||||
? (error as { cause?: unknown }).cause
|
||||
: null
|
||||
if (!cause || typeof cause !== 'object') {
|
||||
return detail
|
||||
}
|
||||
|
||||
const current = cause as Record<string, unknown>
|
||||
const fields: Array<[string, unknown]> = [
|
||||
['causeMessage', current.message],
|
||||
['causeCode', current.code],
|
||||
['causeSyscall', current.syscall],
|
||||
['causeHostname', current.hostname],
|
||||
]
|
||||
for (const [key, value] of fields) {
|
||||
const text = String(value || '').trim()
|
||||
if (text) {
|
||||
detail[key] = text
|
||||
}
|
||||
}
|
||||
|
||||
return detail
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getKuaishouIndustryConfig } from './config.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kuaixiaodian.com'
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kwaixiaodian.com'
|
||||
|
||||
type DestroyCallbackInput = {
|
||||
oid: string
|
||||
@@ -110,9 +110,7 @@ export async function destroyCallback(input: DestroyCallbackInput): Promise<{ su
|
||||
return { success: ok, response: json }
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
logWarn('[kuaishou-industry/destroy-callback]', `销毁回调异常 oid=${input.oid}`, {
|
||||
error: message,
|
||||
})
|
||||
logWarn('[kuaishou-industry/destroy-callback]', `销毁回调异常 oid=${input.oid}`, resolveCallbackErrorDetail(err))
|
||||
return { success: false, error: message }
|
||||
}
|
||||
}
|
||||
@@ -138,3 +136,31 @@ function stringifySignValue(value: unknown): string {
|
||||
if (typeof value === 'object') return JSON.stringify(value, Object.keys(value as Record<string, unknown>).sort())
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function resolveCallbackErrorDetail(error: unknown): JsonObject {
|
||||
const detail: JsonObject = {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
}
|
||||
const cause = error && typeof error === 'object' && 'cause' in error
|
||||
? (error as { cause?: unknown }).cause
|
||||
: null
|
||||
if (!cause || typeof cause !== 'object') {
|
||||
return detail
|
||||
}
|
||||
|
||||
const current = cause as Record<string, unknown>
|
||||
const fields: Array<[string, unknown]> = [
|
||||
['causeMessage', current.message],
|
||||
['causeCode', current.code],
|
||||
['causeSyscall', current.syscall],
|
||||
['causeHostname', current.hostname],
|
||||
]
|
||||
for (const [key, value] of fields) {
|
||||
const text = String(value || '').trim()
|
||||
if (text) {
|
||||
detail[key] = text
|
||||
}
|
||||
}
|
||||
|
||||
return detail
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getKuaishouIndustryConfig } from './config.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kuaixiaodian.com'
|
||||
const KUAISHOU_OPEN_API = 'https://openapi.kwaixiaodian.com'
|
||||
|
||||
type SendCallbackInput = {
|
||||
oid: string
|
||||
@@ -122,9 +122,7 @@ export async function sendCallback(input: SendCallbackInput): Promise<{ success:
|
||||
return { success: ok, response: json }
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
logWarn('[kuaishou-industry/send-callback]', `发码回调异常 oid=${input.oid}`, {
|
||||
error: message,
|
||||
})
|
||||
logWarn('[kuaishou-industry/send-callback]', `发码回调异常 oid=${input.oid}`, resolveCallbackErrorDetail(err))
|
||||
return { success: false, error: message }
|
||||
}
|
||||
}
|
||||
@@ -150,3 +148,31 @@ function stringifySignValue(value: unknown): string {
|
||||
if (typeof value === 'object') return JSON.stringify(value, Object.keys(value as Record<string, unknown>).sort())
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function resolveCallbackErrorDetail(error: unknown): JsonObject {
|
||||
const detail: JsonObject = {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
}
|
||||
const cause = error && typeof error === 'object' && 'cause' in error
|
||||
? (error as { cause?: unknown }).cause
|
||||
: null
|
||||
if (!cause || typeof cause !== 'object') {
|
||||
return detail
|
||||
}
|
||||
|
||||
const current = cause as Record<string, unknown>
|
||||
const fields: Array<[string, unknown]> = [
|
||||
['causeMessage', current.message],
|
||||
['causeCode', current.code],
|
||||
['causeSyscall', current.syscall],
|
||||
['causeHostname', current.hostname],
|
||||
]
|
||||
for (const [key, value] of fields) {
|
||||
const text = String(value || '').trim()
|
||||
if (text) {
|
||||
detail[key] = text
|
||||
}
|
||||
}
|
||||
|
||||
return detail
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user