next-stripe-helper
Advanced tools
Comparing version 1.1.46 to 1.1.47
@@ -52,2 +52,11 @@ import { Stripe } from 'stripe'; | ||
declare const createAccountLink: (options: Stripe.AccountLinkCreateParams) => Promise<Stripe.AccountLink>; | ||
export { createConnectedAccount, createPayout, startOAuthFlow, handleOAuthCallback, createAccountLink }; | ||
/** | ||
* Creates a Connect Express login link for a connected account. | ||
* | ||
* @param {string} accountId - The ID of the connected account. | ||
* @param {string} secretKey - Your Stripe secret key. | ||
* @returns {Promise<string>} - A promise that resolves to the created login link URL. | ||
* @throws {Error} - If there's an error during the request. | ||
*/ | ||
declare const createConnectExpressLoginLink: (accountId: string, secretKey: string) => Promise<string>; | ||
export { createConnectedAccount, createPayout, startOAuthFlow, handleOAuthCallback, createAccountLink, createConnectExpressLoginLink }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createAccountLink = exports.handleOAuthCallback = exports.startOAuthFlow = exports.createPayout = exports.createConnectedAccount = void 0; | ||
exports.createConnectExpressLoginLink = exports.createAccountLink = exports.handleOAuthCallback = exports.startOAuthFlow = exports.createPayout = exports.createConnectedAccount = void 0; | ||
const stripe_1 = require("../utils/stripe"); | ||
@@ -123,2 +123,31 @@ /** | ||
exports.createAccountLink = createAccountLink; | ||
/** | ||
* Creates a Connect Express login link for a connected account. | ||
* | ||
* @param {string} accountId - The ID of the connected account. | ||
* @param {string} secretKey - Your Stripe secret key. | ||
* @returns {Promise<string>} - A promise that resolves to the created login link URL. | ||
* @throws {Error} - If there's an error during the request. | ||
*/ | ||
const createConnectExpressLoginLink = async (accountId, secretKey) => { | ||
const endpoint = `https://api.stripe.com/v1/accounts/${accountId}/login_links`; | ||
try { | ||
const response = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Authorization': `Bearer ${secretKey}`, | ||
//'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}); | ||
if (!response.ok) { | ||
throw new Error(`Failed to create login link: ${response.statusText}`); | ||
} | ||
const data = await response.json(); | ||
return data.url; | ||
} | ||
catch (error) { | ||
(0, stripe_1.handleStripeError)(error); | ||
} | ||
}; | ||
exports.createConnectExpressLoginLink = createConnectExpressLoginLink; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "next-stripe-helper", | ||
"version": "1.1.46", | ||
"version": "1.1.47", | ||
"description": "Easily add Stripe boilerplate code to Nextjs, like webhook handling, and subscription updates. This package provides a thin wrapper around the Stripe API, and makes integrating Stripe and NextJS a lot faster!", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/i-dream-of-ai/next-stripe-helper", |
@@ -354,2 +354,24 @@ # next-stripe-helper | ||
### Create Connect Express Login Link | ||
Creates a Connect Express login link for a connected account. | ||
```javascript | ||
const loginLinkUrl = await createConnectExpressLoginLink( | ||
'acct_123456789', // Replace with your users connected account ID | ||
'sk_YourStripeSecretKey' // Replace with your Stripe secret key | ||
); | ||
``` | ||
Parameters: | ||
- `accountId` (required): The ID of the connected account. | ||
- `secretKey` (required): Your Stripe secret key. | ||
Returns: | ||
- A string representing the created login link URL. | ||
## Subscription Utilities | ||
@@ -356,0 +378,0 @@ |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
125004
1388
1124
1