moltspay 0.5.2 → 0.5.4
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/README.md +156 -0
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +547 -1
- package/dist/index.d.ts +547 -1
- package/dist/index.js +988 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +981 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -935,4 +935,550 @@ declare class CDPWallet {
|
|
|
935
935
|
getViemAccount(): Promise<unknown>;
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
-
|
|
938
|
+
/**
|
|
939
|
+
* Deferred Payment Types
|
|
940
|
+
*
|
|
941
|
+
* Supports credit-based, milestone, and subscription payment models
|
|
942
|
+
* for trusted Agent-to-Agent transactions.
|
|
943
|
+
*/
|
|
944
|
+
|
|
945
|
+
interface CreditAccount {
|
|
946
|
+
/** Unique account identifier */
|
|
947
|
+
accountId: string;
|
|
948
|
+
/** Buyer/debtor address or identifier */
|
|
949
|
+
buyerId: string;
|
|
950
|
+
/** Seller/creditor address */
|
|
951
|
+
sellerId: string;
|
|
952
|
+
/** Credit limit in USDC */
|
|
953
|
+
creditLimit: number;
|
|
954
|
+
/** Current balance owed (positive = buyer owes seller) */
|
|
955
|
+
balance: number;
|
|
956
|
+
/** Account status */
|
|
957
|
+
status: CreditAccountStatus;
|
|
958
|
+
/** Settlement chain */
|
|
959
|
+
chain: ChainName;
|
|
960
|
+
/** Payment terms */
|
|
961
|
+
terms: PaymentTerms;
|
|
962
|
+
/** Account creation time */
|
|
963
|
+
createdAt: string;
|
|
964
|
+
/** Last activity time */
|
|
965
|
+
updatedAt: string;
|
|
966
|
+
/** Transaction history */
|
|
967
|
+
transactions: CreditTransaction[];
|
|
968
|
+
/** Optional metadata */
|
|
969
|
+
metadata?: Record<string, unknown>;
|
|
970
|
+
}
|
|
971
|
+
type CreditAccountStatus = 'active' | 'suspended' | 'closed' | 'pending';
|
|
972
|
+
interface PaymentTerms {
|
|
973
|
+
/** Net days for payment (e.g., 30 = Net-30) */
|
|
974
|
+
netDays: number;
|
|
975
|
+
/** Grace period after due date before suspension */
|
|
976
|
+
graceDays: number;
|
|
977
|
+
/** Settlement frequency: on-demand, daily, weekly, monthly */
|
|
978
|
+
settlementFrequency: SettlementFrequency;
|
|
979
|
+
/** Minimum balance to trigger auto-settlement */
|
|
980
|
+
autoSettleThreshold?: number;
|
|
981
|
+
/** Late fee percentage (optional) */
|
|
982
|
+
lateFeePercent?: number;
|
|
983
|
+
}
|
|
984
|
+
type SettlementFrequency = 'on-demand' | 'daily' | 'weekly' | 'monthly';
|
|
985
|
+
interface CreditTransaction {
|
|
986
|
+
/** Transaction ID */
|
|
987
|
+
txId: string;
|
|
988
|
+
/** Transaction type */
|
|
989
|
+
type: CreditTransactionType;
|
|
990
|
+
/** Amount (positive for charges, negative for payments/credits) */
|
|
991
|
+
amount: number;
|
|
992
|
+
/** Running balance after this transaction */
|
|
993
|
+
balanceAfter: number;
|
|
994
|
+
/** Reference (order ID, service name, etc.) */
|
|
995
|
+
reference: string;
|
|
996
|
+
/** Optional on-chain tx hash for settlements */
|
|
997
|
+
onChainTxHash?: string;
|
|
998
|
+
/** Transaction time */
|
|
999
|
+
timestamp: string;
|
|
1000
|
+
/** Notes */
|
|
1001
|
+
notes?: string;
|
|
1002
|
+
}
|
|
1003
|
+
type CreditTransactionType = 'charge' | 'payment' | 'credit' | 'adjustment' | 'late_fee' | 'refund';
|
|
1004
|
+
interface DeferredPayment {
|
|
1005
|
+
/** Payment ID */
|
|
1006
|
+
paymentId: string;
|
|
1007
|
+
/** Associated credit account (if using credit) */
|
|
1008
|
+
accountId?: string;
|
|
1009
|
+
/** Order/service ID */
|
|
1010
|
+
orderId: string;
|
|
1011
|
+
/** Service description */
|
|
1012
|
+
service: string;
|
|
1013
|
+
/** Total amount */
|
|
1014
|
+
amount: number;
|
|
1015
|
+
/** Amount paid so far */
|
|
1016
|
+
paidAmount: number;
|
|
1017
|
+
/** Payment status */
|
|
1018
|
+
status: DeferredPaymentStatus;
|
|
1019
|
+
/** Due date (ISO string) */
|
|
1020
|
+
dueDate: string;
|
|
1021
|
+
/** Settlement chain */
|
|
1022
|
+
chain: ChainName;
|
|
1023
|
+
/** Buyer identifier */
|
|
1024
|
+
buyerId: string;
|
|
1025
|
+
/** Seller address */
|
|
1026
|
+
sellerAddress: string;
|
|
1027
|
+
/** Payment plan (for installments) */
|
|
1028
|
+
plan?: PaymentPlan;
|
|
1029
|
+
/** Creation time */
|
|
1030
|
+
createdAt: string;
|
|
1031
|
+
/** Last update time */
|
|
1032
|
+
updatedAt: string;
|
|
1033
|
+
/** Settlement transactions */
|
|
1034
|
+
settlements: Settlement[];
|
|
1035
|
+
/** Optional metadata */
|
|
1036
|
+
metadata?: Record<string, unknown>;
|
|
1037
|
+
}
|
|
1038
|
+
type DeferredPaymentStatus = 'pending' | 'partial' | 'paid' | 'overdue' | 'settled' | 'cancelled' | 'disputed';
|
|
1039
|
+
interface PaymentPlan {
|
|
1040
|
+
/** Plan type */
|
|
1041
|
+
type: 'fixed' | 'milestone' | 'subscription';
|
|
1042
|
+
/** Total installments */
|
|
1043
|
+
totalInstallments: number;
|
|
1044
|
+
/** Completed installments */
|
|
1045
|
+
completedInstallments: number;
|
|
1046
|
+
/** Installment schedule */
|
|
1047
|
+
schedule: Installment[];
|
|
1048
|
+
}
|
|
1049
|
+
interface Installment {
|
|
1050
|
+
/** Installment number (1-based) */
|
|
1051
|
+
number: number;
|
|
1052
|
+
/** Amount for this installment */
|
|
1053
|
+
amount: number;
|
|
1054
|
+
/** Due date */
|
|
1055
|
+
dueDate: string;
|
|
1056
|
+
/** Status */
|
|
1057
|
+
status: 'pending' | 'paid' | 'overdue';
|
|
1058
|
+
/** Settlement tx hash (if paid) */
|
|
1059
|
+
txHash?: string;
|
|
1060
|
+
/** Milestone description (for milestone-based) */
|
|
1061
|
+
milestone?: string;
|
|
1062
|
+
}
|
|
1063
|
+
interface Settlement {
|
|
1064
|
+
/** Settlement ID */
|
|
1065
|
+
settlementId: string;
|
|
1066
|
+
/** Amount settled */
|
|
1067
|
+
amount: number;
|
|
1068
|
+
/** On-chain transaction hash */
|
|
1069
|
+
txHash: string;
|
|
1070
|
+
/** Chain */
|
|
1071
|
+
chain: ChainName;
|
|
1072
|
+
/** Settlement time */
|
|
1073
|
+
timestamp: string;
|
|
1074
|
+
/** Verification status */
|
|
1075
|
+
verified: boolean;
|
|
1076
|
+
}
|
|
1077
|
+
interface CreateCreditAccountParams {
|
|
1078
|
+
buyerId: string;
|
|
1079
|
+
sellerId: string;
|
|
1080
|
+
creditLimit: number;
|
|
1081
|
+
chain?: ChainName;
|
|
1082
|
+
terms?: Partial<PaymentTerms>;
|
|
1083
|
+
metadata?: Record<string, unknown>;
|
|
1084
|
+
}
|
|
1085
|
+
interface CreateDeferredPaymentParams {
|
|
1086
|
+
accountId?: string;
|
|
1087
|
+
orderId: string;
|
|
1088
|
+
service: string;
|
|
1089
|
+
amount: number;
|
|
1090
|
+
buyerId: string;
|
|
1091
|
+
sellerAddress: string;
|
|
1092
|
+
chain?: ChainName;
|
|
1093
|
+
dueInDays?: number;
|
|
1094
|
+
plan?: Omit<PaymentPlan, 'completedInstallments'>;
|
|
1095
|
+
metadata?: Record<string, unknown>;
|
|
1096
|
+
}
|
|
1097
|
+
interface RecordSettlementParams {
|
|
1098
|
+
paymentId: string;
|
|
1099
|
+
amount: number;
|
|
1100
|
+
txHash: string;
|
|
1101
|
+
chain?: ChainName;
|
|
1102
|
+
}
|
|
1103
|
+
interface DeferredPaymentStore {
|
|
1104
|
+
createAccount(params: CreateCreditAccountParams): Promise<CreditAccount>;
|
|
1105
|
+
getAccount(accountId: string): Promise<CreditAccount | null>;
|
|
1106
|
+
getAccountByBuyer(buyerId: string, sellerId: string): Promise<CreditAccount | null>;
|
|
1107
|
+
updateAccount(accountId: string, updates: Partial<CreditAccount>): Promise<CreditAccount>;
|
|
1108
|
+
listAccounts(sellerId: string): Promise<CreditAccount[]>;
|
|
1109
|
+
createPayment(params: CreateDeferredPaymentParams): Promise<DeferredPayment>;
|
|
1110
|
+
getPayment(paymentId: string): Promise<DeferredPayment | null>;
|
|
1111
|
+
updatePayment(paymentId: string, updates: Partial<DeferredPayment>): Promise<DeferredPayment>;
|
|
1112
|
+
listPayments(filter: PaymentFilter): Promise<DeferredPayment[]>;
|
|
1113
|
+
addTransaction(accountId: string, tx: Omit<CreditTransaction, 'txId' | 'timestamp'>): Promise<CreditTransaction>;
|
|
1114
|
+
}
|
|
1115
|
+
interface PaymentFilter {
|
|
1116
|
+
accountId?: string;
|
|
1117
|
+
buyerId?: string;
|
|
1118
|
+
sellerId?: string;
|
|
1119
|
+
status?: DeferredPaymentStatus | DeferredPaymentStatus[];
|
|
1120
|
+
overdueOnly?: boolean;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Deferred Payment Manager
|
|
1125
|
+
*
|
|
1126
|
+
* Manages credit accounts and deferred payments for Agent-to-Agent transactions.
|
|
1127
|
+
* Supports credit-based, milestone, and installment payment models.
|
|
1128
|
+
*/
|
|
1129
|
+
|
|
1130
|
+
interface DeferredPaymentManagerConfig {
|
|
1131
|
+
/** Seller's wallet address for receiving payments */
|
|
1132
|
+
sellerAddress: string;
|
|
1133
|
+
/** Seller's identifier */
|
|
1134
|
+
sellerId: string;
|
|
1135
|
+
/** Default chain for payments */
|
|
1136
|
+
chain?: ChainName;
|
|
1137
|
+
/** Custom store implementation (defaults to MemoryDeferredStore) */
|
|
1138
|
+
store?: DeferredPaymentStore;
|
|
1139
|
+
/** Auto-verify settlements on-chain */
|
|
1140
|
+
autoVerify?: boolean;
|
|
1141
|
+
}
|
|
1142
|
+
interface ChargeResult {
|
|
1143
|
+
success: boolean;
|
|
1144
|
+
payment?: DeferredPayment;
|
|
1145
|
+
transaction?: CreditTransaction;
|
|
1146
|
+
error?: string;
|
|
1147
|
+
/** True if credit limit would be exceeded */
|
|
1148
|
+
creditExceeded?: boolean;
|
|
1149
|
+
}
|
|
1150
|
+
interface SettlementResult {
|
|
1151
|
+
success: boolean;
|
|
1152
|
+
settlement?: Settlement;
|
|
1153
|
+
payment?: DeferredPayment;
|
|
1154
|
+
transaction?: CreditTransaction;
|
|
1155
|
+
error?: string;
|
|
1156
|
+
}
|
|
1157
|
+
interface AccountSummary {
|
|
1158
|
+
account: CreditAccount;
|
|
1159
|
+
pendingPayments: DeferredPayment[];
|
|
1160
|
+
overduePayments: DeferredPayment[];
|
|
1161
|
+
availableCredit: number;
|
|
1162
|
+
totalOwed: number;
|
|
1163
|
+
}
|
|
1164
|
+
declare class DeferredPaymentManager {
|
|
1165
|
+
private config;
|
|
1166
|
+
constructor(config: DeferredPaymentManagerConfig);
|
|
1167
|
+
/**
|
|
1168
|
+
* Create a new credit account for a buyer
|
|
1169
|
+
*/
|
|
1170
|
+
createCreditAccount(params: {
|
|
1171
|
+
buyerId: string;
|
|
1172
|
+
creditLimit: number;
|
|
1173
|
+
netDays?: number;
|
|
1174
|
+
metadata?: Record<string, unknown>;
|
|
1175
|
+
}): Promise<CreditAccount>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Get or create a credit account for a buyer
|
|
1178
|
+
*/
|
|
1179
|
+
getOrCreateAccount(params: {
|
|
1180
|
+
buyerId: string;
|
|
1181
|
+
creditLimit?: number;
|
|
1182
|
+
}): Promise<CreditAccount>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Get credit account by ID
|
|
1185
|
+
*/
|
|
1186
|
+
getAccount(accountId: string): Promise<CreditAccount | null>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Get credit account by buyer ID
|
|
1189
|
+
*/
|
|
1190
|
+
getAccountByBuyer(buyerId: string): Promise<CreditAccount | null>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Update credit limit
|
|
1193
|
+
*/
|
|
1194
|
+
updateCreditLimit(accountId: string, newLimit: number): Promise<CreditAccount>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Suspend an account
|
|
1197
|
+
*/
|
|
1198
|
+
suspendAccount(accountId: string, reason?: string): Promise<CreditAccount>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Reactivate a suspended account
|
|
1201
|
+
*/
|
|
1202
|
+
reactivateAccount(accountId: string): Promise<CreditAccount>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Get account summary with pending/overdue payments
|
|
1205
|
+
*/
|
|
1206
|
+
getAccountSummary(accountId: string): Promise<AccountSummary | null>;
|
|
1207
|
+
/**
|
|
1208
|
+
* List all credit accounts for this seller
|
|
1209
|
+
*/
|
|
1210
|
+
listAccounts(): Promise<CreditAccount[]>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Charge a service to a credit account (deferred payment)
|
|
1213
|
+
*/
|
|
1214
|
+
charge(params: {
|
|
1215
|
+
buyerId: string;
|
|
1216
|
+
orderId: string;
|
|
1217
|
+
service: string;
|
|
1218
|
+
amount: number;
|
|
1219
|
+
dueInDays?: number;
|
|
1220
|
+
metadata?: Record<string, unknown>;
|
|
1221
|
+
}): Promise<ChargeResult>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Create a deferred payment without a credit account (standalone)
|
|
1224
|
+
*/
|
|
1225
|
+
createDeferredPayment(params: CreateDeferredPaymentParams): Promise<DeferredPayment>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Get deferred payment by ID
|
|
1228
|
+
*/
|
|
1229
|
+
getPayment(paymentId: string): Promise<DeferredPayment | null>;
|
|
1230
|
+
/**
|
|
1231
|
+
* List deferred payments with filters
|
|
1232
|
+
*/
|
|
1233
|
+
listPayments(filter?: PaymentFilter): Promise<DeferredPayment[]>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Get overdue payments
|
|
1236
|
+
*/
|
|
1237
|
+
getOverduePayments(): Promise<DeferredPayment[]>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Record a settlement (payment received)
|
|
1240
|
+
*/
|
|
1241
|
+
recordSettlement(params: RecordSettlementParams): Promise<SettlementResult>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Settle all pending charges for an account
|
|
1244
|
+
*/
|
|
1245
|
+
settleAccount(accountId: string, txHash: string): Promise<SettlementResult>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Issue a credit (reduce balance owed)
|
|
1248
|
+
*/
|
|
1249
|
+
issueCredit(params: {
|
|
1250
|
+
accountId: string;
|
|
1251
|
+
amount: number;
|
|
1252
|
+
reason: string;
|
|
1253
|
+
}): Promise<CreditTransaction>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Issue a refund
|
|
1256
|
+
*/
|
|
1257
|
+
issueRefund(params: {
|
|
1258
|
+
paymentId: string;
|
|
1259
|
+
amount: number;
|
|
1260
|
+
reason: string;
|
|
1261
|
+
}): Promise<SettlementResult>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Mark overdue payments
|
|
1264
|
+
*/
|
|
1265
|
+
markOverduePayments(): Promise<DeferredPayment[]>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Apply late fees to overdue accounts
|
|
1268
|
+
*/
|
|
1269
|
+
applyLateFees(): Promise<CreditTransaction[]>;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* In-Memory Store for Deferred Payments
|
|
1274
|
+
*
|
|
1275
|
+
* Suitable for testing and single-process deployments.
|
|
1276
|
+
* For production, implement DeferredPaymentStore with persistent storage.
|
|
1277
|
+
*/
|
|
1278
|
+
|
|
1279
|
+
declare class MemoryDeferredStore implements DeferredPaymentStore {
|
|
1280
|
+
private accounts;
|
|
1281
|
+
private payments;
|
|
1282
|
+
private buyerSellerIndex;
|
|
1283
|
+
private makeKey;
|
|
1284
|
+
createAccount(params: CreateCreditAccountParams): Promise<CreditAccount>;
|
|
1285
|
+
getAccount(accountId: string): Promise<CreditAccount | null>;
|
|
1286
|
+
getAccountByBuyer(buyerId: string, sellerId: string): Promise<CreditAccount | null>;
|
|
1287
|
+
updateAccount(accountId: string, updates: Partial<CreditAccount>): Promise<CreditAccount>;
|
|
1288
|
+
listAccounts(sellerId: string): Promise<CreditAccount[]>;
|
|
1289
|
+
createPayment(params: CreateDeferredPaymentParams): Promise<DeferredPayment>;
|
|
1290
|
+
getPayment(paymentId: string): Promise<DeferredPayment | null>;
|
|
1291
|
+
updatePayment(paymentId: string, updates: Partial<DeferredPayment>): Promise<DeferredPayment>;
|
|
1292
|
+
listPayments(filter: PaymentFilter): Promise<DeferredPayment[]>;
|
|
1293
|
+
addTransaction(accountId: string, tx: Omit<CreditTransaction, 'txId' | 'timestamp'>): Promise<CreditTransaction>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Get all data (for debugging/export)
|
|
1296
|
+
*/
|
|
1297
|
+
export(): {
|
|
1298
|
+
accounts: CreditAccount[];
|
|
1299
|
+
payments: DeferredPayment[];
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* Import data (for restore)
|
|
1303
|
+
*/
|
|
1304
|
+
import(data: {
|
|
1305
|
+
accounts: CreditAccount[];
|
|
1306
|
+
payments: DeferredPayment[];
|
|
1307
|
+
}): void;
|
|
1308
|
+
/**
|
|
1309
|
+
* Clear all data
|
|
1310
|
+
*/
|
|
1311
|
+
clear(): void;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* JSON File-based Store for Deferred Payments
|
|
1316
|
+
*
|
|
1317
|
+
* Persists deferred payment data to a JSON file.
|
|
1318
|
+
* Suitable for single-process production deployments.
|
|
1319
|
+
*
|
|
1320
|
+
* For multi-process or distributed systems, implement DeferredPaymentStore
|
|
1321
|
+
* with a proper database (PostgreSQL, Redis, etc.).
|
|
1322
|
+
*/
|
|
1323
|
+
|
|
1324
|
+
interface JsonDeferredStoreConfig {
|
|
1325
|
+
/** Path to the JSON file */
|
|
1326
|
+
filePath: string;
|
|
1327
|
+
/** Auto-save after each write operation (default: true) */
|
|
1328
|
+
autoSave?: boolean;
|
|
1329
|
+
/** Pretty print JSON (default: true) */
|
|
1330
|
+
prettyPrint?: boolean;
|
|
1331
|
+
}
|
|
1332
|
+
declare class JsonDeferredStore implements DeferredPaymentStore {
|
|
1333
|
+
private memory;
|
|
1334
|
+
private config;
|
|
1335
|
+
private dirty;
|
|
1336
|
+
constructor(config: JsonDeferredStoreConfig);
|
|
1337
|
+
/**
|
|
1338
|
+
* Load data from file
|
|
1339
|
+
*/
|
|
1340
|
+
load(): void;
|
|
1341
|
+
/**
|
|
1342
|
+
* Save data to file
|
|
1343
|
+
*/
|
|
1344
|
+
save(): void;
|
|
1345
|
+
/**
|
|
1346
|
+
* Mark as dirty and optionally auto-save
|
|
1347
|
+
*/
|
|
1348
|
+
private markDirty;
|
|
1349
|
+
/**
|
|
1350
|
+
* Check if there are unsaved changes
|
|
1351
|
+
*/
|
|
1352
|
+
isDirty(): boolean;
|
|
1353
|
+
createAccount(params: CreateCreditAccountParams): Promise<CreditAccount>;
|
|
1354
|
+
getAccount(accountId: string): Promise<CreditAccount | null>;
|
|
1355
|
+
getAccountByBuyer(buyerId: string, sellerId: string): Promise<CreditAccount | null>;
|
|
1356
|
+
updateAccount(accountId: string, updates: Partial<CreditAccount>): Promise<CreditAccount>;
|
|
1357
|
+
listAccounts(sellerId: string): Promise<CreditAccount[]>;
|
|
1358
|
+
createPayment(params: CreateDeferredPaymentParams): Promise<DeferredPayment>;
|
|
1359
|
+
getPayment(paymentId: string): Promise<DeferredPayment | null>;
|
|
1360
|
+
updatePayment(paymentId: string, updates: Partial<DeferredPayment>): Promise<DeferredPayment>;
|
|
1361
|
+
listPayments(filter: PaymentFilter): Promise<DeferredPayment[]>;
|
|
1362
|
+
addTransaction(accountId: string, tx: Omit<CreditTransaction, 'txId' | 'timestamp'>): Promise<CreditTransaction>;
|
|
1363
|
+
/**
|
|
1364
|
+
* Export all data
|
|
1365
|
+
*/
|
|
1366
|
+
export(): {
|
|
1367
|
+
accounts: CreditAccount[];
|
|
1368
|
+
payments: DeferredPayment[];
|
|
1369
|
+
};
|
|
1370
|
+
/**
|
|
1371
|
+
* Clear all data (including file)
|
|
1372
|
+
*/
|
|
1373
|
+
clear(): void;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Deferred Payment Conversation Templates
|
|
1378
|
+
*
|
|
1379
|
+
* Natural language templates for Agent-to-Agent deferred payment flows.
|
|
1380
|
+
*/
|
|
1381
|
+
|
|
1382
|
+
declare const DeferredStatusMarkers: {
|
|
1383
|
+
creditAccountCreated: (accountId: string, limit: number) => string;
|
|
1384
|
+
chargeAdded: (paymentId: string, amount: number) => string;
|
|
1385
|
+
settlementReceived: (paymentId: string, txHash: string, amount: number) => string;
|
|
1386
|
+
accountSettled: (accountId: string, txHash: string, amount: number) => string;
|
|
1387
|
+
creditIssued: (accountId: string, amount: number) => string;
|
|
1388
|
+
accountSuspended: (accountId: string, reason: string) => string;
|
|
1389
|
+
paymentOverdue: (paymentId: string, amount: number) => string;
|
|
1390
|
+
};
|
|
1391
|
+
declare const DeferredSellerTemplates: {
|
|
1392
|
+
/**
|
|
1393
|
+
* Offer deferred payment option
|
|
1394
|
+
*/
|
|
1395
|
+
offerDeferredPayment: (params: {
|
|
1396
|
+
service: string;
|
|
1397
|
+
price: number;
|
|
1398
|
+
netDays?: number;
|
|
1399
|
+
}) => string;
|
|
1400
|
+
/**
|
|
1401
|
+
* Explain credit account setup
|
|
1402
|
+
*/
|
|
1403
|
+
explainCreditAccount: () => string;
|
|
1404
|
+
/**
|
|
1405
|
+
* Confirm credit account creation
|
|
1406
|
+
*/
|
|
1407
|
+
creditAccountCreated: (account: CreditAccount) => string;
|
|
1408
|
+
/**
|
|
1409
|
+
* Charge confirmation
|
|
1410
|
+
*/
|
|
1411
|
+
chargeConfirmation: (payment: DeferredPayment, availableCredit: number) => string;
|
|
1412
|
+
/**
|
|
1413
|
+
* Credit limit exceeded
|
|
1414
|
+
*/
|
|
1415
|
+
creditLimitExceeded: (params: {
|
|
1416
|
+
requested: number;
|
|
1417
|
+
available: number;
|
|
1418
|
+
balance: number;
|
|
1419
|
+
limit: number;
|
|
1420
|
+
}) => string;
|
|
1421
|
+
/**
|
|
1422
|
+
* Account summary/statement
|
|
1423
|
+
*/
|
|
1424
|
+
accountStatement: (summary: AccountSummary) => string;
|
|
1425
|
+
/**
|
|
1426
|
+
* Settlement confirmation
|
|
1427
|
+
*/
|
|
1428
|
+
settlementConfirmation: (params: {
|
|
1429
|
+
amount: number;
|
|
1430
|
+
txHash: string;
|
|
1431
|
+
newBalance: number;
|
|
1432
|
+
paymentId?: string;
|
|
1433
|
+
}) => string;
|
|
1434
|
+
/**
|
|
1435
|
+
* Overdue notice
|
|
1436
|
+
*/
|
|
1437
|
+
overdueNotice: (payments: DeferredPayment[]) => string;
|
|
1438
|
+
/**
|
|
1439
|
+
* Credit issued confirmation
|
|
1440
|
+
*/
|
|
1441
|
+
creditIssued: (params: {
|
|
1442
|
+
amount: number;
|
|
1443
|
+
reason: string;
|
|
1444
|
+
newBalance: number;
|
|
1445
|
+
accountId: string;
|
|
1446
|
+
}) => string;
|
|
1447
|
+
};
|
|
1448
|
+
declare const DeferredBuyerTemplates: {
|
|
1449
|
+
/**
|
|
1450
|
+
* Request deferred payment
|
|
1451
|
+
*/
|
|
1452
|
+
requestDeferredPayment: (service: string) => string;
|
|
1453
|
+
/**
|
|
1454
|
+
* Accept credit account offer
|
|
1455
|
+
*/
|
|
1456
|
+
acceptCreditAccount: () => string;
|
|
1457
|
+
/**
|
|
1458
|
+
* Request credit limit increase
|
|
1459
|
+
*/
|
|
1460
|
+
requestCreditIncrease: (currentLimit: number, requestedLimit: number) => string;
|
|
1461
|
+
/**
|
|
1462
|
+
* Request account statement
|
|
1463
|
+
*/
|
|
1464
|
+
requestStatement: () => string;
|
|
1465
|
+
/**
|
|
1466
|
+
* Announce settlement payment
|
|
1467
|
+
*/
|
|
1468
|
+
announceSettlement: (params: {
|
|
1469
|
+
amount: number;
|
|
1470
|
+
txHash: string;
|
|
1471
|
+
accountId?: string;
|
|
1472
|
+
}) => string;
|
|
1473
|
+
/**
|
|
1474
|
+
* Dispute a charge
|
|
1475
|
+
*/
|
|
1476
|
+
disputeCharge: (paymentId: string, reason: string) => string;
|
|
1477
|
+
};
|
|
1478
|
+
interface ParsedDeferredStatus {
|
|
1479
|
+
type: string;
|
|
1480
|
+
data: Record<string, string>;
|
|
1481
|
+
}
|
|
1482
|
+
declare function parseDeferredStatusMarker(text: string): ParsedDeferredStatus | null;
|
|
1483
|
+
|
|
1484
|
+
export { type AccountSummary, AgentWallet, AuditAction, AuditEntry, AuditLog, BuyerTemplates, type CDPInitResult, CDPWallet, type CDPWalletConfig, type CDPWalletData, ChainConfig, ChainName, type ChargeResult, type CreateCreditAccountParams, type CreateDeferredPaymentParams, CreateInvoiceParams, type CreditAccount, type CreditAccountStatus, type CreditTransaction, type CreditTransactionType, DeferredBuyerTemplates, type DeferredPayment, DeferredPaymentManager, type DeferredPaymentManagerConfig, type DeferredPaymentStatus, type DeferredPaymentStore, DeferredSellerTemplates, DeferredStatusMarkers, type EIP3009Authorization, type Installment, Invoice, JsonDeferredStore, type JsonDeferredStoreConfig, MemoryDeferredStore, PAYMENT_HEADER, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, type ParsedDeferredStatus, PaymentAgent, PaymentAgentConfig, type PaymentFilter, type PaymentPlan, type PaymentTerms, type Receipt, type ReceiptParams, type RecordSettlementParams, SellerTemplates, type Settlement, type SettlementFrequency, type SettlementResult, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, type X402Client, type X402ClientConfig, type X402PaymentPayload, type X402PaymentRequirements, X402_VERSION, chainToNetwork, createExactEvmPayload, createPaymentRequiredResponse, createX402Client, encodePaymentPayload, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, getAgentAddress, getCDPWalletAddress, getChain, initCDPWallet, isCDPAvailable, isX402Available, loadCDPWallet, networkToChain, parseDeferredStatusMarker, parsePaymentRequired, parseStatusMarker, signEIP3009, verifyPaymentHeader, wrapFetchWith402, x402Fetch };
|