Change Stripe example email in webhooks triggers - stripe-payments

I want to be able to pass an email into the webhook I trigger. I have a setup where after a user pays I want to update their record on Mailchimp. To properly test this without pushing to production (or running a local server open to the internet) I need to pass an email to stripe trigger checkout.session.completed so that it can find an email in Mailchimp. Right now the email is always stripe#example.com.

It's not possible to pass in custom data to stripe-cli triggers currently. Instead you probably want to use a service like ngrok.io to test this in a local environment.

Related

Testing/automating/mocking orders on Stripe hosted checkout

Is there any way to automate/mock placing an order in stripe hosted checkout in the Stripe test environment?
One can use the Stripe CLI to trigger an event like $ stripe trigger checkout.session.completed but this isn't enough for my use case.
With the event triggers, we don't have control over the data in the checkout session. It's random.
I want to trigger an order completed with defined line items, in a specific currency, with a particular test card, and a destination connect account.
But if I want to do that now, I must manually place the order in my dev environment and go through the test Stripe-hosted checkout flow.
You can use the --add and --override CLI flags to customize your CLI triggered checkout.session.created events. Otherwise, your best bet is to just mock the Session Completed response yourself here.

How do you send email data with Stripe connect onboarding in test mode?

I'm currently setting up Stripe connect on my website and I want to test a webhook that needs the email data to be sent to it. But, in test mode, Stripe says "email is not needed in test mode" and blocks the input. Is there a solution or workaround for this so I can test sending email data?
Thanks,
In test mode it's not possible to set the email for an Express account during the onboarding flow. But when creating the account with the API, you could set the email parameter (this field is only used to make the account easier to identify for you).
Also note that Stripe don't send any emails in test mode.

How to process payment on the backend side using Stripe?

I am new to Stripe and payments in general. I've found few articles on the internet with the examples and guidelines eg. this one. As i noticed the algorithm for creating the payment looks like this:
Client app fetches the publishable Stripe key from the server
Server application creates the checkout session, client app fetches the checkout session id using retrieved publishable key
Client app redirects to checkout
User finishes the payment and being redirect back to client app
Please correct me if i'm wrong. In general i don't understand one thing - how the server application knows that the payment is completed successfully or not? Should i redirect the flow from stripe checkout to backend first, process the result and the from the backend call the frontend again? Or should i somehow use the checkout session to check has it been completed? Shall i use some kind of cron then to process pending checkout sessions? Thanks in advance for any help. Regards
Basically, what you lay out is viable. You can check the Session status when the client is directed back to your server, but you will want to check this status at least one other way, either via a webhook or the cron job you mention.
Should i redirect the flow from stripe checkout to backend first, process the result and the from the backend call the frontend again?
This is possible. Stripe allows you to add the {CHECKOUT_SESSION_ID} template parameter to your Checkout's success URL, when the user is redirected after their checkout, that template will be replaced with the actual Checkout Session ID which you can use to retrieve the Session and its status.
That being said, it is possible for a Customer to make a payment but have their connection cut out before navigating back to your page. So, if you rely on that redirect the customer will be charged but you will never know to fulfill their order. That leads to unhappy customers so Stripe typically recommends setting up a webhook endpoint on your server[2] so that they can send you a checkout.session.completed event to notify you that the customer has finished their Checkout Session. That way, even if a customer never gets to your success page, you will know to fulfill their order.
[1] https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url
[2] https://stripe.com/docs/payments/checkout/fulfill-orders

Not allow user to change email on Stripe Checkout Session

I am using stripe for my app subscription needs. I have some webhooks which are called when an invoice is paid, failed etc now this webhooks send the customer_email and i use that to do some other tasks. Now the problem is that a user is able to change the email on checkout_session
I don't want the user to be able to change this. I tried disabling the option from the customer-portal dashboard on stripe but that didn't work either.
Changing this email calls the webhook with wrong email resulting in lost subscription etc. I can't seem to find the option to disable this.
Currently you cannot disable changing the email address in the Checkout Session. You would probably want to use the customer's id as the unique reference (instead of relying on the customer's email).
Disabling the ability to update their email address as shown in the second screenshot, only disables that function in the customer portal.

In aws pinpoint (NodeJS) how to trigger a email when custome event trigger by user

I am working on a NodeJs API which send a mail when New user added in AWS Pinpoint.
I need to trigger a mail when new user add in AWS Pinpoint or sign-in attempts or some transaction happens or credit in his/her account is less than 5.
I have already created a API which add and update user in AWS pinpoint as endpoints.But I stuck in, how to create a custom event which automatically do this task after updating the endpoint in AWS pinpoint.
I have referred https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Pinpoint.html link while trying to create custom event. But no proper solution found
you should only send an event, in the EndpointUser part of the payload, put your new user details, it will update the endpoint and will fire event, which you can catch with a campaign

Resources