
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@stripe/scripts
Advanced tools
In your project directory, run the following command to install the SDK:
npm install @stripe/scripts
Import the proper script function signature types into your file and write your custom logic inside of your script function.
See the Stripe Scripts documentation for more information on how to get started with using the SDK.
Here is an example script authored by Stripe:
import type {
ComputeDiscountsFunction,
DiscountableItem,
DiscountCalculation,
DiscountResult,
} from '@stripe/scripts/discount_calculation';
import type {
PositiveMonetaryAmount,
Percent,
RunContext,
} from '@stripe/scripts';
/**
* Configuration for the discount calculator function
*/
export type DiscountCalculatorConfiguration = {
max_discount_amount: PositiveMonetaryAmount;
discount_percent: Percent;
};
/**
* Gives a percentage off discount upto a maximum discount amount
*
* @param {DiscountCalculatorConfiguration} config - The configuration containing max discount amount and discount percent
* @param {DiscountableItem} item - The items to apply discounts to
* @returns {DiscountResult} - The discounts applied to the items
*/
const percentOffUptoMaxDiscount: ComputeDiscountsFunction<
DiscountCalculatorConfiguration
> = (
context: RunContext,
config: DiscountCalculatorConfiguration,
discountable_item: DiscountableItem,
): DiscountResult => {
const {max_discount_amount, discount_percent} = config;
let discountAmount = 0;
if (
discountable_item.gross_amount.currency.toLowerCase().trim() ===
max_discount_amount.currency.toLowerCase().trim()
) {
const discountAmountValue =
(discountable_item.gross_amount.amount * discount_percent) / 100;
discountAmount = Math.min(discountAmountValue, max_discount_amount.amount);
}
return {
discount: {
amount: {
amount: discountAmount,
currency: discountable_item.gross_amount.currency,
},
},
};
};
const computePercentOffUptoMaxDiscount: DiscountCalculation<DiscountCalculatorConfiguration> =
{
computeDiscounts: percentOffUptoMaxDiscount,
};
export default computePercentOffUptoMaxDiscount;
You can explore more examples and explore how to write your custom scripts package.
Instructions for how to package and upload your scripts are coming soon!
FAQs
Stripe Scripts SDK
The npm package @stripe/scripts receives a total of 411 weekly downloads. As such, @stripe/scripts popularity was classified as not popular.
We found that @stripe/scripts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 63 open source maintainers 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
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.