Checkout and buy confirmation with Snipcart and Strapi - webhooks

It's probably a noob question, but I've been searching for a while and haven't been able to find the answer so far.
I'm currently building a webpage with strapi and snipcart. I've got a user login system on strapi, users can buy courses and do the checkout process with snipcart without registering a user account there.
After buying the online course, I need to give the user access to the course in strapi. I just can't figure out how I can send a request from snipcart to strapi to confirm that a user has bought the course and therefore is allowed to view it in whilst being logged in.
Since snipcart and strapi are not connected I'm trying to figure out how I can send a request from snipcart to strapi. I've been stumbling across webhooks, but I'm not sure if this is what I'm supposed to be using yet.
Any help is appreciated.

So I figured it out, but didn't have time to reply yet.
After an item is bought, the snipcart sdk can send a cart.confirmed event where you can listen to.
After listening to the event you can send the snipcart information to your strapi backend to save it. Here you can for example have a boolean which gets updated if the user has bought a course/item.
https://docs.snipcart.com/v3/sdk/events#cartconfirmed

Related

How Can I fetch my customers data from my CRM and show on Twilio frontline app

I hope you are well. Thank you for Mail. I was quite busy on these days. That's why, I can't able to reach out you.
Actually, I have some questions regarding some issues. I'm working to build a system in which I can fetch the customers data from my CRM to Twilio frontline app. The half of the job is done. Like I make the okta developer account and ready for user access to Twilio frontline app. But the main issue is that I'm not able that How I can fetch the Customers Data from my CRM(Pipedrive) to Twilio frontline app to contact with customers over the app. Let me show you How I actually work on it. I'm currently working according to your blog for Twilio frontline app:
https://www.twilio.com/docs/frontline
And I'm now on this URL:
https://www.twilio.com/docs/frontline/nodejs-demo-quickstart
I'm also using Ngork and Yarn as Local Host but I'm stuck over here.
Now, I need to complete this and go forward to get customers data. I'm confused here. So, I need your help.
Now, the Questions is that How I can make a Node.js script or any other script that can fetch my CRM(Pipedrive) data and show on Twilio frontline app. I need the exact script. OR Is there is any other option that I can easily fetch the customer data.
Thank you!
Regards,
Ehtisham
I want customers data(PHone number, Whatsapp number, Email) from my CRM(Pipedrive) into frontlineapp to contact with the customers. And Also I need a feature that When I text to someone from frontline app it will also save the chat to the person's timeline.

Best way to handle one-time payments with STRIPE webhooks in nodeJS

I am using STRIPE as my payment processor, in an REACT + nodeJS app. I already have something that already works, but I would like some feedback, maybe I'm doing something wrong.
So... I have this Redirect-To-Checkout functionality thats made available by STRIPE, basically I redirect the user to this STRIPE page where all card-data (sensitive information) is processes in order for the payment to full-fill.
What I do in my nodeJS server part is the following:
Once the user acces the redirect to check-out page, I already create a PendingOrder, with the products selected by client (Here I save some information based on client/stripe payment-intent, in order to check in later steps)
Once webhook gives me the 'payment_intent.succeeded' I check for the payment-intent information to see if it exists in my PendingOrder collection, then proceed to add in to ConfirmedOrders and remove it from PendingOrders.
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order(such as observation that the user has based on the type of service he chooses).
Are there any down-sides to this approach or is there any other way to do it?
Thanks in advance!
You’re not really far from the best practices that Stripe recommends here. The only thing that I would change is listening to checkout.session.completed instead of the payment_intent.succeeded event. As of the latest API version, a PaymentIntent is no longer created upfront so a better to way to handle order fulfillment is to either store the Checkout Session ID (e.g. cs_live_xxx) or you could add some metadata when creating the Checkout Session and use that instead to identify the order.
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order
As for this, I’m not sure what you mean, you can always use your app with the success page customization described here alongside webhooks. I wouldn’t use that to fulfill the order though since the user might close the page before the redirection completes which means that the fulfillment wouldn’t be done in that case. As such, webhooks are essential to order fulfillment.

Update my database after Stripe payment successful

I am implementing Stripe on a website for the first time and I'm not sure the right way to do something. After the payment is successful I need to update my database before the client is redirected to the "client's account dashboard", so the dashboard shows the updated information. I thought the right way would be to use webhooks, but if the webhook takes longer to update the database then the redirection, the dashboard will show outdated info.
I found an old post with a similar problem to mine where they said there is no need to use webhooks, as Stripe API calls are synchronous and I can get "the charge object" back which indicates that the payment succeeded. It's a fairly old post so I am not sure if that's the way to go (and also, I can't find information on Stripe Docs on how retrieve the "charge object" once redirected to the "success page")
I would appreciate any help. Thanks!
*Edit: Would polling be a viable way to accomplish this? I can keep the client in the "success page" and use polling to check when the database has been updated, and then redirect.

Node.js Trade Notification for Steambot

I'm not a coder, but I'm asking on behalf of my web developer who isn't fluent with english, for everyone's expertise.
I'm trying to achieve a real time trade notification on my website.
I have the node.js bot working for all trading purpose already and its interacting with the web with socket.io. Inventory is working. But I do want to add an addtional functionality when the trade offer is send, a notification will also in real time event sent to user on my website at the same time my bot sent a trade offer to the user in steam.
Below is a screenshot example,
https://gyazo.com/ec41e836605f2284f834dd7606693e22
Really appreciate if anyone could help me out.
This all depends on the way you handle your data.
If you are making it so the bot sends a trade offer to the user then when you call your trade offer add in a
socket.emit('tradeOfferSent', {
});
to that user which can be picked up on the client side by
socket.on('tradeOfferSent',function(data) {
});
conversely if you are making your users send trade offers to the bot you can use on 'newOffer' from steam-tradeoffer-manager to emit the data as above.
Inside the on.socket('',function(){}); you are able to add anything you want as an notification. Such as using sweetalerts.

How To Send Notifications To A Specific User Group / Role Only using Socket.io?

I am working on a project which I want to implement a feature where after an action happens, I want to notify all online administrators on the web app and show them a message that an action happened.
I have a few questions:
How can I identify which user is online and has an admin role? I am looking for some ideas around "show all online users" list
Should I put these admins into a room where I can broadcast the notification only to that room?
How can I get all users who are online and associate their socket ID with the ID / Username in the database?
I will also need the online status to be shown in a table so I can know if UserOne and John are online at the moment.
How can I keep the online / offline status? Do I have to keep the status somewhere outside of the database?
I am using Laravel v5.1, NodeJS v5.0, Socket.io v1.3 and Redis to play around with the notifications.
Does anyone have any idea how can I deal with this problem? I am not really looking for any code specific stuff, I am just curious about the theory behind the idea and how it will work.
Thanks!

Resources