@xiashe/sdk 0.1.24 → 0.1.26
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 +69 -1
- package/index.mjs +3 -2
- package/package.json +1 -1
package/alipayWallet.mjs
CHANGED
|
@@ -861,7 +861,7 @@ export async function diagnoseAlipay402Resource(input, options = {}) {
|
|
|
861
861
|
message: '没有找到本地付款尝试;请不要因此重复付款。'
|
|
862
862
|
};
|
|
863
863
|
}
|
|
864
|
-
|
|
864
|
+
const result = {
|
|
865
865
|
ok: state.status !== 'failed' && state.status !== 'wallet_command_failed',
|
|
866
866
|
status: state.status || 'unknown',
|
|
867
867
|
provider: 'alipay-agent-payment',
|
|
@@ -877,4 +877,72 @@ export async function diagnoseAlipay402Resource(input, options = {}) {
|
|
|
877
877
|
} : {}),
|
|
878
878
|
updatedAt: state.updatedAt || null
|
|
879
879
|
};
|
|
880
|
+
// TRADE_PROGRESS_FAILED is deliberately generic in the official wallet
|
|
881
|
+
// output. Attach a redacted report to the one diagnose command an Agent is
|
|
882
|
+
// already required to run, rather than relying on it to remember a second
|
|
883
|
+
// optional command after a failed payment.
|
|
884
|
+
if (state.lastFailureCode === 'wallet_trade_progress_failed') {
|
|
885
|
+
const support = await createAlipay402SupportReport({ resourceUrl }, options);
|
|
886
|
+
if (support.ok && support.report) result.supportReport = support.report;
|
|
887
|
+
}
|
|
888
|
+
return result;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Creates a deliberately redacted support summary for an already-failed
|
|
893
|
+
* official-wallet attempt. This never invokes the wallet, re-fetches the
|
|
894
|
+
* resource, or reads/prints the Payment-Needed payload. It is intended for
|
|
895
|
+
* the official `alipay-bot problem-feedback` flow, where a generic wallet
|
|
896
|
+
* trade-creation error otherwise leaves an operator with no safe facts to
|
|
897
|
+
* report.
|
|
898
|
+
*/
|
|
899
|
+
export async function createAlipay402SupportReport(input, options = {}) {
|
|
900
|
+
const resourceUrl = normalizeResourceUrl(input?.resourceUrl);
|
|
901
|
+
const state = await readPaymentState(resourceUrl, options);
|
|
902
|
+
if (!state) {
|
|
903
|
+
return {
|
|
904
|
+
ok: false,
|
|
905
|
+
status: 'no_local_attempt',
|
|
906
|
+
provider: 'alipay-agent-payment',
|
|
907
|
+
walletInvoked: false,
|
|
908
|
+
message: '没有找到本地付款尝试,无法生成问题反馈材料。'
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
const failureCode = state.lastFailureCode || null;
|
|
913
|
+
const diagnosis = state.lastDiagnosis || null;
|
|
914
|
+
const failedBeforeConfirmation = !state.queryCredential?.value &&
|
|
915
|
+
['failed', 'wallet_command_failed'].includes(state.status);
|
|
916
|
+
const { stdout, stderr } = await runOfficialCli(['--version'], options);
|
|
917
|
+
const runtimeVersion = safeRuntimeVersion(stdout, stderr) || null;
|
|
918
|
+
const lines = [
|
|
919
|
+
'[环节]:402 支付 / 官方钱包创建交易',
|
|
920
|
+
`[结果]:${failedBeforeConfirmation ? '未创建可确认交易,未获得 Payment-Proof' : '请以本地诊断状态为准'}`,
|
|
921
|
+
`[桥接诊断]:${diagnosis?.code || failureCode || 'unknown'}`,
|
|
922
|
+
`[官方代码]:${diagnosis?.officialCode || '未返回'}`,
|
|
923
|
+
`[官方运行时]:${runtimeVersion || '未知'}`,
|
|
924
|
+
`[发生时间]:${state.updatedAt || state.createdAt || '未知'}`,
|
|
925
|
+
'[已确认]:卖方资源返回字段结构有效的 402 账单;本次未生成可查询交易凭证。',
|
|
926
|
+
'[请协助]:返回本次 TRADE_PROGRESS_FAILED 的子码、requestId/traceId,以及交易创建被拒绝的具体校验项。'
|
|
927
|
+
];
|
|
928
|
+
return {
|
|
929
|
+
ok: true,
|
|
930
|
+
status: 'support_report_ready',
|
|
931
|
+
provider: 'alipay-agent-payment',
|
|
932
|
+
walletInvoked: false,
|
|
933
|
+
report: {
|
|
934
|
+
category: 'ALIPAY_402_TRADE_CREATION_FAILED',
|
|
935
|
+
attemptId: `alipay-402:${state.resourceDigest.slice(0, 16)}`,
|
|
936
|
+
occurredAt: state.updatedAt || state.createdAt || null,
|
|
937
|
+
officialRuntimeVersion: runtimeVersion,
|
|
938
|
+
failureCode,
|
|
939
|
+
...(diagnosis?.officialCode ? { officialCode: diagnosis.officialCode } : {}),
|
|
940
|
+
...(diagnosis?.officialSubCode ? { officialSubCode: diagnosis.officialSubCode } : {}),
|
|
941
|
+
billShapeValidated: state.merchantResource?.billShapeValidated === true,
|
|
942
|
+
paymentNeededReceived: state.merchantResource?.paymentNeededReceived === true,
|
|
943
|
+
queryCredentialCreated: Boolean(state.queryCredential?.value),
|
|
944
|
+
text: lines.join('\n')
|
|
945
|
+
},
|
|
946
|
+
message: '已生成脱敏的问题反馈材料;其中不包含订单号、资源 URL、账单、Payment-Proof 或钱包凭证。'
|
|
947
|
+
};
|
|
880
948
|
}
|
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.26';
|
|
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';
|