@directcryptopay/sdk 0.2.4 → 0.3.0

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.
Files changed (127) hide show
  1. package/README.md +51 -87
  2. package/dist/core/config.d.ts +9 -46
  3. package/dist/core/iframe.d.ts +16 -0
  4. package/dist/dcp-sdk.umd.js +1 -12811
  5. package/dist/dcp.d.ts +12 -5
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +219 -2
  8. package/dist/types.d.ts +26 -164
  9. package/package.json +3 -13
  10. package/dist/ExchangeController-CbO41bcH.js +0 -217
  11. package/dist/HelpersUtil-DHm6EVSE.js +0 -120
  12. package/dist/NavigationUtil-kj9LEOOd.js +0 -8
  13. package/dist/PhArrowCircleDown-lsK25DCk.js +0 -73
  14. package/dist/PhArrowClockwise-NeKHZ1co.js +0 -73
  15. package/dist/PhArrowDown-C9AkNvLs.js +0 -73
  16. package/dist/PhArrowLeft-RNfIQP1X.js +0 -73
  17. package/dist/PhArrowRight-DM1tna0G.js +0 -73
  18. package/dist/PhArrowSquareOut-S5XYbAZj.js +0 -73
  19. package/dist/PhArrowUp-DmktzOWy.js +0 -73
  20. package/dist/PhArrowUpRight-BkNeW_5i.js +0 -73
  21. package/dist/PhArrowsClockwise-CQ4pG76b.js +0 -73
  22. package/dist/PhArrowsDownUp-H6gxaNM6.js +0 -73
  23. package/dist/PhArrowsLeftRight-DZSsfMR6.js +0 -73
  24. package/dist/PhBank-4_9QzqIB.js +0 -73
  25. package/dist/PhBrowser-B-JSznId.js +0 -73
  26. package/dist/PhCaretDown-vV5oHMNi.js +0 -73
  27. package/dist/PhCaretLeft-BLo6Y_f4.js +0 -73
  28. package/dist/PhCaretRight-CqQN4TT3.js +0 -73
  29. package/dist/PhCaretUp-Df7UCAHy.js +0 -73
  30. package/dist/PhCheck-gtpfK4ed.js +0 -73
  31. package/dist/PhCircleHalf-Uq7dwDYw.js +0 -73
  32. package/dist/PhClock-SDCW-NmF.js +0 -73
  33. package/dist/PhCompass-B7hgtdx-.js +0 -73
  34. package/dist/PhCopy-BcnhyXCy.js +0 -73
  35. package/dist/PhCreditCard-BJjByVgu.js +0 -73
  36. package/dist/PhCurrencyDollar-B7ZXqXBy.js +0 -73
  37. package/dist/PhDesktop-B3VKPuJx.js +0 -73
  38. package/dist/PhDeviceMobile-Bnd0TYEH.js +0 -73
  39. package/dist/PhDotsThree-yyMWyZ-R.js +0 -73
  40. package/dist/PhEnvelope-67uzHbI9.js +0 -73
  41. package/dist/PhFunnelSimple-B-DCsloI.js +0 -73
  42. package/dist/PhGlobe-TMm_6qGk.js +0 -73
  43. package/dist/PhIdentificationCard-CePPD2xc.js +0 -73
  44. package/dist/PhImage-gY96WtHR.js +0 -73
  45. package/dist/PhInfo-DRQM_ZDP.js +0 -73
  46. package/dist/PhLightbulb-B0TxPfZ1.js +0 -73
  47. package/dist/PhMagnifyingGlass-B8si5_6W.js +0 -73
  48. package/dist/PhPaperPlaneRight-DVu5PLYd.js +0 -73
  49. package/dist/PhPlus-BfTsQnUz.js +0 -73
  50. package/dist/PhPower-CxYUGOWn.js +0 -73
  51. package/dist/PhPuzzlePiece-CQ4wh0gV.js +0 -73
  52. package/dist/PhQrCode-BuJ97NYJ.js +0 -73
  53. package/dist/PhQuestion-kJoP8Mja.js +0 -73
  54. package/dist/PhQuestionMark-C46ZkFpu.js +0 -73
  55. package/dist/PhSealCheck-Eh8jVqSN.js +0 -73
  56. package/dist/PhSignOut-jk97OSVt.js +0 -73
  57. package/dist/PhSpinner-CiYOhwMg.js +0 -73
  58. package/dist/PhTrash-pxerMqzd.js +0 -73
  59. package/dist/PhUser-BMg0VV4A.js +0 -73
  60. package/dist/PhVault-DYQvx5A-.js +0 -73
  61. package/dist/PhWarning-NLC5Mj87.js +0 -73
  62. package/dist/PhWarningCircle-Ch2jU9fA.js +0 -73
  63. package/dist/PhX-Bx4wpwm3.js +0 -73
  64. package/dist/SwapController-Ch0FFTEt.js +0 -457
  65. package/dist/ccip-BrGhNXIM.js +0 -150
  66. package/dist/core/api.d.ts +0 -39
  67. package/dist/core/logic.d.ts +0 -2
  68. package/dist/core/wallet.d.ts +0 -55
  69. package/dist/data-capture-CpafmuCb.js +0 -490
  70. package/dist/email-Dcg4jlai.js +0 -344
  71. package/dist/embedded-wallet-DeoRdAPw.js +0 -820
  72. package/dist/features-B9Nde43h.js +0 -274
  73. package/dist/hashTypedData-a7b8tdkO.js +0 -197
  74. package/dist/if-defined-k21LutCn.js +0 -10
  75. package/dist/index-9vLw53Xl.js +0 -228
  76. package/dist/index-B5wUyynz.js +0 -107
  77. package/dist/index-B8LkUrww.js +0 -86
  78. package/dist/index-BA0VwKg0.js +0 -8189
  79. package/dist/index-BB9JJ24N.js +0 -125
  80. package/dist/index-BCkEvPQ6.js +0 -172
  81. package/dist/index-BDeO_csr.js +0 -171
  82. package/dist/index-Bb7babLF.js +0 -1281
  83. package/dist/index-BjOhprVS.js +0 -199
  84. package/dist/index-BjyMgZsf.js +0 -218
  85. package/dist/index-BkThIDLX.js +0 -159
  86. package/dist/index-BmFs6nb7.js +0 -209
  87. package/dist/index-C1QEJL-2.js +0 -572
  88. package/dist/index-C4qc4PdD.js +0 -387
  89. package/dist/index-CAPvUh14.js +0 -1750
  90. package/dist/index-CBMU3PTE.js +0 -65
  91. package/dist/index-CGwPkJLF.js +0 -355
  92. package/dist/index-CNGEqX3D.js +0 -153
  93. package/dist/index-CRlCq6IB.js +0 -7981
  94. package/dist/index-Cg_o-i9X.js +0 -118
  95. package/dist/index-D1BvhCbI.js +0 -62
  96. package/dist/index-DFi8TiHc.js +0 -128
  97. package/dist/index-DLwuveL9.js +0 -555
  98. package/dist/index-DMn7ktUQ.js +0 -56
  99. package/dist/index-DOXwtuwa.js +0 -117
  100. package/dist/index-DPPOW_Tp.js +0 -118
  101. package/dist/index-DQpzHpW-.js +0 -517
  102. package/dist/index-DXHg5C-W.js +0 -276
  103. package/dist/index-DcYjZV4H.js +0 -110
  104. package/dist/index-DeL88Lwc.js +0 -41655
  105. package/dist/index-DrWVlf8b.js +0 -46
  106. package/dist/index-Dsfuc4rB.js +0 -123
  107. package/dist/index-DuTny38n.js +0 -1175
  108. package/dist/index-Nfjb6bV0.js +0 -21991
  109. package/dist/index-WwwdQSN2.js +0 -85
  110. package/dist/index-Yha9Afch.js +0 -174
  111. package/dist/index-cbQHN7GC.js +0 -100
  112. package/dist/index-hyG3cYsv.js +0 -1083
  113. package/dist/index-qLxmmPaL.js +0 -257
  114. package/dist/localBatchGatewayRequest-vfcvRH0G.js +0 -91
  115. package/dist/onramp-BSiyOX4L.js +0 -855
  116. package/dist/parseSignature-CdCMAPZN.js +0 -3304
  117. package/dist/pay-with-exchange-CduNoMEz.js +0 -525
  118. package/dist/property-Bd8U3_QP.js +0 -618
  119. package/dist/receive-CrmptJlq.js +0 -232
  120. package/dist/ref-SOwYtCZb.js +0 -107
  121. package/dist/send-oMcHMEr6.js +0 -1166
  122. package/dist/socials-C0A4-FbY.js +0 -620
  123. package/dist/swaps-CbJJ9Ciu.js +0 -1760
  124. package/dist/transactions-BDfCoBS5.js +0 -37
  125. package/dist/ui/Modal.d.ts +0 -9
  126. package/dist/ui/index.d.ts +0 -6
  127. package/dist/w3m-modal-BjsTkny7.js +0 -1706
