@ton-pay/api 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -22,28 +22,28 @@ import {
22
22
  verifySignature,
23
23
  TON,
24
24
  USDT,
25
- } from "@ton-pay/api";
25
+ } from '@ton-pay/api';
26
26
 
27
27
  // Create a TON Pay transfer
28
28
  const transfer = await createTonPayTransfer(
29
29
  {
30
30
  amount: 10.5,
31
31
  asset: TON,
32
- recipientAddr: "EQC...", // Optional if API key is provided
33
- senderAddr: "EQC...",
34
- commentToSender: "Payment for order #123",
35
- commentToRecipient: "Thank you!",
32
+ recipientAddr: 'EQC...', // Optional if API key is provided
33
+ senderAddr: 'EQC...',
34
+ commentToSender: 'Payment for order #123',
35
+ commentToRecipient: 'Thank you!',
36
36
  },
37
37
  {
38
- chain: "mainnet",
39
- apiKey: "your-api-key",
40
- }
38
+ chain: 'mainnet',
39
+ apiKey: 'your-api-key',
40
+ },
41
41
  );
42
42
 
43
43
  // Get transfer status by reference
44
44
  const transferInfo = await getTonPayTransferByReference(transfer.reference, {
45
- chain: "mainnet",
46
- apiKey: "your-api-key",
45
+ chain: 'mainnet',
46
+ apiKey: 'your-api-key',
47
47
  });
48
48
 
49
49
  // Verify webhook signature
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- type Chain = "mainnet" | "testnet";
1
+ type Chain = 'mainnet' | 'testnet';
2
2
 
