Luna
Luna

Reputation: 557

Laravel E-Commerce How to allow users to upload file after payment is received

I'm creating a site where a user will be allowed to upload a file once they make a payment: example: Basic Plan for $9.99 or Enterprise Plan $20.99

when a user chooses a plan they will then be prompted to upload a file.

I'm looking for some direction on what the best way to go about doing this is, any suggestions as far as plugins, or the best process to do something like this.

I will be using stripe's API , what do you think is the best workflow, I already know how to use stripes API with laravel , my concern is how to make the user pay , then allow the user to upload once and only if payment is received.

What should by database table look like? What should the process look like for the user.

I was thinking 1.User creates an account 2.User confirms email then is redirected to choose plan page, user chooses plan 3.User makes payment, then is redirected to an upload page. 4.User uploads file.

any ideas, or maybe a better solution?

This is not your typical e-commerce site with a whole bunch of products where you choose something then pay.

This site will require a user to make payment in order to allow them to upload one file to the platform.

any direction with as much detail would be greatly appreciated.

of course I'm building this system on laravel.

Upvotes: 1

Views: 257

Answers (1)

Jelly Bean
Jelly Bean

Reputation: 1219

Honestly, your plan is solid.

  1. Have a spot where they can manage their documents, just in case the payment does not get approved immediately.
  2. depending on how your subscription works i.e. monthly, yearly or once off you probably need to store some sort of a token that is valid for a period of time. creating this token after payment has been verified.
  3. For your file uploads table I would suggest making use of Morph relationships. This will allow you to to have one table for many different file uploads, as you will have 2 columns a itemable_type and itemable_id the type is your model and the id your record id. to get these columns add this to your migration $table->morphs('itemable'); Laravel will make them for you.

  4. using a trait for your file uploads would be a good idea as well as you can call it up and pass it parameters with a single line whereever you need it, or call it with some complex logic.

Upvotes: 2

Related Questions