package/dist/dcp.d.ts CHANGED
@@ -2,19 +2,26 @@ import { type DCPInitConfig } from './core/config';
2
2
  import type { DCPPayOptions, DCPPaymentOptions } from './types';
3
3
  export declare class DCP {
4
4
  private static instance;
5
+ private cleanup;
5
6
  private constructor();
6
7
  static getInstance(): DCP;
8
+ /**
9
+ * Initialize the SDK. Must be called before pay() or Payment().
10
+ */
7
11
  init(initConfig: DCPInitConfig): void;
8
12
  /**
9
- * Pay using a Payment Tool (toolId).
10
- * Requires DCP.init() first.
13
+ * Open a checkout iframe for a Payment Tool (link, button, donation, etc.).
14
+ * The checkout page handles wallet connection, token selection, and payment.
11
15
  */
12
16
  pay(options: DCPPayOptions): void;
13
17
  /**
14
- * Pay using a pre-configured Integration.
15
- * Supports optional currency/chainId when omitted, shows a token selector.
16
- * Requires DCP.init() first (for WalletConnect projectId).
18
+ * Open a checkout iframe for an Integration with dynamic amount.
19
+ * Use this for programmatic payments where amount is determined at runtime.
17
20
  */
18
21
  Payment(options: DCPPaymentOptions): void;
22
+ /**
23
+ * Programmatically close the checkout iframe.
24
+ */
25
+ close(): void;
19
26
  }
