Today we are going to learn how to generate events for purchase tests with Stripe using the Ubuntu console.

The first thing we will do is install Stripe in our console:
curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
- Update APT:
sudo apt update
- Install Stripe:
sudo apt install stripe
And now log in:
stripe login
It will generate a login link, click on it to authenticate.
And now let’s launch some events, for example payment received:
stripe trigger payment_intent.succeeded
If you want to re-forward events to your local:
stripe listen --forward-to localhost:4242/webhooks
You can’t trigger a checkout.session.completed directly from the CLI with a specific product. The cleanest way is to make a real purchase in test mode from the frontend with a test card.
Without frontend, you can create a session manually:
html
# 1. Create the checkout session with your real Stripe price_id. Stripe checkout sessions create \ --line-items "price=price_1ABC123,quantity=1" \ --mode=payment \ --success-url="https://tudominio.com/success" \ --cancel-url="https://tudominio.com/cancel"
You can finally indicate the test data of Stripe.
4242 4242 4242 4242 Date: any future date CVC: any number
