Regarding Rest "Communicate statelessly" principle - web-services

One of the rest key principle is not to maintain state on a server or to communicate statelessly. I want to have views how this principle works on shopping cart?
So, say if the user is adding products in a shopping cart from a shopping website. In my opinion, the server will have some implementation to have shopping cart in session scope and user will send a post call to add the product in a shopping cart. For e.g /shoppingcart/products/1. Now the products remain added in shopping cart(but not persisted in database) until user confirms for checkout. During confirmation of check-out, the shopping cart items gets persisted into the database on server side.
Does this approach(putting item in shopping cart on server side that is in session scope) violates rest principle? If yes, how then we can implement the adding product to shopping cart by taking care of "stateless" communication principle?

A shopping cart should be handled as a resource, and products added/removed just as you may add or remove associations between any two resources in REST. Instead of the client saying "now purchase the items in my cart" the client should say "now purchase the items in cart #187462". Assign each cart a URL, and have your operations act upon that resource instead of some product array tied to the current session.
An alternative which is also stateless is to have the client track all items in the cart, but this means the user cannot leave the cart (abandon it) on one computer and resume shopping on another device.
Addendum: Remember that permissions/access control can be assigned independently. Sure, each cart has a URL, but be sure to make it so that the logged in user can only see cart resources that they have created.

Related

How can we get data of current logged in user in flutter if used django as a backend

I want to show widgets in flutter as per the types of user logged in. For example if the user is logged in as seller, he/she can see widgets to sell the goods and if he/she is buyer they should get option to buy goods. I want to achieve this in flutter with django backend...
Firstly you must return a role with the user object.
as example the rules are
"role":1
for saler
"role":2
for buyer
"role":3
for viewer
an so on
then use your state management solution for flutter to check the role of current logged in user

Add an item to my own Amazon cart through the API

I would like to add an item to my own Amazon cart through the API.
Simplified use case: I have a specific product ID in mind. When I'm running low on that product, I press a button in an iPad app and it will make an authenticated callout to Amazon to add this item to my cart.
I've looked at the Product Advertising API, mainly the Add to Cart Form and CartAdd operation, but it doesn't look like that's what I want - me adding an item to my own cart.
https://docs.aws.amazon.com/AWSECommerceService/latest/DG/AddToCartForm.html
https://docs.aws.amazon.com/AWSECommerceService/latest/DG/CartAdd.html
Is there even a way to do this?

Bigcommerce Cart Contents xfer to Another

We want to operate two separate bigcommerce sites across tld (.ca & .com). The sites will be virtually identical aside from currency.
To make it user friendly, I want to have the cart contents transfer over, so if a user starts a cart in .com and realizes they need to switch to .ca it is persistent when they do.
I imagine the contents of the cart are stored in the user cookies somewhere and I can just develop some code to fill the cart using a cross reference for the .ca/.com site.
Does anyone know where the cart contents are stored in the cookies?

How to track client payment information of a visitor redirected from my website

I want to implement a system similar to affilite tracking systems like Skimlinks, Viglink, etc. I searched their customer tracking systems. Found some information about tracking systems. I have also searched Analytics systems like Google Analytics, Piwik, OWA. There is a point I need to be guided.
When a user visits my website, clicks a product link of a shopping website like ebay, amazon, etc. I need to track the payment information of my user at the shopping website.
I achieved tracking user activity, clicks, etc on my web site with using Analytics's tracking methods (JS tracking). But I cannot find a way how Skimlinks or Viglink tracks user activity(succesful payment of users) in the shopping website which user redirected.
(Tracking user activity in the shopping website without using a service from shopping website, without Instant Payment Notification service of PayPay or something else)
I noticed Viglink and Skimlinks redirects user to their server before shopping and adds some additional information (like cookies, URL parameters etc)
Here is an example link to affiliate link of Skimlinks
website : http://www.capoeira-izmir.com/capoeira-kiyafetleri/
link : Street Abada
http://go.redirectingat.com/?id=25227X845172&site=capoeira-izmir.com&xs=1&url=http%3A%2F%2Fwww.ebay.com%2Fitm%2FHELANCA-POLYAMID-CAPOEIRA-PANTS-ABADA-YOGA-FREE-BONFIM-%2F280678232152%3Fpt%3DUS_CSA_MC_Pants%26hash%3Ditem4159b9f058%23ht_2891wt_1163&xguid=94275a6f74c7ce02bf4739e364d8831c&xcreo=0&sref=http%3A%2F%2Fwww.capoeira-izmir.com%2Fcapoeira-kiyafetleri%2F
It redirects user to go.redirectingat.com first, then a redirection is done to ebay.com/...
I also noticed that it adds an attribute to the url of ebay product link : afsrc=1
I guess it is "affiliate source = 1 " or something like that.
Any guidance or documents about this will be great for me.
Thanks in advance!!
I think your question is more about how online advertising works rather than technical.
This is a two parts answer.
1. How a conversion tracking works:
In any advertising platform that tracks conversions (any user action that happens in the advertiser property like, in example, a sale) you need to make a request to the advertising platform to notify this.
This is usually done by placing a "Tracking pixel" in the confirmation page the users see after performing the action, commonly known as the "Thank you page".
So the process goes like:
User goes to a website and sees an ad
User clicks the ad
The user's browser goes to the advertising platform (Adwords, Rightmedia, Appnexus, etc) and a cookie is placed in her browser. In this cookie there's a click ID, containing all the relevant information (website that originated the click, time, IP, campaign, etc) and it is redirected to the advertiser's website
The user lands in the advertiser website and "converts" (buys)
The user is redirected to the Thank you page where a "Tracking pixel" is placed, this makes a request to the advertising platform, which reads the cookies in the user's browser and if there's a match, logs the conversion.
Note: The previous example is a Client Side conversion. The same logic could be done in a Server Side request by the advertiser saving the "click id" in step 4 and sending it to the advertising platform in step 5. This is useful when the conversion occurs offline.
For more information: Adwords Conversion tracking: https://support.google.com/adwords/answer/1722054?hl=en
2. How I assume VigLink works
I noticed that many of the products VigLink tracks are from ClickBank, since this is the one I'm more used to, I will write the answer using this example.
You first need to be aware that VigLink is an "affiliate" of Clickbank. As such, it has a report of every sale made by users they referred. They, as affiliates, also have the chance to pass extra information in each click as a TID parameter. This TID sent as a URL parameter in the click will be shown in the sales report.
When a user clicks on a link to a clickbank product using VigLink. VigLink attaches their affiliate link to this same product and a unique TID. I assume this TID matches an ID in their database containing the information of the VigLink website who referred the click.
If the user buys the product, VigLink will see in their ClickBank report (I assume via the ClickBank API) the product bought and the TID, and so on they will know in which website the sale was originated.
Short answer: VigLink is not tracking user actions in the advertiser's website. They are just matching click IDs between their click tracker and the advertiser's reports.

Is it possible to make a shopping cart persistent in Ubercart

I would like users to be able to have persistent shopping carts. In other words, unless they check out the shopping cart explicitly the shopping cart with the same items should be available the next time they visit the site. Obviously this would be through the use of a cookie...
Is this possible in Drupal?
Yes. This is right in Ubercart. You can set the cart time to whatever you please.
There is duration and units for anonymous and separate settings for logged in.
Visit this on your site: admin/store/settings/cart/edit/basic