@settlr/sdk 0.6.0 → 0.6.1
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 +66 -1
- package/dist/index.d.mts +111 -1
- package/dist/index.d.ts +111 -1
- package/dist/index.js +173 -0
- package/dist/index.mjs +167 -0
- package/package.json +19 -2
package/README.md
CHANGED
|
@@ -97,6 +97,71 @@ const accounts = await buildPrivateReceiptAccounts({
|
|
|
97
97
|
|
|
98
98
|
> **Private on-chain. Compliant off-chain.** Your competitors can't see your revenue, but your accountant can.
|
|
99
99
|
|
|
100
|
+
## 🛡️ Wallet Security (Range)
|
|
101
|
+
|
|
102
|
+
Settlr integrates Range Security to screen wallets before processing payments:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { screenWallet, isWalletBlocked, RiskLevel } from "@settlr/sdk";
|
|
106
|
+
|
|
107
|
+
// Screen a wallet for sanctions, fraud, mixers, etc.
|
|
108
|
+
const result = await screenWallet("SomeWalletAddress...");
|
|
109
|
+
|
|
110
|
+
if (result.riskLevel === RiskLevel.SEVERE || result.isSanctioned) {
|
|
111
|
+
console.log("Wallet is blocked:", result.categories);
|
|
112
|
+
// Don't process payment
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Quick check
|
|
116
|
+
const blocked = await isWalletBlocked("SuspiciousWallet...");
|
|
117
|
+
if (blocked) {
|
|
118
|
+
return { error: "Payment blocked for compliance" };
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**What Range screens for:**
|
|
123
|
+
|
|
124
|
+
- 🚫 **Sanctions** - OFAC, EU sanctions lists
|
|
125
|
+
- 🕵️ **Fraud** - Known scam wallets
|
|
126
|
+
- 🌀 **Mixers** - Tornado Cash, etc.
|
|
127
|
+
- 🌑 **Darknet** - Illicit marketplace activity
|
|
128
|
+
- 💀 **Ransomware** - Known attack wallets
|
|
129
|
+
- 🎰 **Gambling** - Unlicensed gambling (configurable)
|
|
130
|
+
|
|
131
|
+
## 💸 Private Payouts (Privacy Cash)
|
|
132
|
+
|
|
133
|
+
Enable ZK-shielded payments for privacy-conscious merchants:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import {
|
|
137
|
+
createPrivacyCashClient,
|
|
138
|
+
shieldPayment,
|
|
139
|
+
privateTransfer,
|
|
140
|
+
} from "@settlr/sdk";
|
|
141
|
+
|
|
142
|
+
// Initialize Privacy Cash
|
|
143
|
+
const privacy = createPrivacyCashClient({
|
|
144
|
+
connection,
|
|
145
|
+
wallet,
|
|
146
|
+
network: "mainnet-beta",
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Shield funds (move to private pool)
|
|
150
|
+
const shieldTx = await shieldPayment(privacy, 100); // $100 USDC
|
|
151
|
+
console.log("Shielded:", shieldTx);
|
|
152
|
+
|
|
153
|
+
// Private transfer (ZK-shielded, amount hidden)
|
|
154
|
+
const transferTx = await privateTransfer(privacy, "RecipientWallet...", 50);
|
|
155
|
+
console.log("Private transfer:", transferTx);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Privacy Cash features:**
|
|
159
|
+
|
|
160
|
+
- 🔐 ZK-shielded transactions
|
|
161
|
+
- 👁️ Amount hidden from on-chain observers
|
|
162
|
+
- ⚡ Fast finality on Solana
|
|
163
|
+
- 💰 Supports USDC and SOL
|
|
164
|
+
|
|
100
165
|
## Installation
|
|
101
166
|
|
|
102
167
|
```bash
|
|
@@ -499,7 +564,7 @@ app.post(
|
|
|
499
564
|
await fulfillOrder(event.payment.orderId);
|
|
500
565
|
},
|
|
501
566
|
},
|
|
502
|
-
})
|
|
567
|
+
}),
|
|
503
568
|
);
|
|
504
569
|
```
|
|
505
570
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1143,4 +1143,114 @@ declare class OneClickClient {
|
|
|
1143
1143
|
*/
|
|
1144
1144
|
declare function createOneClickClient(baseUrl?: string): OneClickClient;
|
|
1145
1145
|
|
|
1146
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* Mobile Game Integration Utilities
|
|
1148
|
+
*
|
|
1149
|
+
* Simple helpers for integrating Settlr payments in mobile games.
|
|
1150
|
+
* Works with Unity, Unreal, native iOS/Android, React Native, etc.
|
|
1151
|
+
*
|
|
1152
|
+
* The simplest integration is URL-based - just open the checkout URL
|
|
1153
|
+
* and listen for the callback.
|
|
1154
|
+
*/
|
|
1155
|
+
interface MobileCheckoutOptions {
|
|
1156
|
+
/** Amount in USDC */
|
|
1157
|
+
amount: number;
|
|
1158
|
+
/** Merchant wallet address */
|
|
1159
|
+
merchantWallet: string;
|
|
1160
|
+
/** Optional: Merchant display name */
|
|
1161
|
+
merchantName?: string;
|
|
1162
|
+
/** Optional: Payment description */
|
|
1163
|
+
memo?: string;
|
|
1164
|
+
/** URL to redirect after success */
|
|
1165
|
+
successUrl?: string;
|
|
1166
|
+
/** URL to redirect on cancel */
|
|
1167
|
+
cancelUrl?: string;
|
|
1168
|
+
/** Optional: Your order/transaction ID */
|
|
1169
|
+
orderId?: string;
|
|
1170
|
+
/** Optional: Customer ID for one-click */
|
|
1171
|
+
customerId?: string;
|
|
1172
|
+
}
|
|
1173
|
+
interface MobileCheckoutResult {
|
|
1174
|
+
success: boolean;
|
|
1175
|
+
signature?: string;
|
|
1176
|
+
orderId?: string;
|
|
1177
|
+
error?: string;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Generate a checkout URL for mobile games
|
|
1181
|
+
*
|
|
1182
|
+
* Usage in Unity (C#):
|
|
1183
|
+
* ```csharp
|
|
1184
|
+
* string url = $"https://settlr.dev/checkout?amount={amount}&merchant={wallet}";
|
|
1185
|
+
* Application.OpenURL(url);
|
|
1186
|
+
* ```
|
|
1187
|
+
*
|
|
1188
|
+
* Usage in Swift:
|
|
1189
|
+
* ```swift
|
|
1190
|
+
* let url = "https://settlr.dev/checkout?amount=\(amount)&merchant=\(wallet)"
|
|
1191
|
+
* UIApplication.shared.open(URL(string: url)!)
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
declare function generateCheckoutUrl(options: MobileCheckoutOptions, baseUrl?: string): string;
|
|
1195
|
+
/**
|
|
1196
|
+
* Generate a deep link for mobile app integration
|
|
1197
|
+
*
|
|
1198
|
+
* For apps that register a custom URL scheme (e.g., mygame://)
|
|
1199
|
+
* the success/cancel URLs can redirect back to the app.
|
|
1200
|
+
*
|
|
1201
|
+
* Example:
|
|
1202
|
+
* - successUrl: "mygame://payment-success?order=123"
|
|
1203
|
+
* - cancelUrl: "mygame://payment-cancel?order=123"
|
|
1204
|
+
*/
|
|
1205
|
+
declare function generateDeepLinkCheckout(options: MobileCheckoutOptions, appScheme: string, baseUrl?: string): string;
|
|
1206
|
+
/**
|
|
1207
|
+
* Parse the callback URL when user returns to app
|
|
1208
|
+
*
|
|
1209
|
+
* Usage in Swift:
|
|
1210
|
+
* ```swift
|
|
1211
|
+
* func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
1212
|
+
* if url.scheme == "mygame" && url.host == "payment-success" {
|
|
1213
|
+
* let signature = URLComponents(url: url, resolvingAgainstBaseURL: true)?
|
|
1214
|
+
* .queryItems?.first(where: { $0.name == "signature" })?.value
|
|
1215
|
+
* // Handle success
|
|
1216
|
+
* }
|
|
1217
|
+
* }
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
declare function parseCallbackUrl(url: string): MobileCheckoutResult;
|
|
1221
|
+
/**
|
|
1222
|
+
* REST API endpoint info for server-side integration
|
|
1223
|
+
*
|
|
1224
|
+
* Mobile games can use these APIs directly without the SDK:
|
|
1225
|
+
*
|
|
1226
|
+
* 1. Create checkout session:
|
|
1227
|
+
* POST /api/checkout/create
|
|
1228
|
+
* { amount, merchantWallet, memo }
|
|
1229
|
+
* → { sessionId, checkoutUrl }
|
|
1230
|
+
*
|
|
1231
|
+
* 2. Check payment status:
|
|
1232
|
+
* GET /api/checkout/status?session={sessionId}
|
|
1233
|
+
* → { status: 'pending' | 'completed' | 'expired', signature? }
|
|
1234
|
+
*
|
|
1235
|
+
* 3. One-click payment (for returning players):
|
|
1236
|
+
* POST /api/one-click
|
|
1237
|
+
* { action: 'charge', customerWallet, merchantWallet, amount }
|
|
1238
|
+
* → { success, signature }
|
|
1239
|
+
*/
|
|
1240
|
+
declare const REST_API: {
|
|
1241
|
+
createSession: string;
|
|
1242
|
+
checkStatus: string;
|
|
1243
|
+
oneClick: string;
|
|
1244
|
+
webhook: string;
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Example Unity C# integration code
|
|
1248
|
+
* (For documentation purposes)
|
|
1249
|
+
*/
|
|
1250
|
+
declare const UNITY_EXAMPLE = "\n// SettlrPayment.cs - Drop into your Unity project\n\nusing UnityEngine;\nusing UnityEngine.Networking;\nusing System.Collections;\n\npublic class SettlrPayment : MonoBehaviour\n{\n public string merchantWallet = \"YOUR_WALLET_ADDRESS\";\n public string settlrUrl = \"https://settlr.dev\";\n \n // Call this to start a payment\n public void StartPayment(float amount, string orderId, System.Action<bool, string> callback)\n {\n string url = $\"{settlrUrl}/checkout?amount={amount}&merchant={merchantWallet}&order_id={orderId}\";\n \n // Add deep link callback (register mygame:// scheme in your app)\n url += $\"&success_url=mygame://payment-success?order={orderId}\";\n url += $\"&cancel_url=mygame://payment-cancel?order={orderId}\";\n \n Application.OpenURL(url);\n \n // Start polling for completion\n StartCoroutine(PollPaymentStatus(orderId, callback));\n }\n \n IEnumerator PollPaymentStatus(string orderId, System.Action<bool, string> callback)\n {\n string statusUrl = $\"{settlrUrl}/api/checkout/status?order_id={orderId}\";\n \n for (int i = 0; i < 60; i++) // Poll for 5 minutes\n {\n using (UnityWebRequest request = UnityWebRequest.Get(statusUrl))\n {\n yield return request.SendWebRequest();\n \n if (request.result == UnityWebRequest.Result.Success)\n {\n var response = JsonUtility.FromJson<PaymentStatusResponse>(request.downloadHandler.text);\n \n if (response.status == \"completed\")\n {\n callback(true, response.signature);\n yield break;\n }\n else if (response.status == \"expired\" || response.status == \"cancelled\")\n {\n callback(false, null);\n yield break;\n }\n }\n }\n \n yield return new WaitForSeconds(5f); // Check every 5 seconds\n }\n \n callback(false, \"Timeout\");\n }\n \n [System.Serializable]\n class PaymentStatusResponse\n {\n public string status;\n public string signature;\n }\n}\n";
|
|
1251
|
+
/**
|
|
1252
|
+
* Example React Native integration
|
|
1253
|
+
*/
|
|
1254
|
+
declare const REACT_NATIVE_EXAMPLE = "\n// SettlrPayment.tsx - React Native component\n\nimport { Linking, Alert } from 'react-native';\nimport { useEffect } from 'react';\n\nconst SETTLR_URL = 'https://settlr.dev';\nconst APP_SCHEME = 'mygame';\n\nexport function useSettlrPayment(onSuccess: (sig: string) => void) {\n useEffect(() => {\n const handleDeepLink = ({ url }: { url: string }) => {\n if (url.includes('payment-success')) {\n const sig = new URL(url).searchParams.get('signature');\n if (sig) onSuccess(sig);\n }\n };\n \n Linking.addEventListener('url', handleDeepLink);\n return () => Linking.removeAllListeners('url');\n }, [onSuccess]);\n \n const startPayment = async (amount: number, merchantWallet: string) => {\n const orderId = `order_${Date.now()}`;\n const url = `${SETTLR_URL}/checkout?amount=${amount}&merchant=${merchantWallet}` +\n `&success_url=${APP_SCHEME}://payment-success?order=${orderId}` +\n `&cancel_url=${APP_SCHEME}://payment-cancel?order=${orderId}`;\n \n await Linking.openURL(url);\n };\n \n return { startPayment };\n}\n";
|
|
1255
|
+
|
|
1256
|
+
export { type ApproveOneClickOptions, BuyButton, type BuyButtonProps, type ChargeOneClickOptions, CheckoutWidget, type CheckoutWidgetProps, type CreatePaymentOptions, type CreateSubscriptionOptions, INCO_LIGHTNING_PROGRAM_ID, type IssuePrivateReceiptResult, type MerchantConfig, type MobileCheckoutOptions, type MobileCheckoutResult, OneClickClient, type OneClickResult, type Payment, PaymentModal, type PaymentModalProps, type PaymentResult, type PaymentStatus, PrivacyFeatures, type PrivateReceiptConfig, REACT_NATIVE_EXAMPLE, REST_API, SETTLR_CHECKOUT_URL, SETTLR_PROGRAM_ID, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, Settlr, type SettlrConfig, SettlrProvider, type SpendingApproval, type Subscription, type SubscriptionInterval, type SubscriptionPlan, type SubscriptionStatus, type SupportedToken, type TransactionOptions, UNITY_EXAMPLE, USDC_MINT_DEVNET, USDC_MINT_MAINNET, USDT_MINT_DEVNET, USDT_MINT_MAINNET, type WebhookEventType, type WebhookHandler, type WebhookHandlers, type WebhookPayload, buildAllowanceRemainingAccounts, buildPrivateReceiptAccounts, createOneClickClient, createWebhookHandler, encryptAmount, findAllowancePda, findPrivateReceiptPda, formatUSDC, generateCheckoutUrl, generateDeepLinkCheckout, getTokenDecimals, getTokenMint, parseCallbackUrl, parseUSDC, parseWebhookPayload, shortenAddress, simulateAndGetHandle, usePaymentLink, usePaymentModal, useSettlr, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1143,4 +1143,114 @@ declare class OneClickClient {
|
|
|
1143
1143
|
*/
|
|
1144
1144
|
declare function createOneClickClient(baseUrl?: string): OneClickClient;
|
|
1145
1145
|
|
|
1146
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* Mobile Game Integration Utilities
|
|
1148
|
+
*
|
|
1149
|
+
* Simple helpers for integrating Settlr payments in mobile games.
|
|
1150
|
+
* Works with Unity, Unreal, native iOS/Android, React Native, etc.
|
|
1151
|
+
*
|
|
1152
|
+
* The simplest integration is URL-based - just open the checkout URL
|
|
1153
|
+
* and listen for the callback.
|
|
1154
|
+
*/
|
|
1155
|
+
interface MobileCheckoutOptions {
|
|
1156
|
+
/** Amount in USDC */
|
|
1157
|
+
amount: number;
|
|
1158
|
+
/** Merchant wallet address */
|
|
1159
|
+
merchantWallet: string;
|
|
1160
|
+
/** Optional: Merchant display name */
|
|
1161
|
+
merchantName?: string;
|
|
1162
|
+
/** Optional: Payment description */
|
|
1163
|
+
memo?: string;
|
|
1164
|
+
/** URL to redirect after success */
|
|
1165
|
+
successUrl?: string;
|
|
1166
|
+
/** URL to redirect on cancel */
|
|
1167
|
+
cancelUrl?: string;
|
|
1168
|
+
/** Optional: Your order/transaction ID */
|
|
1169
|
+
orderId?: string;
|
|
1170
|
+
/** Optional: Customer ID for one-click */
|
|
1171
|
+
customerId?: string;
|
|
1172
|
+
}
|
|
1173
|
+
interface MobileCheckoutResult {
|
|
1174
|
+
success: boolean;
|
|
1175
|
+
signature?: string;
|
|
1176
|
+
orderId?: string;
|
|
1177
|
+
error?: string;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Generate a checkout URL for mobile games
|
|
1181
|
+
*
|
|
1182
|
+
* Usage in Unity (C#):
|
|
1183
|
+
* ```csharp
|
|
1184
|
+
* string url = $"https://settlr.dev/checkout?amount={amount}&merchant={wallet}";
|
|
1185
|
+
* Application.OpenURL(url);
|
|
1186
|
+
* ```
|
|
1187
|
+
*
|
|
1188
|
+
* Usage in Swift:
|
|
1189
|
+
* ```swift
|
|
1190
|
+
* let url = "https://settlr.dev/checkout?amount=\(amount)&merchant=\(wallet)"
|
|
1191
|
+
* UIApplication.shared.open(URL(string: url)!)
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
declare function generateCheckoutUrl(options: MobileCheckoutOptions, baseUrl?: string): string;
|
|
1195
|
+
/**
|
|
1196
|
+
* Generate a deep link for mobile app integration
|
|
1197
|
+
*
|
|
1198
|
+
* For apps that register a custom URL scheme (e.g., mygame://)
|
|
1199
|
+
* the success/cancel URLs can redirect back to the app.
|
|
1200
|
+
*
|
|
1201
|
+
* Example:
|
|
1202
|
+
* - successUrl: "mygame://payment-success?order=123"
|
|
1203
|
+
* - cancelUrl: "mygame://payment-cancel?order=123"
|
|
1204
|
+
*/
|
|
1205
|
+
declare function generateDeepLinkCheckout(options: MobileCheckoutOptions, appScheme: string, baseUrl?: string): string;
|
|
1206
|
+
/**
|
|
1207
|
+
* Parse the callback URL when user returns to app
|
|
1208
|
+
*
|
|
1209
|
+
* Usage in Swift:
|
|
1210
|
+
* ```swift
|
|
1211
|
+
* func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
1212
|
+
* if url.scheme == "mygame" && url.host == "payment-success" {
|
|
1213
|
+
* let signature = URLComponents(url: url, resolvingAgainstBaseURL: true)?
|
|
1214
|
+
* .queryItems?.first(where: { $0.name == "signature" })?.value
|
|
1215
|
+
* // Handle success
|
|
1216
|
+
* }
|
|
1217
|
+
* }
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
declare function parseCallbackUrl(url: string): MobileCheckoutResult;
|
|
1221
|
+
/**
|
|
1222
|
+
* REST API endpoint info for server-side integration
|
|
1223
|
+
*
|
|
1224
|
+
* Mobile games can use these APIs directly without the SDK:
|
|
1225
|
+
*
|
|
1226
|
+
* 1. Create checkout session:
|
|
1227
|
+
* POST /api/checkout/create
|
|
1228
|
+
* { amount, merchantWallet, memo }
|
|
1229
|
+
* → { sessionId, checkoutUrl }
|
|
1230
|
+
*
|
|
1231
|
+
* 2. Check payment status:
|
|
1232
|
+
* GET /api/checkout/status?session={sessionId}
|
|
1233
|
+
* → { status: 'pending' | 'completed' | 'expired', signature? }
|
|
1234
|
+
*
|
|
1235
|
+
* 3. One-click payment (for returning players):
|
|
1236
|
+
* POST /api/one-click
|
|
1237
|
+
* { action: 'charge', customerWallet, merchantWallet, amount }
|
|
1238
|
+
* → { success, signature }
|
|
1239
|
+
*/
|
|
1240
|
+
declare const REST_API: {
|
|
1241
|
+
createSession: string;
|
|
1242
|
+
checkStatus: string;
|
|
1243
|
+
oneClick: string;
|
|
1244
|
+
webhook: string;
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Example Unity C# integration code
|
|
1248
|
+
* (For documentation purposes)
|
|
1249
|
+
*/
|
|
1250
|
+
declare const UNITY_EXAMPLE = "\n// SettlrPayment.cs - Drop into your Unity project\n\nusing UnityEngine;\nusing UnityEngine.Networking;\nusing System.Collections;\n\npublic class SettlrPayment : MonoBehaviour\n{\n public string merchantWallet = \"YOUR_WALLET_ADDRESS\";\n public string settlrUrl = \"https://settlr.dev\";\n \n // Call this to start a payment\n public void StartPayment(float amount, string orderId, System.Action<bool, string> callback)\n {\n string url = $\"{settlrUrl}/checkout?amount={amount}&merchant={merchantWallet}&order_id={orderId}\";\n \n // Add deep link callback (register mygame:// scheme in your app)\n url += $\"&success_url=mygame://payment-success?order={orderId}\";\n url += $\"&cancel_url=mygame://payment-cancel?order={orderId}\";\n \n Application.OpenURL(url);\n \n // Start polling for completion\n StartCoroutine(PollPaymentStatus(orderId, callback));\n }\n \n IEnumerator PollPaymentStatus(string orderId, System.Action<bool, string> callback)\n {\n string statusUrl = $\"{settlrUrl}/api/checkout/status?order_id={orderId}\";\n \n for (int i = 0; i < 60; i++) // Poll for 5 minutes\n {\n using (UnityWebRequest request = UnityWebRequest.Get(statusUrl))\n {\n yield return request.SendWebRequest();\n \n if (request.result == UnityWebRequest.Result.Success)\n {\n var response = JsonUtility.FromJson<PaymentStatusResponse>(request.downloadHandler.text);\n \n if (response.status == \"completed\")\n {\n callback(true, response.signature);\n yield break;\n }\n else if (response.status == \"expired\" || response.status == \"cancelled\")\n {\n callback(false, null);\n yield break;\n }\n }\n }\n \n yield return new WaitForSeconds(5f); // Check every 5 seconds\n }\n \n callback(false, \"Timeout\");\n }\n \n [System.Serializable]\n class PaymentStatusResponse\n {\n public string status;\n public string signature;\n }\n}\n";
|
|
1251
|
+
/**
|
|
1252
|
+
* Example React Native integration
|
|
1253
|
+
*/
|
|
1254
|
+
declare const REACT_NATIVE_EXAMPLE = "\n// SettlrPayment.tsx - React Native component\n\nimport { Linking, Alert } from 'react-native';\nimport { useEffect } from 'react';\n\nconst SETTLR_URL = 'https://settlr.dev';\nconst APP_SCHEME = 'mygame';\n\nexport function useSettlrPayment(onSuccess: (sig: string) => void) {\n useEffect(() => {\n const handleDeepLink = ({ url }: { url: string }) => {\n if (url.includes('payment-success')) {\n const sig = new URL(url).searchParams.get('signature');\n if (sig) onSuccess(sig);\n }\n };\n \n Linking.addEventListener('url', handleDeepLink);\n return () => Linking.removeAllListeners('url');\n }, [onSuccess]);\n \n const startPayment = async (amount: number, merchantWallet: string) => {\n const orderId = `order_${Date.now()}`;\n const url = `${SETTLR_URL}/checkout?amount=${amount}&merchant=${merchantWallet}` +\n `&success_url=${APP_SCHEME}://payment-success?order=${orderId}` +\n `&cancel_url=${APP_SCHEME}://payment-cancel?order=${orderId}`;\n \n await Linking.openURL(url);\n };\n \n return { startPayment };\n}\n";
|
|
1255
|
+
|
|
1256
|
+
export { type ApproveOneClickOptions, BuyButton, type BuyButtonProps, type ChargeOneClickOptions, CheckoutWidget, type CheckoutWidgetProps, type CreatePaymentOptions, type CreateSubscriptionOptions, INCO_LIGHTNING_PROGRAM_ID, type IssuePrivateReceiptResult, type MerchantConfig, type MobileCheckoutOptions, type MobileCheckoutResult, OneClickClient, type OneClickResult, type Payment, PaymentModal, type PaymentModalProps, type PaymentResult, type PaymentStatus, PrivacyFeatures, type PrivateReceiptConfig, REACT_NATIVE_EXAMPLE, REST_API, SETTLR_CHECKOUT_URL, SETTLR_PROGRAM_ID, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, Settlr, type SettlrConfig, SettlrProvider, type SpendingApproval, type Subscription, type SubscriptionInterval, type SubscriptionPlan, type SubscriptionStatus, type SupportedToken, type TransactionOptions, UNITY_EXAMPLE, USDC_MINT_DEVNET, USDC_MINT_MAINNET, USDT_MINT_DEVNET, USDT_MINT_MAINNET, type WebhookEventType, type WebhookHandler, type WebhookHandlers, type WebhookPayload, buildAllowanceRemainingAccounts, buildPrivateReceiptAccounts, createOneClickClient, createWebhookHandler, encryptAmount, findAllowancePda, findPrivateReceiptPda, formatUSDC, generateCheckoutUrl, generateDeepLinkCheckout, getTokenDecimals, getTokenMint, parseCallbackUrl, parseUSDC, parseWebhookPayload, shortenAddress, simulateAndGetHandle, usePaymentLink, usePaymentModal, useSettlr, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -36,12 +36,15 @@ __export(index_exports, {
|
|
|
36
36
|
OneClickClient: () => OneClickClient,
|
|
37
37
|
PaymentModal: () => PaymentModal,
|
|
38
38
|
PrivacyFeatures: () => PrivacyFeatures,
|
|
39
|
+
REACT_NATIVE_EXAMPLE: () => REACT_NATIVE_EXAMPLE,
|
|
40
|
+
REST_API: () => REST_API,
|
|
39
41
|
SETTLR_CHECKOUT_URL: () => SETTLR_CHECKOUT_URL,
|
|
40
42
|
SETTLR_PROGRAM_ID: () => SETTLR_PROGRAM_ID,
|
|
41
43
|
SUPPORTED_NETWORKS: () => SUPPORTED_NETWORKS,
|
|
42
44
|
SUPPORTED_TOKENS: () => SUPPORTED_TOKENS,
|
|
43
45
|
Settlr: () => Settlr,
|
|
44
46
|
SettlrProvider: () => SettlrProvider,
|
|
47
|
+
UNITY_EXAMPLE: () => UNITY_EXAMPLE,
|
|
45
48
|
USDC_MINT_DEVNET: () => USDC_MINT_DEVNET,
|
|
46
49
|
USDC_MINT_MAINNET: () => USDC_MINT_MAINNET,
|
|
47
50
|
USDT_MINT_DEVNET: () => USDT_MINT_DEVNET,
|
|
@@ -54,8 +57,11 @@ __export(index_exports, {
|
|
|
54
57
|
findAllowancePda: () => findAllowancePda,
|
|
55
58
|
findPrivateReceiptPda: () => findPrivateReceiptPda,
|
|
56
59
|
formatUSDC: () => formatUSDC,
|
|
60
|
+
generateCheckoutUrl: () => generateCheckoutUrl,
|
|
61
|
+
generateDeepLinkCheckout: () => generateDeepLinkCheckout,
|
|
57
62
|
getTokenDecimals: () => getTokenDecimals,
|
|
58
63
|
getTokenMint: () => getTokenMint,
|
|
64
|
+
parseCallbackUrl: () => parseCallbackUrl,
|
|
59
65
|
parseUSDC: () => parseUSDC,
|
|
60
66
|
parseWebhookPayload: () => parseWebhookPayload,
|
|
61
67
|
shortenAddress: () => shortenAddress,
|
|
@@ -1426,6 +1432,167 @@ var OneClickClient = class {
|
|
|
1426
1432
|
function createOneClickClient(baseUrl) {
|
|
1427
1433
|
return new OneClickClient(baseUrl);
|
|
1428
1434
|
}
|
|
1435
|
+
|
|
1436
|
+
// src/mobile.ts
|
|
1437
|
+
function generateCheckoutUrl(options, baseUrl = "https://settlr.dev") {
|
|
1438
|
+
const params = new URLSearchParams();
|
|
1439
|
+
params.set("amount", options.amount.toString());
|
|
1440
|
+
params.set("merchant", options.merchantWallet);
|
|
1441
|
+
if (options.merchantName) params.set("name", options.merchantName);
|
|
1442
|
+
if (options.memo) params.set("memo", options.memo);
|
|
1443
|
+
if (options.successUrl) params.set("success_url", options.successUrl);
|
|
1444
|
+
if (options.cancelUrl) params.set("cancel_url", options.cancelUrl);
|
|
1445
|
+
if (options.orderId) params.set("order_id", options.orderId);
|
|
1446
|
+
if (options.customerId) params.set("customer_id", options.customerId);
|
|
1447
|
+
return `${baseUrl}/checkout?${params.toString()}`;
|
|
1448
|
+
}
|
|
1449
|
+
function generateDeepLinkCheckout(options, appScheme, baseUrl = "https://settlr.dev") {
|
|
1450
|
+
const orderId = options.orderId || `order_${Date.now()}`;
|
|
1451
|
+
return generateCheckoutUrl({
|
|
1452
|
+
...options,
|
|
1453
|
+
orderId,
|
|
1454
|
+
successUrl: `${appScheme}://payment-success?order=${orderId}`,
|
|
1455
|
+
cancelUrl: `${appScheme}://payment-cancel?order=${orderId}`
|
|
1456
|
+
}, baseUrl);
|
|
1457
|
+
}
|
|
1458
|
+
function parseCallbackUrl(url) {
|
|
1459
|
+
try {
|
|
1460
|
+
const parsed = new URL(url);
|
|
1461
|
+
const params = parsed.searchParams;
|
|
1462
|
+
if (parsed.host === "payment-success" || parsed.pathname.includes("success")) {
|
|
1463
|
+
return {
|
|
1464
|
+
success: true,
|
|
1465
|
+
signature: params.get("signature") || void 0,
|
|
1466
|
+
orderId: params.get("order") || params.get("order_id") || void 0
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
if (parsed.host === "payment-cancel" || parsed.pathname.includes("cancel")) {
|
|
1470
|
+
return {
|
|
1471
|
+
success: false,
|
|
1472
|
+
orderId: params.get("order") || params.get("order_id") || void 0,
|
|
1473
|
+
error: "Payment cancelled by user"
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
return {
|
|
1477
|
+
success: false,
|
|
1478
|
+
error: "Unknown callback URL format"
|
|
1479
|
+
};
|
|
1480
|
+
} catch {
|
|
1481
|
+
return {
|
|
1482
|
+
success: false,
|
|
1483
|
+
error: "Failed to parse callback URL"
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
var REST_API = {
|
|
1488
|
+
createSession: "/api/checkout/create",
|
|
1489
|
+
checkStatus: "/api/checkout/status",
|
|
1490
|
+
oneClick: "/api/one-click",
|
|
1491
|
+
webhook: "/api/webhooks"
|
|
1492
|
+
// For server-to-server notifications
|
|
1493
|
+
};
|
|
1494
|
+
var UNITY_EXAMPLE = `
|
|
1495
|
+
// SettlrPayment.cs - Drop into your Unity project
|
|
1496
|
+
|
|
1497
|
+
using UnityEngine;
|
|
1498
|
+
using UnityEngine.Networking;
|
|
1499
|
+
using System.Collections;
|
|
1500
|
+
|
|
1501
|
+
public class SettlrPayment : MonoBehaviour
|
|
1502
|
+
{
|
|
1503
|
+
public string merchantWallet = "YOUR_WALLET_ADDRESS";
|
|
1504
|
+
public string settlrUrl = "https://settlr.dev";
|
|
1505
|
+
|
|
1506
|
+
// Call this to start a payment
|
|
1507
|
+
public void StartPayment(float amount, string orderId, System.Action<bool, string> callback)
|
|
1508
|
+
{
|
|
1509
|
+
string url = $"{settlrUrl}/checkout?amount={amount}&merchant={merchantWallet}&order_id={orderId}";
|
|
1510
|
+
|
|
1511
|
+
// Add deep link callback (register mygame:// scheme in your app)
|
|
1512
|
+
url += $"&success_url=mygame://payment-success?order={orderId}";
|
|
1513
|
+
url += $"&cancel_url=mygame://payment-cancel?order={orderId}";
|
|
1514
|
+
|
|
1515
|
+
Application.OpenURL(url);
|
|
1516
|
+
|
|
1517
|
+
// Start polling for completion
|
|
1518
|
+
StartCoroutine(PollPaymentStatus(orderId, callback));
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
IEnumerator PollPaymentStatus(string orderId, System.Action<bool, string> callback)
|
|
1522
|
+
{
|
|
1523
|
+
string statusUrl = $"{settlrUrl}/api/checkout/status?order_id={orderId}";
|
|
1524
|
+
|
|
1525
|
+
for (int i = 0; i < 60; i++) // Poll for 5 minutes
|
|
1526
|
+
{
|
|
1527
|
+
using (UnityWebRequest request = UnityWebRequest.Get(statusUrl))
|
|
1528
|
+
{
|
|
1529
|
+
yield return request.SendWebRequest();
|
|
1530
|
+
|
|
1531
|
+
if (request.result == UnityWebRequest.Result.Success)
|
|
1532
|
+
{
|
|
1533
|
+
var response = JsonUtility.FromJson<PaymentStatusResponse>(request.downloadHandler.text);
|
|
1534
|
+
|
|
1535
|
+
if (response.status == "completed")
|
|
1536
|
+
{
|
|
1537
|
+
callback(true, response.signature);
|
|
1538
|
+
yield break;
|
|
1539
|
+
}
|
|
1540
|
+
else if (response.status == "expired" || response.status == "cancelled")
|
|
1541
|
+
{
|
|
1542
|
+
callback(false, null);
|
|
1543
|
+
yield break;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
yield return new WaitForSeconds(5f); // Check every 5 seconds
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
callback(false, "Timeout");
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
[System.Serializable]
|
|
1555
|
+
class PaymentStatusResponse
|
|
1556
|
+
{
|
|
1557
|
+
public string status;
|
|
1558
|
+
public string signature;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
`;
|
|
1562
|
+
var REACT_NATIVE_EXAMPLE = `
|
|
1563
|
+
// SettlrPayment.tsx - React Native component
|
|
1564
|
+
|
|
1565
|
+
import { Linking, Alert } from 'react-native';
|
|
1566
|
+
import { useEffect } from 'react';
|
|
1567
|
+
|
|
1568
|
+
const SETTLR_URL = 'https://settlr.dev';
|
|
1569
|
+
const APP_SCHEME = 'mygame';
|
|
1570
|
+
|
|
1571
|
+
export function useSettlrPayment(onSuccess: (sig: string) => void) {
|
|
1572
|
+
useEffect(() => {
|
|
1573
|
+
const handleDeepLink = ({ url }: { url: string }) => {
|
|
1574
|
+
if (url.includes('payment-success')) {
|
|
1575
|
+
const sig = new URL(url).searchParams.get('signature');
|
|
1576
|
+
if (sig) onSuccess(sig);
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
Linking.addEventListener('url', handleDeepLink);
|
|
1581
|
+
return () => Linking.removeAllListeners('url');
|
|
1582
|
+
}, [onSuccess]);
|
|
1583
|
+
|
|
1584
|
+
const startPayment = async (amount: number, merchantWallet: string) => {
|
|
1585
|
+
const orderId = \`order_\${Date.now()}\`;
|
|
1586
|
+
const url = \`\${SETTLR_URL}/checkout?amount=\${amount}&merchant=\${merchantWallet}\` +
|
|
1587
|
+
\`&success_url=\${APP_SCHEME}://payment-success?order=\${orderId}\` +
|
|
1588
|
+
\`&cancel_url=\${APP_SCHEME}://payment-cancel?order=\${orderId}\`;
|
|
1589
|
+
|
|
1590
|
+
await Linking.openURL(url);
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
return { startPayment };
|
|
1594
|
+
}
|
|
1595
|
+
`;
|
|
1429
1596
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1430
1597
|
0 && (module.exports = {
|
|
1431
1598
|
BuyButton,
|
|
@@ -1434,12 +1601,15 @@ function createOneClickClient(baseUrl) {
|
|
|
1434
1601
|
OneClickClient,
|
|
1435
1602
|
PaymentModal,
|
|
1436
1603
|
PrivacyFeatures,
|
|
1604
|
+
REACT_NATIVE_EXAMPLE,
|
|
1605
|
+
REST_API,
|
|
1437
1606
|
SETTLR_CHECKOUT_URL,
|
|
1438
1607
|
SETTLR_PROGRAM_ID,
|
|
1439
1608
|
SUPPORTED_NETWORKS,
|
|
1440
1609
|
SUPPORTED_TOKENS,
|
|
1441
1610
|
Settlr,
|
|
1442
1611
|
SettlrProvider,
|
|
1612
|
+
UNITY_EXAMPLE,
|
|
1443
1613
|
USDC_MINT_DEVNET,
|
|
1444
1614
|
USDC_MINT_MAINNET,
|
|
1445
1615
|
USDT_MINT_DEVNET,
|
|
@@ -1452,8 +1622,11 @@ function createOneClickClient(baseUrl) {
|
|
|
1452
1622
|
findAllowancePda,
|
|
1453
1623
|
findPrivateReceiptPda,
|
|
1454
1624
|
formatUSDC,
|
|
1625
|
+
generateCheckoutUrl,
|
|
1626
|
+
generateDeepLinkCheckout,
|
|
1455
1627
|
getTokenDecimals,
|
|
1456
1628
|
getTokenMint,
|
|
1629
|
+
parseCallbackUrl,
|
|
1457
1630
|
parseUSDC,
|
|
1458
1631
|
parseWebhookPayload,
|
|
1459
1632
|
shortenAddress,
|
package/dist/index.mjs
CHANGED
|
@@ -1372,6 +1372,167 @@ var OneClickClient = class {
|
|
|
1372
1372
|
function createOneClickClient(baseUrl) {
|
|
1373
1373
|
return new OneClickClient(baseUrl);
|
|
1374
1374
|
}
|
|
1375
|
+
|
|
1376
|
+
// src/mobile.ts
|
|
1377
|
+
function generateCheckoutUrl(options, baseUrl = "https://settlr.dev") {
|
|
1378
|
+
const params = new URLSearchParams();
|
|
1379
|
+
params.set("amount", options.amount.toString());
|
|
1380
|
+
params.set("merchant", options.merchantWallet);
|
|
1381
|
+
if (options.merchantName) params.set("name", options.merchantName);
|
|
1382
|
+
if (options.memo) params.set("memo", options.memo);
|
|
1383
|
+
if (options.successUrl) params.set("success_url", options.successUrl);
|
|
1384
|
+
if (options.cancelUrl) params.set("cancel_url", options.cancelUrl);
|
|
1385
|
+
if (options.orderId) params.set("order_id", options.orderId);
|
|
1386
|
+
if (options.customerId) params.set("customer_id", options.customerId);
|
|
1387
|
+
return `${baseUrl}/checkout?${params.toString()}`;
|
|
1388
|
+
}
|
|
1389
|
+
function generateDeepLinkCheckout(options, appScheme, baseUrl = "https://settlr.dev") {
|
|
1390
|
+
const orderId = options.orderId || `order_${Date.now()}`;
|
|
1391
|
+
return generateCheckoutUrl({
|
|
1392
|
+
...options,
|
|
1393
|
+
orderId,
|
|
1394
|
+
successUrl: `${appScheme}://payment-success?order=${orderId}`,
|
|
1395
|
+
cancelUrl: `${appScheme}://payment-cancel?order=${orderId}`
|
|
1396
|
+
}, baseUrl);
|
|
1397
|
+
}
|
|
1398
|
+
function parseCallbackUrl(url) {
|
|
1399
|
+
try {
|
|
1400
|
+
const parsed = new URL(url);
|
|
1401
|
+
const params = parsed.searchParams;
|
|
1402
|
+
if (parsed.host === "payment-success" || parsed.pathname.includes("success")) {
|
|
1403
|
+
return {
|
|
1404
|
+
success: true,
|
|
1405
|
+
signature: params.get("signature") || void 0,
|
|
1406
|
+
orderId: params.get("order") || params.get("order_id") || void 0
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
if (parsed.host === "payment-cancel" || parsed.pathname.includes("cancel")) {
|
|
1410
|
+
return {
|
|
1411
|
+
success: false,
|
|
1412
|
+
orderId: params.get("order") || params.get("order_id") || void 0,
|
|
1413
|
+
error: "Payment cancelled by user"
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
return {
|
|
1417
|
+
success: false,
|
|
1418
|
+
error: "Unknown callback URL format"
|
|
1419
|
+
};
|
|
1420
|
+
} catch {
|
|
1421
|
+
return {
|
|
1422
|
+
success: false,
|
|
1423
|
+
error: "Failed to parse callback URL"
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
var REST_API = {
|
|
1428
|
+
createSession: "/api/checkout/create",
|
|
1429
|
+
checkStatus: "/api/checkout/status",
|
|
1430
|
+
oneClick: "/api/one-click",
|
|
1431
|
+
webhook: "/api/webhooks"
|
|
1432
|
+
// For server-to-server notifications
|
|
1433
|
+
};
|
|
1434
|
+
var UNITY_EXAMPLE = `
|
|
1435
|
+
// SettlrPayment.cs - Drop into your Unity project
|
|
1436
|
+
|
|
1437
|
+
using UnityEngine;
|
|
1438
|
+
using UnityEngine.Networking;
|
|
1439
|
+
using System.Collections;
|
|
1440
|
+
|
|
1441
|
+
public class SettlrPayment : MonoBehaviour
|
|
1442
|
+
{
|
|
1443
|
+
public string merchantWallet = "YOUR_WALLET_ADDRESS";
|
|
1444
|
+
public string settlrUrl = "https://settlr.dev";
|
|
1445
|
+
|
|
1446
|
+
// Call this to start a payment
|
|
1447
|
+
public void StartPayment(float amount, string orderId, System.Action<bool, string> callback)
|
|
1448
|
+
{
|
|
1449
|
+
string url = $"{settlrUrl}/checkout?amount={amount}&merchant={merchantWallet}&order_id={orderId}";
|
|
1450
|
+
|
|
1451
|
+
// Add deep link callback (register mygame:// scheme in your app)
|
|
1452
|
+
url += $"&success_url=mygame://payment-success?order={orderId}";
|
|
1453
|
+
url += $"&cancel_url=mygame://payment-cancel?order={orderId}";
|
|
1454
|
+
|
|
1455
|
+
Application.OpenURL(url);
|
|
1456
|
+
|
|
1457
|
+
// Start polling for completion
|
|
1458
|
+
StartCoroutine(PollPaymentStatus(orderId, callback));
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
IEnumerator PollPaymentStatus(string orderId, System.Action<bool, string> callback)
|
|
1462
|
+
{
|
|
1463
|
+
string statusUrl = $"{settlrUrl}/api/checkout/status?order_id={orderId}";
|
|
1464
|
+
|
|
1465
|
+
for (int i = 0; i < 60; i++) // Poll for 5 minutes
|
|
1466
|
+
{
|
|
1467
|
+
using (UnityWebRequest request = UnityWebRequest.Get(statusUrl))
|
|
1468
|
+
{
|
|
1469
|
+
yield return request.SendWebRequest();
|
|
1470
|
+
|
|
1471
|
+
if (request.result == UnityWebRequest.Result.Success)
|
|
1472
|
+
{
|
|
1473
|
+
var response = JsonUtility.FromJson<PaymentStatusResponse>(request.downloadHandler.text);
|
|
1474
|
+
|
|
1475
|
+
if (response.status == "completed")
|
|
1476
|
+
{
|
|
1477
|
+
callback(true, response.signature);
|
|
1478
|
+
yield break;
|
|
1479
|
+
}
|
|
1480
|
+
else if (response.status == "expired" || response.status == "cancelled")
|
|
1481
|
+
{
|
|
1482
|
+
callback(false, null);
|
|
1483
|
+
yield break;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
yield return new WaitForSeconds(5f); // Check every 5 seconds
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
callback(false, "Timeout");
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
[System.Serializable]
|
|
1495
|
+
class PaymentStatusResponse
|
|
1496
|
+
{
|
|
1497
|
+
public string status;
|
|
1498
|
+
public string signature;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
`;
|
|
1502
|
+
var REACT_NATIVE_EXAMPLE = `
|
|
1503
|
+
// SettlrPayment.tsx - React Native component
|
|
1504
|
+
|
|
1505
|
+
import { Linking, Alert } from 'react-native';
|
|
1506
|
+
import { useEffect } from 'react';
|
|
1507
|
+
|
|
1508
|
+
const SETTLR_URL = 'https://settlr.dev';
|
|
1509
|
+
const APP_SCHEME = 'mygame';
|
|
1510
|
+
|
|
1511
|
+
export function useSettlrPayment(onSuccess: (sig: string) => void) {
|
|
1512
|
+
useEffect(() => {
|
|
1513
|
+
const handleDeepLink = ({ url }: { url: string }) => {
|
|
1514
|
+
if (url.includes('payment-success')) {
|
|
1515
|
+
const sig = new URL(url).searchParams.get('signature');
|
|
1516
|
+
if (sig) onSuccess(sig);
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
Linking.addEventListener('url', handleDeepLink);
|
|
1521
|
+
return () => Linking.removeAllListeners('url');
|
|
1522
|
+
}, [onSuccess]);
|
|
1523
|
+
|
|
1524
|
+
const startPayment = async (amount: number, merchantWallet: string) => {
|
|
1525
|
+
const orderId = \`order_\${Date.now()}\`;
|
|
1526
|
+
const url = \`\${SETTLR_URL}/checkout?amount=\${amount}&merchant=\${merchantWallet}\` +
|
|
1527
|
+
\`&success_url=\${APP_SCHEME}://payment-success?order=\${orderId}\` +
|
|
1528
|
+
\`&cancel_url=\${APP_SCHEME}://payment-cancel?order=\${orderId}\`;
|
|
1529
|
+
|
|
1530
|
+
await Linking.openURL(url);
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
return { startPayment };
|
|
1534
|
+
}
|
|
1535
|
+
`;
|
|
1375
1536
|
export {
|
|
1376
1537
|
BuyButton,
|
|
1377
1538
|
CheckoutWidget,
|
|
@@ -1379,12 +1540,15 @@ export {
|
|
|
1379
1540
|
OneClickClient,
|
|
1380
1541
|
PaymentModal,
|
|
1381
1542
|
PrivacyFeatures,
|
|
1543
|
+
REACT_NATIVE_EXAMPLE,
|
|
1544
|
+
REST_API,
|
|
1382
1545
|
SETTLR_CHECKOUT_URL,
|
|
1383
1546
|
SETTLR_PROGRAM_ID,
|
|
1384
1547
|
SUPPORTED_NETWORKS,
|
|
1385
1548
|
SUPPORTED_TOKENS,
|
|
1386
1549
|
Settlr,
|
|
1387
1550
|
SettlrProvider,
|
|
1551
|
+
UNITY_EXAMPLE,
|
|
1388
1552
|
USDC_MINT_DEVNET,
|
|
1389
1553
|
USDC_MINT_MAINNET,
|
|
1390
1554
|
USDT_MINT_DEVNET,
|
|
@@ -1397,8 +1561,11 @@ export {
|
|
|
1397
1561
|
findAllowancePda,
|
|
1398
1562
|
findPrivateReceiptPda,
|
|
1399
1563
|
formatUSDC,
|
|
1564
|
+
generateCheckoutUrl,
|
|
1565
|
+
generateDeepLinkCheckout,
|
|
1400
1566
|
getTokenDecimals,
|
|
1401
1567
|
getTokenMint,
|
|
1568
|
+
parseCallbackUrl,
|
|
1402
1569
|
parseUSDC,
|
|
1403
1570
|
parseWebhookPayload,
|
|
1404
1571
|
shortenAddress,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@settlr/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Settlr SDK - Accept Solana USDC payments with privacy. Email checkout, gasless transactions, FHE-encrypted receipts. Private on-chain, compliant off-chain.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"build": "tsup",
|
|
22
22
|
"dev": "tsup --watch",
|
|
23
23
|
"lint": "eslint src/",
|
|
24
|
+
"test": "npx tsx node_modules/mocha/bin/mocha.js 'src/__tests__/**/*.test.ts'",
|
|
24
25
|
"prepublishOnly": "npm run build"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
@@ -46,7 +47,17 @@
|
|
|
46
47
|
"typescript",
|
|
47
48
|
"email-checkout",
|
|
48
49
|
"no-wallet",
|
|
49
|
-
"privy"
|
|
50
|
+
"privy",
|
|
51
|
+
"inco-lightning",
|
|
52
|
+
"fhe",
|
|
53
|
+
"homomorphic-encryption",
|
|
54
|
+
"private-receipts",
|
|
55
|
+
"privacy-cash",
|
|
56
|
+
"zk-payments",
|
|
57
|
+
"range-security",
|
|
58
|
+
"compliance",
|
|
59
|
+
"sanctions-screening",
|
|
60
|
+
"one-click-payments"
|
|
50
61
|
],
|
|
51
62
|
"author": "Settlr <hello@settlr.dev> (https://settlr.dev)",
|
|
52
63
|
"license": "MIT",
|
|
@@ -68,10 +79,16 @@
|
|
|
68
79
|
"@solana/web3.js": "^1.98.0"
|
|
69
80
|
},
|
|
70
81
|
"devDependencies": {
|
|
82
|
+
"@types/chai": "^5.2.3",
|
|
83
|
+
"@types/mocha": "^10.0.10",
|
|
71
84
|
"@types/node": "^20.0.0",
|
|
72
85
|
"@types/react": "^19.2.7",
|
|
86
|
+
"chai": "^6.2.2",
|
|
87
|
+
"mocha": "^11.7.5",
|
|
73
88
|
"react": "^19.2.3",
|
|
89
|
+
"ts-node": "^10.9.2",
|
|
74
90
|
"tsup": "^8.0.0",
|
|
91
|
+
"tsx": "^4.21.0",
|
|
75
92
|
"typescript": "^5.0.0"
|
|
76
93
|
},
|
|
77
94
|
"peerDependencies": {
|