20
27
  export declare const dcp: DCP;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { dcp as DCP } from './dcp';
2
2
  export type { DCPInitConfig } from './core/config';
3
- export type { DCPPayOptions, DCPPaymentOptions, PaymentCallbacks, PaymentStatus, IntegrationConfig, } from './types';
3
+ export type { DCPPayOptions, DCPPaymentOptions, PaymentCallbacks } from './types';
package/dist/index.js CHANGED
@@ -1,4 +1,221 @@
1
- import { fx as r } from "./index-DeL88Lwc.js";
1
+ var z = Object.defineProperty;
2
+ var D = (p, e, d) => e in p ? z(p, e, { enumerable: !0, configurable: !0, writable: !0, value: d }) : p[e] = d;
3
+ var g = (p, e, d) => D(p, typeof e != "symbol" ? e + "" : e, d);
4
+ class P {
5
+ constructor() {
6
+ g(this, "config", null);
7
+ }
8
+ init(e) {
9
+ this.config = {
10
+ checkoutUrl: (e.checkoutUrl || "https://directcryptopay.com").replace(/\/$/, "")
11
+ };
12
+ }
13
+ get() {
14
+ if (!this.config)
15
+ throw new Error("DirectCryptoPay: SDK not initialized. Call DCP.init() first");
16
+ return this.config;
17
+ }
18
+ isInitialized() {
19
+ return this.config !== null;
20
+ }
21
+ }
22
+ const y = new P();
23
+ function a(p, e) {
24
+ let d = !1;
25
+ const i = document.createElement("div");
26
+ i.id = "dcp-checkout-overlay", Object.assign(i.style, {
27
+ position: "fixed",
28
+ inset: "0",
29
+ zIndex: "99999",
30
+ background: "rgba(0, 0, 0, 0.6)",
31
+ display: "flex",
32
+ alignItems: "center",
33
+ justifyContent: "center"
34
+ });
35
+ const h = document.createElement("div");
36
+ Object.assign(h.style, {
37
+ background: "white",
38
+ borderRadius: "16px",
39
+ overflow: "hidden",
40
+ width: "100%",
41
+ maxWidth: "440px",
42
+ maxHeight: "90vh",
43
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
44
+ position: "relative"
45
+ });
46
+ const t = document.createElement("button");
47
+ t.innerHTML = "×", Object.assign(t.style, {
48
+ position: "absolute",
49
+ top: "8px",
50
+ right: "8px",
51
+ zIndex: "10",
52
+ background: "rgba(255, 255, 255, 0.9)",
53
+ border: "none",
54
+ borderRadius: "50%",
55
+ width: "32px",
56
+ height: "32px",
57
+ fontSize: "20px",
58
+ lineHeight: "32px",
59
+ textAlign: "center",
60
+ cursor: "pointer",
61
+ color: "#6b7280",
62
+ boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
63
+ });
64
+ const u = document.createElement("iframe");
65
+ u.src = p, Object.assign(u.style, {
66
+ width: "100%",
67
+ height: "600px",
68
+ border: "none",
69
+ display: "block"
70
+ }), h.appendChild(t), h.appendChild(u), i.appendChild(h);
71
+ const n = () => {
72
+ d || (d = !0, window.removeEventListener("message", w), window.removeEventListener("keydown", r), i.parentNode && i.parentNode.removeChild(i));
73
+ };
74
+ t.onclick = () => {
75
+ var s;
76
+ n(), (s = e == null ? void 0 : e.onClose) == null || s.call(e);
77
+ }, i.addEventListener("click", (s) => {
78
+ var o;
79
+ s.target === i && (n(), (o = e == null ? void 0 : e.onClose) == null || o.call(e));
80
+ });
81
+ const r = (s) => {
82
+ var o;
83
+ s.key === "Escape" && (n(), (o = e == null ? void 0 : e.onClose) == null || o.call(e));
84
+ };
85
+ window.addEventListener("keydown", r);
86
+ const w = (s) => {
87
+ var x, C, S, E, I, v;
88
+ const o = s.data;
89
+ if (!(!o || typeof o.type != "string") && o.type.startsWith("dcp:"))
90
+ switch (o.type) {
91
+ case "dcp:ready":
92
+ (x = e == null ? void 0 : e.onReady) == null || x.call(e);
93
+ break;
94
+ case "dcp:payment-submitted":
95
+ (C = e == null ? void 0 : e.onTxSubmitted) == null || C.call(e, o.txHash);
96
+ break;
97
+ case "dcp:payment-success":
98
+ (S = e == null ? void 0 : e.onSuccess) == null || S.call(e, { txHash: o.txHash, intentId: o.intentId });
99
+ break;
100
+ case "dcp:payment-error":
101
+ (E = e == null ? void 0 : e.onError) == null || E.call(e, o.error);
102
+ break;
103
+ case "dcp:payment-cancelled":
104
+ (I = e == null ? void 0 : e.onCancel) == null || I.call(e), n();
105
+ break;
106
+ case "dcp:close":
107
+ (v = e == null ? void 0 : e.onClose) == null || v.call(e), n();
108
+ break;
109
+ }
110
+ };
111
+ return window.addEventListener("message", w), document.body.appendChild(i), n;
112
+ }
113
+ const m = class m {
114
+ constructor() {
115
+ g(this, "cleanup", null);
116
+ }
117
+ static getInstance() {
118
+ return m.instance || (m.instance = new m()), m.instance;
119
+ }
120
+ /**
121
+ * Initialize the SDK. Must be called before pay() or Payment().
122
+ */
123
+ init(e) {
124
+ if (y.isInitialized()) {
125
+ console.warn("DirectCryptoPay: SDK already initialized");
126
+ return;
127
+ }
128
+ y.init(e);
129
+ }
130
+ /**
131
+ * Open a checkout iframe for a Payment Tool (link, button, donation, etc.).
132
+ * The checkout page handles wallet connection, token selection, and payment.
133
+ */
134
+ pay(e) {
135
+ var u;
136
+ if (!y.isInitialized())
137
+ throw new Error("DirectCryptoPay: SDK not initialized. Call DCP.init() first");
138
+ const { checkoutUrl: d } = y.get(), i = new URLSearchParams({ embedded: "true" });
139
+ e.amountUsd && i.set("amount", String(e.amountUsd));
140
+ const h = `${d}/pay/${e.toolId}?${i.toString()}`, t = e.callbacks;
141
+ (u = this.cleanup) == null || u.call(this), this.cleanup = a(h, {
142
+ onReady: () => {
143
+ var n;
144
+ return (n = t == null ? void 0 : t.onOpen) == null ? void 0 : n.call(t);
145
+ },
146
+ onTxSubmitted: (n) => {
147
+ var r;
148
+ return (r = t == null ? void 0 : t.onTxSubmitted) == null ? void 0 : r.call(t, n);
149
+ },
150
+ onSuccess: (n) => {
151
+ var r;
152
+ return (r = t == null ? void 0 : t.onSuccess) == null ? void 0 : r.call(t, n);
153
+ },
154
+ onError: (n) => {
155
+ var r;
156
+ return (r = t == null ? void 0 : t.onError) == null ? void 0 : r.call(t, new Error(n));
157
+ },
158
+ onClose: () => {
159
+ var n;
160
+ this.cleanup = null, (n = t == null ? void 0 : t.onClose) == null || n.call(t);
161
+ },
162
+ onCancel: () => {
163
+ var n;
164
+ this.cleanup = null, (n = t == null ? void 0 : t.onCancel) == null || n.call(t);
165
+ }
166
+ });
167
+ }
168
+ /**
169
+ * Open a checkout iframe for an Integration with dynamic amount.
170
+ * Use this for programmatic payments where amount is determined at runtime.
171
+ */
172
+ Payment(e) {
173
+ var u;
174
+ if (!y.isInitialized())
175
+ throw new Error("DirectCryptoPay: SDK not initialized. Call DCP.init() first");
176
+ if (!e.integrationId)
177
+ throw new Error("DirectCryptoPay: integrationId is required");
178
+ const { checkoutUrl: d } = y.get(), i = new URLSearchParams({ embedded: "true" });
179
+ i.set("integrationId", e.integrationId), e.amount_usd && i.set("amount_usd", e.amount_usd), e.amount != null && i.set("amount", String(e.amount)), e.currency && i.set("currency", e.currency), e.chainId && i.set("chainId", String(e.chainId)), e.metadata && i.set("metadata", JSON.stringify(e.metadata));
180
+ const h = `${d}/pay/checkout?${i.toString()}`, t = e.callbacks;
181
+ (u = this.cleanup) == null || u.call(this), this.cleanup = a(h, {
182
+ onReady: () => {
183
+ var n;
184
+ return (n = t == null ? void 0 : t.onOpen) == null ? void 0 : n.call(t);
185
+ },
186
+ onTxSubmitted: (n) => {
187
+ var r;
188
+ return (r = t == null ? void 0 : t.onTxSubmitted) == null ? void 0 : r.call(t, n);
189
+ },
190
+ onSuccess: (n) => {
191
+ var r;
192
+ return (r = t == null ? void 0 : t.onSuccess) == null ? void 0 : r.call(t, n);
193
+ },
194
+ onError: (n) => {
195
+ var r;
196
+ return (r = t == null ? void 0 : t.onError) == null ? void 0 : r.call(t, new Error(n));
197
+ },
198
+ onClose: () => {
199
+ var n;
200
+ this.cleanup = null, (n = t == null ? void 0 : t.onClose) == null || n.call(t);
201
+ },
202
+ onCancel: () => {
203
+ var n;
204
+ this.cleanup = null, (n = t == null ? void 0 : t.onCancel) == null || n.call(t);
205
+ }
206
+ });
207
+ }
208
+ /**
209
+ * Programmatically close the checkout iframe.
210
+ */
211
+ close() {
212
+ var e;
213
+ (e = this.cleanup) == null || e.call(this), this.cleanup = null;
214
+ }
215
+ };
216
+ g(m, "instance");
217
+ let f = m;
218
+ const U = f.getInstance();
2
219
  export {
3
- r as DCP
220
+ U as DCP
4
221
  };
