@xiashe/sdk 0.1.24 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alipayWallet.mjs +59 -0
- package/index.mjs +3 -2
- package/package.json +1 -1
package/alipayWallet.mjs
CHANGED
|
@@ -878,3 +878,62 @@ export async function diagnoseAlipay402Resource(input, options = {}) {
|
|
|
878
878
|
updatedAt: state.updatedAt || null
|
|
879
879
|
};
|
|
880
880
|
}
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Creates a deliberately redacted support summary for an already-failed
|
|
884
|
+
* official-wallet attempt. This never invokes the wallet, re-fetches the
|
|
885
|
+
* resource, or reads/prints the Payment-Needed payload. It is intended for
|
|
886
|
+
* the official `alipay-bot problem-feedback` flow, where a generic wallet
|
|
887
|
+
* trade-creation error otherwise leaves an operator with no safe facts to
|
|
888
|
+
* report.
|
|
889
|
+
*/
|
|
890
|
+
export async function createAlipay402SupportReport(input, options = {}) {
|
|
891
|
+
const resourceUrl = normalizeResourceUrl(input?.resourceUrl);
|
|
892
|
+
const state = await readPaymentState(resourceUrl, options);
|
|
893
|
+
if (!state) {
|
|
894
|
+
return {
|
|
895
|
+
ok: false,
|
|
896
|
+
status: 'no_local_attempt',
|
|
897
|
+
provider: 'alipay-agent-payment',
|
|
898
|
+
walletInvoked: false,
|
|
899
|
+
message: '没有找到本地付款尝试,无法生成问题反馈材料。'
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
const failureCode = state.lastFailureCode || null;
|
|
904
|
+
const diagnosis = state.lastDiagnosis || null;
|
|
905
|
+
const failedBeforeConfirmation = !state.queryCredential?.value &&
|
|
906
|
+
['failed', 'wallet_command_failed'].includes(state.status);
|
|
907
|
+
const { stdout, stderr } = await runOfficialCli(['--version'], options);
|
|
908
|
+
const runtimeVersion = safeRuntimeVersion(stdout, stderr) || null;
|
|
909
|
+
const lines = [
|
|
910
|
+
'[环节]:402 支付 / 官方钱包创建交易',
|
|
911
|
+
`[结果]:${failedBeforeConfirmation ? '未创建可确认交易,未获得 Payment-Proof' : '请以本地诊断状态为准'}`,
|
|
912
|
+
`[桥接诊断]:${diagnosis?.code || failureCode || 'unknown'}`,
|
|
913
|
+
`[官方代码]:${diagnosis?.officialCode || '未返回'}`,
|
|
914
|
+
`[官方运行时]:${runtimeVersion || '未知'}`,
|
|
915
|
+
`[发生时间]:${state.updatedAt || state.createdAt || '未知'}`,
|
|
916
|
+
'[已确认]:卖方资源返回字段结构有效的 402 账单;本次未生成可查询交易凭证。',
|
|
917
|
+
'[请协助]:返回本次 TRADE_PROGRESS_FAILED 的子码、requestId/traceId,以及交易创建被拒绝的具体校验项。'
|
|
918
|
+
];
|
|
919
|
+
return {
|
|
920
|
+
ok: true,
|
|
921
|
+
status: 'support_report_ready',
|
|
922
|
+
provider: 'alipay-agent-payment',
|
|
923
|
+
walletInvoked: false,
|
|
924
|
+
report: {
|
|
925
|
+
category: 'ALIPAY_402_TRADE_CREATION_FAILED',
|
|
926
|
+
attemptId: `alipay-402:${state.resourceDigest.slice(0, 16)}`,
|
|
927
|
+
occurredAt: state.updatedAt || state.createdAt || null,
|
|
928
|
+
officialRuntimeVersion: runtimeVersion,
|
|
929
|
+
failureCode,
|
|
930
|
+
...(diagnosis?.officialCode ? { officialCode: diagnosis.officialCode } : {}),
|
|
931
|
+
...(diagnosis?.officialSubCode ? { officialSubCode: diagnosis.officialSubCode } : {}),
|
|
932
|
+
billShapeValidated: state.merchantResource?.billShapeValidated === true,
|
|
933
|
+
paymentNeededReceived: state.merchantResource?.paymentNeededReceived === true,
|
|
934
|
+
queryCredentialCreated: Boolean(state.queryCredential?.value),
|
|
935
|
+
text: lines.join('\n')
|
|
936
|
+
},
|
|
937
|
+
message: '已生成脱敏的问题反馈材料;其中不包含订单号、资源 URL、账单、Payment-Proof 或钱包凭证。'
|
|
938
|
+
};
|
|
939
|
+
}
|
package/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import { ConvexHttpClient } from 'convex/browser';
|
|
7
7
|
import { anyApi as api } from 'convex/server';
|
|
8
8
|
|
|
9
|
-
export const VERSION = '0.1.
|
|
9
|
+
export const VERSION = '0.1.25';
|
|
10
10
|
|
|
11
11
|
export const DEFAULTS = {
|
|
12
12
|
cn: {
|
|
@@ -1365,5 +1365,6 @@ export {
|
|
|
1365
1365
|
preflightAlipay402Resource,
|
|
1366
1366
|
payAlipay402Resource,
|
|
1367
1367
|
queryAlipay402Resource,
|
|
1368
|
-
diagnoseAlipay402Resource
|
|
1368
|
+
diagnoseAlipay402Resource,
|
|
1369
|
+
createAlipay402SupportReport
|
|
1369
1370
|
} from './alipayWallet.mjs';
|