Rent-like option to sell data

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi!
I'm developing an ecommerce that sells "date ranged" data.
The ideia is that the user picks two different dates and receive a dynamic made file with data.
Is there a way that I can create something like the rent option, but with custom code?
6 years ago
This is a really cool idea! It looks like it's doable with some work.

Here's the relevant code to generate a download:
https://github.com/nopSolutions/nopCommerce/blob/b5f7884ce5be583e0d5e4deaa300b9176eca42fa/src/Presentation/Nop.Web/Controllers/DownloadController.cs#L60

The gist of how it works is
1. we get the OrderItem from OrderService
2. we get the Download (which contains either a URL or the binary) from DownloadService by passing in OrderItem.Product.DownloadId

The main issue here is that DownloadService only receives the Product's DownloadId, not the rental date information.

So one solution that I see you can do from plugins alone, is that you'll override OrderService to return a different DownloadId that embeds information about the rental dates.

For example, in OrderService.GetOrderItemByGuid, you'll check to see if it's one of these date-ranged data products. If it is, you'll insert a new Download into DownloadService with a DownloadUrl to a custom controller that will compute your data. Then you'll replace the original OrderItem.Product.DownloadId with the new Download that you just inserted.

Does that make sense?
6 years ago
You can create a plugin that subscribes to Order Paid event - you create a class (e.g. OrderPaidWhateverHandler) which implements "IConsumer<OrderPaidEvent>" interface. And then implement "HandleEvent(OrderPaidEvent eventMessage)" method. In the handler: access order item's attributed for dates, generate the data, encode it, get the bytes, create new Download() and set properties, use download service to insert it, and then finally update the order item's LicenseDownloadId with the inserted download id.
5 years ago
Was looking for this topic.
I am also interested in selling a data service by rental product.
the service will send emails to customers who rent the product service.
In order to do so - I will need to get a list of all users to send the data to.
how do I filter all those valid users (in the rental period) and get their email address?
also, is there a simple way to send emails I can use through Nop (shceduled job- for sending emails)?
5 years ago
ronenl wrote:
...
how do I filter all those valid users (in the rental period) and get their email address?
also, is there a simple way to send emails I can use through Nop (shceduled job- for sending emails)?


You can always query the Orders looking for the relevant order items, but it would probably be better to maintain your own table to track the users.  As per above, the Order Paid event would insert records.  A scheduled task can handle the 'expiration'.  A scheduled task can handle queuing the emails.  All would require customization (plugin) if you wanted it built-in to the system.  If you want to do it externally/manually, you could use SQL to query the Orders as per above, and deal with sending emails using some external service like MailChimp.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.