Django PayPal for the association of an automatic email sending - python

Hi everyone I would like to know how you were able to manage once the customer clicks on the paypal payment button in your Django app, I would like to know how you were able to automatically manage sending an email in his mailbox
indeed I can already manage the sending of emails automatically for a button button that I created myself but the case where I used the integration of paypal on the client side, I can't do it

If you want your server to take action when there is a payment, you should be using a server-side integration. Full stop.
Create two routes that return JSON, one for 'Create an Order' and one for 'Capture Order', documented here.
Pair your two routes with the PayPal JS for approval: https://developer.paypal.com/demo/checkout/#/pattern/server
When an order is successfully captured by your server, have your server then immediately take the desired action (send the email). This is straightforward.

Related

Slack: Is it possible to initiate an API call using user input from slack to another system?

I have been asked to try and get something working in our slack environment for our campus locations to use. The goal is to have a user input the location which would initiate the API call to the other system and return some basic high level system health stats.
I am familiar with how to setup webhooks to slack, just not sure if it's possible to do this or not with slack.
The slack API (https://api.slack.com/) is fairly complex to get set up, but it will do what you want once you get there. It has a web API that you can register to receive hooks from when things appear in messages or chats, for example, and thus you can trigger things to run when people say certain things, for example.
If I understand correctly, you want a user to input a location on slack, and based on their input to make an API call to a different service.
You have several options to get the input from the user:
You can create a bot that the user can chat with
You can create a shortcut or workflow that users can use to fill some kind of form
You can allow for interactions on your application's home page
All these options will get slack to send a payload to some endpoint you define. You will have to set up some basic back end to handle this and call your external APIs from.
I'm currently working on a similar project and recommend using some serverless, fast setup. I have opted for Lambda and API gateway for this. The experience is:
The user goes to the app home page and presses a button
The user gets a form to fill
On form submission, slack sends a payload to an endpoint set via API gateway
API gateway summons a lambda function
The function parses and validates the payload, and ultimately makes a request to my external API

"Become customer" button on my website requires the POST customer endpoint to be public. I don't want it public. How do I get around this?

I have a web app communicating with a backend through a couple of REST endpoints.
I also have a home page where people can become customers to the above mentioned web app.
All the web app's endpoints requires authentication (a logged in user) to be called (JWT tokens) but on my home page I have a "Become customer" button which makes a POST /customers request, which I have to leave public (But I don't want anyone to be able to spam my endpoint with new customers.
What is the standard way of getting around this problem?
I'm using Python, Flask and Flask-JWT in my backend.
The only option would be a user role that is added, for a limited amount of time (30mins). If the user has this role, then they have permission to view it.
Make sense?

Shopify app: adding a new shipping address via webhook

I'm planning to create a simple app using Django/Python that shows a nice button when installed by the store owner on user's account.
Clicking on that button should trigger a webhook request to our servers that would send back the generated shipping address for the user.
My questions:
Is it possible to create such button through shopify API or this something the store owner must manually add?
Is it possible to add a shipping address upon user request?
Thanks
Here is the recipe:
create a Proxy in your App to accept incoming Ajax call from customer
create a form and button in customer liquid that submits to your Proxy
in the App Proxy, validate the call from Shopify and when valid, look for your form params.
open the customer record with the ID of the customer you sent along with the form data, and add an address to their account
Done. Simple.

django real time collaborative web site

My question is about real time collaboration between users in a django powered web site.
In practice what I need to know is if it's possible to implement such a system:
1) Say that all users using the web site are user1, user2, ... userN
2) Each time one of the users do something interesting notify the server and other users in order to update
the application status and the browsers ui
3) The previous point can be extended to cover not only user-triggered events but also other more general events like timeouts, or "every 5 minutes" or what ever you can imagine.
I know that browser to server and server to browser communication can be done via ajax (or something newer like web-sockets or SSE), but the part that is obscure to me is how to
notify users when a certain events occurs.
The only (bad) idea that comes to mind is to store application data to database and update it when a user do something, and at the same time have all the users polling the application status from db. But I would know if there is a way to avoid the use
of database and the polling system, in other words something like:
when event e is triggered => send to all browsers "e triggered"
Thanks in advance
I'll try to better explain my question: I would like to know how to send a response to user "Frank" when another user "John" do something. The problem isn't how the server send something to a browser but how to link john’s activity (i.e. click button, change page, fill forms) to Frank’s ui without using a database. For example think about a simple chat page, when a user type something the typed text must be pushed to all other users: in this case I don't know how to link the action "John typed something" with the action "send typed text to Frank's browser". The memcache solution sound good, but I would like to know if there is something else like a pub-sub or event system that can be used to link different users' connections.
Implement a cache (i.e. memcache) to avoid hitting the database when the Ajax call checks for changes. If you want to get fancy, look into key-based cache expiration to handle the cache invalidation.

Subscription web/desktop app [PYTHON]

Firstly pardon me if i've yet again failed to title my question correctly.
I am required to build an app to manage magazine subscriptions. The client wants to enter subscriber data and then receive alerts at pre-set intervals such as when the subscription of a subscriber is about to expire and also the option to view all subscriber records at any time. Also needed is the facility to send an SMS/e-mail to particular subscribers reminding them for subscription renewal.
I am very familiar with python but this will be my first real project. I have decided to build it as a web app using django, allowing the admin user the ability to view/add/modify all records and others to subscribe. What options do I have for integrating an online payment service? Also how do I manage the SMS alert functionality? Any other pointers/suggestions would be welcome.
Thank You
Payment gateway integration:
Here is a detailed article about how to integrate the Authorize.net payment system into a Django project. Authorize.net is used by a few popular Django projects, including the Satchmo e-commerce store project.
django-paypal is a pluggable Django app which lets you connect to PayPal merchant services.
SMS alerts:
django-sms is a Django app which is "...designed to make sending SMS text messages as simple as sending an email." so might be a good start.
General Django
You didn't mention your knowledge level of Django itself; if you need to brush up on your Django skills I would highly recommend the book Django 1.0 Website Development.
I think it's also worth pointing out that the resources I've mentioned here were all found in the first few results of a Google search for each topic. These are the search terms I used:
django payment gateway integration
django paypal integration (because I knew of PayPal beforehand)
django sms alerts
I'd like to comment on the SMS alert part.
First, I have to admit that I'm not familiar with Django, but I assume it to be just like most other web frameworks: request based. This might be your first problem, as the alert service needs to run independently of requests. You could of course hack together something to externally trigger a request once a day... :-)
Now for the SMS part: much depends on how you plan to implement this. If you are going with an SMS provider, there are many to choose from that let you send SMS with a simple HTTP request. I wouldn't recommend the other approach, namely using a real cellphone or SMS modem and take care of the delivery yourself: it is way too cumbersome and you have to take into account a lot more issues: e.g. retry message transmission for handsets that are turned off or aren't able to receive SMS because their memory is full. Your friendly SMS provider will probably take care of this.

Categories