package/dist/types.d.ts CHANGED
@@ -1,188 +1,50 @@
1
- import type { Address, Hash } from 'viem';
2
1
  /**
3
- * Payment intent from the API
2
+ * Callbacks for payment lifecycle events.
4
3
  */
5
- export interface PaymentIntent {
6
- id: string;
7
- chain_id: number;
8
- recipient: Address;
9
- amount_wei: string;
10
- currency: string;
11
- expires_at: string;
12
- signature: string;
13
- status: 'CREATED' | 'PENDING' | 'PAID' | 'FAILED' | 'EXPIRED' | 'LATE_CONFIRMED';
14
- metadata?: Record<string, any>;
15
- asset_type?: 'native' | 'erc20';
16
- token_address?: Address;
17
- token_decimals?: number;
18
- nonce?: string;
19
- }
20
- /**
21
- * Gas estimation result
22
- */
23
- export interface GasEstimate {
24
- gasLimit: bigint;
25
- maxFeePerGas: bigint;
26
- maxPriorityFeePerGas: bigint;
27
- totalCostWei: bigint;
28
- percentageOfPayment: number;
29
- exceedsThreshold: boolean;
30
- }
31
- /**
32
- * Payment status update
33
- */
34
- export type PaymentStatus = {
35
- type: 'fetching_tool_data';
36
- } | {
37
- type: 'fetching_token_balances';
38
- } | {
39
- type: 'awaiting_token_selection';
40
- } | {
41
- type: 'creating_payment_intent';
42
- } | {
43
- type: 'estimating_gas';
44
- } | {
45
- type: 'gas_estimated';
46
- estimate: GasEstimate;
47
- } | {
48
- type: 'awaiting_wallet_connection';
49
- } | {
50
- type: 'wallet_connected';
51
- address: Address;
52
- } | {
53
- type: 'awaiting_signature';
54
- } | {
55
- type: 'transaction_submitted';
56
- txHash: Hash;
57
- } | {
58
- type: 'confirming';
59
- txHash: Hash;
60
- confirmations: number;
61
- } | {
62
- type: 'verifying';
63
- txHash: Hash;
64
- paymentId: string;
65
- } | {
66
- type: 'confirmed';
67
- txHash: Hash;
68
- paymentId?: string;
69
- } | {
70
- type: 'failed';
71
- error: Error;
72
- } | {
73
- type: 'rejected';
74
- } | {
75
- type: 'cancelled';
76
- };
77
- export interface TokenConfig {
78
- symbol: string;
79
- name: string;
80
- address: string | null;
81
- decimals: number;
82
- isNative: boolean;
83
- }
84
- export interface TokenWithBalance extends TokenConfig {
85
- balance: string;
86
- balanceFormatted: string;
87
- hasBalance: boolean;
88
- }
89
- export interface ToolData {
90
- id: string;
91
- amount: string;
92
- currency_id: string;
93
- chain_id: number;
94
- recipient_address: string;
95
- available_tokens: TokenConfig[];
96
- metadata: {
97
- name: string;
98
- type: string;
99
- };
100
- }
101
- export interface BackendIntentResponse {
102
- id: string;
103
- amount: string;
104
- currency: string;
105
- chainId: number;
106
- tokenAddress: Address;
107
- merchantAddress: Address;
108
- expiresAt: string;
109
- signature: string;
110
- nonce: string;
111
- }
112
4
  export interface PaymentCallbacks {
5
+ /** Fired when the checkout iframe opens. */
113
6
  onOpen?: () => void;
7
+ /** Fired when the checkout iframe is closed (by user or programmatically). */
114
8
  onClose?: () => void;
115
- onStatus?: (status: PaymentStatus) => void;
116
- onTxSubmitted?: (txHash: Hash) => void;
117
- onSuccess?: (receipt: any) => void;
9
+ /** Fired when the transaction hash is available (TX sent, not yet confirmed). */
10
+ onTxSubmitted?: (txHash: string) => void;
11
+ /** Fired when the payment is confirmed on-chain. */
12
+ onSuccess?: (data: {
13
+ txHash: string;
14
+ intentId?: string;
15
+ }) => void;
16
+ /** Fired when the user explicitly cancels the payment. */
118
17
  onCancel?: () => void;
18
+ /** Fired on payment error. */
119
19
  onError?: (error: Error) => void;
120
20
  }
