I am trying to make a something like a shopping cart. I want to add a feature, that if a person adds a product on website but does not purchase the item, i will send him an email with a link. If the person clicks on the link, then I want to login him automatically and take him directly to payment page. I don't want him to enter password in between. So can I somehow create some API call which can login him and then redirect him to concerned URL?
Sure you can. It's your application, you can handle access to it the way you want. But you should remember several important points.
Whoever gets access to that link gains access to the customer's payment page. That is a lot of access to be sent over something as blatantly insecure as email.
The link that you generate should not transparently include any user credentials. This is easy to get horribly wrong. You don't want to create something that allows an attacker to access every other customer's payment data just by incrementing a number somewhere in the URL.
The link should probably be usable only once, and only within a short time of its generation, to mitigate the risks that you can't avoid when generating such pre-approvied log-ins.