Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
stripe-lib
Advanced tools
Readme
A library to make easier some simple requests to stripe. Focused on the use of cards and the storage of users with cards assigned.
npm install stripe-lib
const stripeLib = require('stripe-lib');
stripeLib.init({
apiKey: "..." // private key
});
(browser, mobile apps, etc)
const stripeLib = require('stripe-lib');
stripeLib.init({
publishableKey: "..."
});
To use the token generation request which should be used from a client side, you must provide your PUBLISHABLE-API-KEY due to not giving away any of your private information.
The rest of the functions are server centered so you'll need to provide the private also.
If you don't initialize this parameters you won't be able to use neither the lib or stripe functions wholly.
Signature: createTokenFromCard(number, month, year, cvc)
Used to get a token from the minimum card information.
const token = await stripelib.createTokenFromCard({
number: 'CARD-NUMBER-AS-A-STRING',
month: EXPIRATION-MONTH,
year: TWO-LAST-NUMBERS-OF-EXPIRATION-YEAR,
cvc: CARD-CVC
});
First of all you'll have to create a token as showed above.
Once you have the token you can directly charge the card.
const charge = await stripelib.cardCharge(
token.id,
AMOUNT-OF-CURRENCY,
CURRENCY);
//you can find the supported currency and their names here https://stripe.com/docs/currencies
WARNING: The amount of currency has to be of the currency's smallest unit e.g: to charge $10 USD, provide an amount value of 1000 (i.e, 1000 cents).
Signature: createCustomer(email)
const customer = await stripelib.createCustomer("CUSTOMER'S-EMAIL");
Signature: createCustomerWithCard(email, cardToken)
const customer = await stripelib.createCustomerWithCard("CUSTOMER'S-EMAIL", CARD-TOKEN-GENERATED.id);
A customer with cards has always a default one which will receive the charge when charging the customer.
You can add more cards to a customer and can change the default card
Signature: addCardToCustomer(customerId, cardToken)
await stripelib.addCardToCustomer(customer.id, CARD-TOKEN-GENERATED.id);
Signature: updateDefaultCard(customerId, cardId)
await stripelib.updateDefaultCard(customer.id, NEW-DEFAULT-CARD.id);
WARNING: The token of a card and the card are different things to see the id's of the different cards of a customer you can either get the customer or the digested information of their cards.
Signature: getCustomer(customerId)
const customerInfo = await stripelib.getCustomer(customer.id);
Signature: getCustomerDigestedCards(customerId)
const digestedCardsInfo = await stripelib.getCustomerDigestedCards(customer.id);
WARNING: A customer can't pay if it has no cards
Signature: customerCharge(customerId, amount, currency)
const charge = await stripelib.customerCharge(
customer.id,
AMOUNT-OF-CURRENCY,
CURRENCY
);
//You can find the supported currency and their names here https://stripe.com/docs/currencies
WARNING: The amount of currency has to be of the currency's smallest unit e.g: to charge $10 USD, provide an amount value of 1000 (i.e, 1000 cents).
To get the info of a charge you only have to use the get function
Signature: chargeInfo(chargeId)
const chargeInfo = await stripelib.chargeInfo(CREATED-GHARGE.id);
Signature: removeCardFromCustomer(customerId, cardId)
await stripelib.removeCardFromCustomer(customer.id, card.id);
Signature: removeCustomer(customerId)
await stripelib.removeCustomer(customer.id);
If on your own decide to make some changes over the code of the functions but want the output to keep it like right now you can alway run the verification output tests using:
npm run jasmine
FAQs
Node JS library for using the most common functionalities of stripe
The npm package stripe-lib receives a total of 0 weekly downloads. As such, stripe-lib popularity was classified as not popular.
We found that stripe-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.