@sergdudko/stripe-js
v2.0.37
Published
Supercharge Your Stripe Integration with Enhanced Methods for stripe-js: Take Full Control of Customer Card Management Right from Your Frontend! Elevate Your Payment Processing Capabilities with Ease and Efficiency.
Maintainers
Readme
@sergdudko/stripe-js
Supercharge Your Stripe Integration with Enhanced Methods for stripe-js: Take Full Control of Customer Card Management Right from Your Frontend! Elevate Your Payment Processing Capabilities with Ease and Efficiency.
🚀 What's New in v2.0.0
- ✅ Dual Package: Full support for both CommonJS and ES Modules
- ✅ TypeScript: Complete type definitions and TypeScript source
- ✅ Optimized Types: Shared type definitions for smaller bundle size
- ✅ TypeScript Tests: All tests converted to TypeScript with
node --test --import tsx - ✅ Better Tree-shaking: Optimized module structure for better bundling
Usage
ES Modules (Recommended)
import { loadStripe } from "@sergdudko/stripe-js";
const stripe = await loadStripe("pk_test_TYooMQauvdEDq54NiTphI7jx");CommonJS
const { loadStripe } = require("@sergdudko/stripe-js");
const stripe = await loadStripe("pk_test_TYooMQauvdEDq54NiTphI7jx");Stripe.js Documentation
Additional Methods
| Method | Arguments | Description | | ----------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------- | | getCustomer | [customer_id], [ephemeral_key] | Get customer. | | confirmPaymentIntentByCard | [client_secret], [card_id], [returnUrl] | Confirm payment intent with the user's payment card (sources api). | | addSourceToCustomer | [source or token], [customer_id], [ephemeral_key] | Add payment card to customer (from source or token, sources api). | | deleteSourceFromCustomer | [source_id], [customer_id], [ephemeral_key] | Delete payment card from customer (sources api). | | getAllCards | [customer_id], [ephemeral_key] | Get all cards from customer (sources api). | | setDefaultCard | [defaultCardId], [customer_id], [ephemeral_key] | Set default card (sources api). | | getDefaultCard | [customer_id], [ephemeral_key] | Get customer default payment card (sources api). | | confirmPaymentIntentByPaymentMethod | [client_secret], [payment_method_id], [returnUrl] | Confirm payment intent with the user's payment method (payment methods api). | | addPaymentMethodToCustomer | [payment_method_id], [customer_id], [ephemeral_key] | Attach payment method to customer (payment methods api). | | deletePaymentMethodFromCustomer | [payment_method_id], [ephemeral_key] | Detach payment method from customer (payment methods api). | | getAllPaymentMethods | [customer_id], [ephemeral_key] | Get all payment methods from customer (payment methods api). | | setDefaultPaymentMethod | [payment_method_id], [customer_id], [ephemeral_key] | Set customer default payment method (payment methods api). |
Examples
stripe.getCustomer(
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.confirmPaymentIntentByCard(
'pi_3Jrk80HdlMaZle3e1tGtSxiH_secret_mWdWNlqJfkYEoYOml1GqRPyPm',
'card_1JrMi8HdlMaZle3eSPPOvapJ',
'https://stripe.com/'
);
stripe.addSourceToCustomer(
'tok_visa',
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.deleteSourceFromCustomer(
'card_1JroRSHdlMaZle3e4EIGOZuv',
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.getAllCards(
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.setDefaultCard(
'card_1JrMi8HdlMaZle3eSPPOvapJ',
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.getDefaultCard(
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.confirmPaymentIntentByPaymentMethod(
'pi_3Jrk80HdlMaZle3e1tGtSxiH_secret_mWdWNlqJfkYEoYOml1GqRPyPm',
'pm_1JrMi8HdlMaZle3eSPPOvapJ',
'https://stripe.com/'
);
stripe.addPaymentMethodToCustomer(
'pm_1JrMi8HdlMaZle3eSPPOvapJ',
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.deletePaymentMethodFromCustomer(
'pm_1JrMi8HdlMaZle3eSPPOvapJ',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.getAllPaymentMethods(
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);
stripe.setDefaultPaymentMethod(
'pm_1JrMi8HdlMaZle3eSPPOvapJ',
'cus_KO9SkBdMeHoMXR',
'ek_test_YWNjdF8xSFhSd0xIZGxNYVpsZTNlLENrVUxKWWNjZExxSDJDb1VKa1YwaXU5VDZVcmVmQXQ_00drAg7pBQ'
);Scripts
- To run linting
npm run lint. - To run build
npm run build. - To run testing
npm run test. - To create docs
npm run doc.
📄 License
MIT License - see LICENSE file for details.
🆘 Support
- 📝 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📧 Email: [email protected]
💝 Support This Project
If my Stripe JS Extension helps you build amazing applications, consider supporting its development:
Your support helps maintain and improve Redux Cluster for the entire community!
Made with ❤️ by Siarhei Dudko