21
+ /**
22
+ * Options for DCP.pay() — tool-based payments (payment links, buttons, etc.)
23
+ */
121
24
  export interface DCPPayOptions {
25
+ /** The payment tool ID (from the dashboard). */
122
26
  toolId: string;
27
+ /** Optional amount override in USD. */
123
28
  amountUsd?: number;
124
- token?: string;
125
- chainId?: number;
126
- metadata?: Record<string, string>;
29
+ /** Payment lifecycle callbacks. */
127
30
  callbacks?: PaymentCallbacks;
128
31
  }
129
32
  /**
130
- * Options for DCP.Payment() — integration-based payments
33
+ * Options for DCP.Payment() — integration-based payments with dynamic amounts.
131
34
  */
132
35
  export interface DCPPaymentOptions {
36
+ /** The integration public ID. */
133
37
  integrationId: string;
38
+ /** Amount in USD (mutually exclusive with `amount`). */
134
39
  amount_usd?: string;
40
+ /** Amount in token units (mutually exclusive with `amount_usd`). */
135
41
  amount?: string | number;
42
+ /** Token symbol (e.g., 'USDC'). When omitted, user picks from available tokens. */
136
43
  currency?: string;
44
+ /** Chain ID override. */
137
45
  chainId?: number;
46
+ /** Arbitrary metadata passed to the backend. */
138
47
  metadata?: Record<string, any>;
48
+ /** Payment lifecycle callbacks. */
139
49
  callbacks?: PaymentCallbacks;
140
50
  }