3
3
  type APIOptions = {
4
4
  chain?: Chain;
@@ -46,6 +46,124 @@ type CreateTonPayTransferResponse = {
46
46
  */
47
47
  declare const createTonPayTransfer: (params: CreateTonPayTransferParams, options?: APIOptions) => Promise<CreateTonPayTransferResponse>;
48
48
 
49
+ /**
50
+ * MoonPay geo location result
51
+ */
52
+ type MoonpayGeoResult = {
53
+ alpha2: string;
54
+ alpha3: string;
55
+ country: string;
56
+ state: string;
57
+ ipAddress: string;
58
+ isAllowed: boolean;
59
+ isBuyAllowed: boolean;
60
+ isNftAllowed: boolean;
61
+ isSellAllowed: boolean;
62
+ isBalanceLedgerWithdrawAllowed: boolean;
63
+ isFiatBalanceAllowed: boolean;
64
+ isMoonPayBalanceAllowed: boolean;
65
+ isLowLimitEnabled: boolean;
66
+ };
67
+ /**
68
+ * MoonPay amount limits
69
+ */
70
+ type MoonpayAmountLimits = {
71
+ paymentMethod: string;
72
+ quoteCurrency: {
73
+ code: string;
74
+ minBuyAmount: number;
75
+ maxBuyAmount: number;
76
+ };
77
+ baseCurrency: {
78
+ code: string;
79
+ minBuyAmount: number;
80
+ maxBuyAmount: number;
81
+ };
82
+ areFeesIncluded: boolean;
83
+ };
84
+ /**
85
+ * @param amount - in human readable format, 10.5 for example
86
+ * @param asset - jetton master address or TON coin address for TON transfer
87
+ * @param recipientAddr - recipient wallet address. Optional if API key is provided - defaults to the merchant's wallet address from the admin panel
88
+ * @param userIp - user's IP address (required for geo verification)
89
+ * @param redirectURL - redirect URL after Moonpay purchase
90
+ */
91
+ type CreateMoonpayTransferParams = {
92
+ amount: number;
93
+ asset: string;
94
+ recipientAddr?: string;
95
+ userIp: string;
96
+ redirectURL: string;
97
+ };
98
+ /**
99
+ * @param link - MoonPay payment link
100
+ * @param geo - MoonPay geo location result
101
+ * @param limits - MoonPay amount limits
102
+ */
103
+ type CreateMoonpayTransferResponse = {
104
+ link: string;
105
+ geo?: MoonpayGeoResult;
106
+ limits: MoonpayAmountLimits;
107
+ };
108
+
109
+ /**
110
+ * Creates a MoonPay payment link for buying crypto
111
+ * @param params - the parameters for the MoonPay transfer
112
+ * @param options - the options for the transfer (requires API key)
113
+ * @returns the payment link, geo restrictions, and amount limits
114
+ */
115
+ declare const createMoonpayTransfer: (params: CreateMoonpayTransferParams, options: APIOptions) => Promise<CreateMoonpayTransferResponse>;
116
+
117
+ /**
118
+ * @param ipAddress - IP address to check for geo restrictions
119
+ */
120
+ type CheckMoonpayGeoParams = {
121
+ ipAddress: string;
122
+ };
123
+ /**
124
+ * MoonPay geo check response
125
+ */
126
+ type CheckMoonpayGeoResponse = MoonpayGeoResult;
127
+
128
+ /**
129
+ * Checks MoonPay geo restrictions for an IP address
130
+ * @param params - the IP address to check
131
+ * @param options - optional API options
132
+ * @returns the geo location and restrictions
133
+ */
134
+ declare const checkMoonpayGeo: (params: CheckMoonpayGeoParams, options?: APIOptions) => Promise<CheckMoonpayGeoResponse>;
135
+
136
+ /**
137
+ * @param asset - jetton master address or TON coin address for TON
138
+ */
139
+ type CheckMoonpayLimitsParams = {
140
+ asset: string;
141
+ };
142
+ /**
143
+ * MoonPay limits check response
144
+ */
145
+ type CheckMoonpayLimitsResponse = MoonpayAmountLimits;
146
+
147
+ /**
148
+ * Gets MoonPay amount limits for an asset
149
+ * @param params - the asset to check limits for
150
+ * @param options - optional API options
151
+ * @returns the amount limits for the asset
152
+ */
153
+ declare const checkMoonpayLimits: (params: CheckMoonpayLimitsParams, options?: APIOptions) => Promise<CheckMoonpayLimitsResponse>;
154
+
155
+ type CheckMoonpayAvailabilityParams = {
156
+ asset: string;
157
+ ipAddress?: string;
158
+ };
159
+ type CheckMoonpayAvailabilityResponse = {
160
+ geo: MoonpayGeoResult;
161
+ limits: MoonpayAmountLimits;
162
+ currencyCode: string;
163
+ };
164
+
165
+ declare const checkMoonpayAvailability: (params: CheckMoonpayAvailabilityParams, options?: APIOptions) => Promise<CheckMoonpayAvailabilityResponse>;
166
+
49
167
  /**
50
168
  * @param amount - the amount of the transfer in human readable format
51
169
  * @param rawAmount - the amount of the transfer in base units
@@ -120,7 +238,7 @@ type GetTonPayTransferByReferenceParams = {
120
238
  * - `transfer.completed` - Transfer completed (check `data.status` for success/failed)
121
239
  * - `transfer.refunded` - Transfer was refunded (Coming Soon)
122
240
  */
123
- type WebhookEventType = "transfer.completed" | "transfer.refunded";
241
+ type WebhookEventType = 'transfer.completed' | 'transfer.refunded';
124
242
 
125
243
  /**
126
244
  * Base webhook payload structure
@@ -137,7 +255,7 @@ interface BaseWebhookPayload {
137
255
  * Check `data.status` field to determine if transfer was "success" or "failed".
138
256
  */
139
257
  interface TransferCompletedWebhookPayload extends BaseWebhookPayload {
140
- event: "transfer.completed";
258
+ event: 'transfer.completed';
141
259
  data: CompletedTonPayTransferInfo;
142
260
  }
143
261
  /**
@@ -147,7 +265,7 @@ interface TransferCompletedWebhookPayload extends BaseWebhookPayload {
147
265
  * Coming Soon - Sent when a transfer is refunded
148
266
  */
149
267
  interface TransferRefundedWebhookPayload extends BaseWebhookPayload {
150
- event: "transfer.refunded";
268
+ event: 'transfer.refunded';
151
269
  data: unknown;
152
270
  }
153
271
  /**
@@ -199,4 +317,4 @@ declare const TON = "TON";
199
317
  */
200
318
  declare function verifySignature(payload: string | object, signature: string, apiSecret: string): boolean;
201
319
 
202
- export { type APIOptions, type Chain, type CompletedTonPayTransferInfo, type CreateTonPayTransferParams, type CreateTonPayTransferResponse, type GetTonPayTransferByBodyHashParams, type GetTonPayTransferByReferenceParams, TON, type TransferCompletedWebhookPayload, type TransferRefundedWebhookPayload, USDT, type WebhookEventType, type WebhookPayload, createTonPayTransfer, getTonPayTransferByBodyHash, getTonPayTransferByReference, verifySignature };
320
+ export { type APIOptions, type Chain, type CheckMoonpayAvailabilityParams, type CheckMoonpayAvailabilityResponse, type CheckMoonpayGeoParams, type CheckMoonpayGeoResponse, type CheckMoonpayLimitsParams, type CheckMoonpayLimitsResponse, type CompletedTonPayTransferInfo, type CreateMoonpayTransferParams, type CreateMoonpayTransferResponse, type CreateTonPayTransferParams, type CreateTonPayTransferResponse, type GetTonPayTransferByBodyHashParams, type GetTonPayTransferByReferenceParams, type MoonpayAmountLimits, type MoonpayGeoResult, TON, type TransferCompletedWebhookPayload, type TransferRefundedWebhookPayload, USDT, type WebhookEventType, type WebhookPayload, checkMoonpayAvailability, checkMoonpayGeo, checkMoonpayLimits, createMoonpayTransfer, createTonPayTransfer, getTonPayTransferByBodyHash, getTonPayTransferByReference, verifySignature };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type Chain = "mainnet" | "testnet";
1
+ type Chain = 'mainnet' | 'testnet';
2
2
 
3
3
  type APIOptions = {
4
4
  chain?: Chain;
@@ -46,6 +46,124 @@ type CreateTonPayTransferResponse = {
46
46
  */
47
47
  declare const createTonPayTransfer: (params: CreateTonPayTransferParams, options?: APIOptions) => Promise<CreateTonPayTransferResponse>;
48
48
 
49
+ /**
50
+ * MoonPay geo location result
51
+ */
52
+ type MoonpayGeoResult = {
53
+ alpha2: string;
54
+ alpha3: string;
55
+ country: string;
56
+ state: string;
57
+ ipAddress: string;
58
+ isAllowed: boolean;
59
+ isBuyAllowed: boolean;
60
+ isNftAllowed: boolean;
61
+ isSellAllowed: boolean;
62
+ isBalanceLedgerWithdrawAllowed: boolean;
63
+ isFiatBalanceAllowed: boolean;
64
+ isMoonPayBalanceAllowed: boolean;
65
+ isLowLimitEnabled: boolean;
66
+ };
67
+ /**
68
+ * MoonPay amount limits
69
+ */
70
+ type MoonpayAmountLimits = {
71
+ paymentMethod: string;
72
+ quoteCurrency: {
73
+ code: string;
74
+ minBuyAmount: number;
75
+ maxBuyAmount: number;
76
+ };
77
+ baseCurrency: {
78
+ code: string;
79
+ minBuyAmount: number;
80
+ maxBuyAmount: number;
81
+ };
82
+ areFeesIncluded: boolean;
83
+ };
84
+ /**
85
+ * @param amount - in human readable format, 10.5 for example
86
+ * @param asset - jetton master address or TON coin address for TON transfer
87
+ * @param recipientAddr - recipient wallet address. Optional if API key is provided - defaults to the merchant's wallet address from the admin panel
88
+ * @param userIp - user's IP address (required for geo verification)
89
+ * @param redirectURL - redirect URL after Moonpay purchase
90
+ */
91
+ type CreateMoonpayTransferParams = {
92
+ amount: number;
93
+ asset: string;
94
+ recipientAddr?: string;
95
+ userIp: string;
96
+ redirectURL: string;
97
+ };
98
+ /**
99
+ * @param link - MoonPay payment link
100
+ * @param geo - MoonPay geo location result
101
+ * @param limits - MoonPay amount limits
102
+ */
103
+ type CreateMoonpayTransferResponse = {
104
+ link: string;
105
+ geo?: MoonpayGeoResult;
106
+ limits: MoonpayAmountLimits;
107
+ };
108
+
109
+ /**
110
+ * Creates a MoonPay payment link for buying crypto
111
+ * @param params - the parameters for the MoonPay transfer
112
+ * @param options - the options for the transfer (requires API key)
113
+ * @returns the payment link, geo restrictions, and amount limits
114
+ */
115
+ declare const createMoonpayTransfer: (params: CreateMoonpayTransferParams, options: APIOptions) => Promise<CreateMoonpayTransferResponse>;
116
+
117
+ /**
118
+ * @param ipAddress - IP address to check for geo restrictions
119
+ */
120
+ type CheckMoonpayGeoParams = {
121
+ ipAddress: string;
122
+ };
123
+ /**
124
+ * MoonPay geo check response
125
+ */
126
+ type CheckMoonpayGeoResponse = MoonpayGeoResult;
127
+
128
+ /**
129
+ * Checks MoonPay geo restrictions for an IP address
130
+ * @param params - the IP address to check
131
+ * @param options - optional API options
132
+ * @returns the geo location and restrictions
133
+ */
134
+ declare const checkMoonpayGeo: (params: CheckMoonpayGeoParams, options?: APIOptions) => Promise<CheckMoonpayGeoResponse>;
135
+
136
+ /**
137
+ * @param asset - jetton master address or TON coin address for TON
138
+ */
139
+ type CheckMoonpayLimitsParams = {
140
+ asset: string;
141
+ };
142
+ /**
143
+ * MoonPay limits check response
144
+ */
145
+ type CheckMoonpayLimitsResponse = MoonpayAmountLimits;
146
+
147
+ /**
148
+ * Gets MoonPay amount limits for an asset
149
+ * @param params - the asset to check limits for
150
+ * @param options - optional API options
151
+ * @returns the amount limits for the asset
152
+ */
153
+ declare const checkMoonpayLimits: (params: CheckMoonpayLimitsParams, options?: APIOptions) => Promise<CheckMoonpayLimitsResponse>;
154
+
155
+ type CheckMoonpayAvailabilityParams = {
156
+ asset: string;
157
+ ipAddress?: string;
158
+ };
159
+ type CheckMoonpayAvailabilityResponse = {
160
+ geo: MoonpayGeoResult;
161
+ limits: MoonpayAmountLimits;
162
+ currencyCode: string;
163
+ };
164
+
165
+ declare const checkMoonpayAvailability: (params: CheckMoonpayAvailabilityParams, options?: APIOptions) => Promise<CheckMoonpayAvailabilityResponse>;
166
+
49
167
  /**
50
168
  * @param amount - the amount of the transfer in human readable format
51
169
  * @param rawAmount - the amount of the transfer in base units
@@ -120,7 +238,7 @@ type GetTonPayTransferByReferenceParams = {
120
238
  * - `transfer.completed` - Transfer completed (check `data.status` for success/failed)
121
239
  * - `transfer.refunded` - Transfer was refunded (Coming Soon)
122
240
  */
123
- type WebhookEventType = "transfer.completed" | "transfer.refunded";
241
+ type WebhookEventType = 'transfer.completed' | 'transfer.refunded';
124
242
 
125
243
  /**
126
244
  * Base webhook payload structure
@@ -137,7 +255,7 @@ interface BaseWebhookPayload {
137
255
  * Check `data.status` field to determine if transfer was "success" or "failed".
138
256
  */
139
257
  interface TransferCompletedWebhookPayload extends BaseWebhookPayload {
140
- event: "transfer.completed";
258
+ event: 'transfer.completed';
141
259
  data: CompletedTonPayTransferInfo;
142
260
  }
143
261
  /**
@@ -147,7 +265,7 @@ interface TransferCompletedWebhookPayload extends BaseWebhookPayload {
147
265
  * Coming Soon - Sent when a transfer is refunded
148
266
  */
149
267
  interface TransferRefundedWebhookPayload extends BaseWebhookPayload {
150
- event: "transfer.refunded";
268
+ event: 'transfer.refunded';
151
269
  data: unknown;
152
270
  }
153
271
  /**
@@ -199,4 +317,4 @@ declare const TON = "TON";
199
317
  */
200
318
  declare function verifySignature(payload: string | object, signature: string, apiSecret: string): boolean;
201
319
 
202
- export { type APIOptions, type Chain, type CompletedTonPayTransferInfo, type CreateTonPayTransferParams, type CreateTonPayTransferResponse, type GetTonPayTransferByBodyHashParams, type GetTonPayTransferByReferenceParams, TON, type TransferCompletedWebhookPayload, type TransferRefundedWebhookPayload, USDT, type WebhookEventType, type WebhookPayload, createTonPayTransfer, getTonPayTransferByBodyHash, getTonPayTransferByReference, verifySignature };
320
+ export { type APIOptions, type Chain, type CheckMoonpayAvailabilityParams, type CheckMoonpayAvailabilityResponse, type CheckMoonpayGeoParams, type CheckMoonpayGeoResponse, type CheckMoonpayLimitsParams, type CheckMoonpayLimitsResponse, type CompletedTonPayTransferInfo, type CreateMoonpayTransferParams, type CreateMoonpayTransferResponse, type CreateTonPayTransferParams, type CreateTonPayTransferResponse, type GetTonPayTransferByBodyHashParams, type GetTonPayTransferByReferenceParams, type MoonpayAmountLimits, type MoonpayGeoResult, TON, type TransferCompletedWebhookPayload, type TransferRefundedWebhookPayload, USDT, type WebhookEventType, type WebhookPayload, checkMoonpayAvailability, checkMoonpayGeo, checkMoonpayLimits, createMoonpayTransfer, createTonPayTransfer, getTonPayTransferByBodyHash, getTonPayTransferByReference, verifySignature };