141
- /**
142
- * Integration config returned from GET /public/integrations/:id
143
- */
144
- export interface IntegrationConfig {
145
- publicId: string;
146
- name: string;
147
- allowChains: number[];
148
- allowTokens: string[];
149
- autoConversion: boolean;
150
- preferredToken: string | null;
151
- chains: Record<number, {
152
- name: string;
153
- tokens: TokenConfig[];
154
- }>;
155
- }
156
- /**
157
- * Intent response from POST /public/integrations/:id/intent
158
- */
159
- export interface IntegrationIntentResponse {
160
- id?: string;
161
- intent_id?: string;
162
- chain_id: number;
163
- recipient: Address;
164
- amount_wei: string;
165
- currency: string;
166
- expires_at?: string;
167
- signature?: string;
168
- status?: string;
169
- asset_type?: 'native' | 'erc20';
170
- token_address?: Address;
171
- token_decimals?: number;
172
- metadata?: Record<string, any>;
173
- }
174
- /**
175
- * Discriminated union for modal mode
176
- */
177
- export type ModalMode = {
178
- type: 'tool';
179
- toolId: string;
180
- } | {
181
- type: 'integration';
182
- integrationId: string;
183
- amount_usd?: string;
184
- amount?: string | number;
185
- currency?: string;
186
- chainId?: number;
187
- metadata?: Record<string, any>;
188
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directcryptopay/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Official SDK for DirectCryptoPay — accept crypto payments directly to your wallet. Non-custodial, multi-chain, developer-first.",
5
5
  "type": "module",
6
6
  "main": "./dist/dcp-sdk.umd.js",
@@ -8,9 +8,9 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js",
12
- "require": "./dist/dcp-sdk.umd.js",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/dcp-sdk.umd.js"
14
14
  }
15
15
  },
16
16
  "files": [
@@ -53,17 +53,7 @@
53
53
  "typecheck": "tsc --noEmit",
54
54
  "prepublishOnly": "npm run build"
55
55
  },
56
- "dependencies": {
57
- "@reown/appkit": "1.8.14",
58
- "@reown/appkit-adapter-wagmi": "1.8.14",
59
- "@tanstack/react-query": "^5.62.0",
60
- "@wagmi/core": "^2.22.1",
61
- "preact": "^10.25.0",
62
- "viem": "^2.40.3",
63
- "wagmi": "^2.19.5"
64
- },
65
56
  "devDependencies": {
66
- "@preact/preset-vite": "^2.9.2",
67
57
  "typescript": "^5.7.2",
68
58
  "vite": "^6.0.0"
69
59
  }