Search Unity

PaypalIPN Shop Integration

Discussion in 'Assets and Asset Store' started by DevionGames, Sep 16, 2012.

  1. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624

    Obsolete
     
    Last edited: Oct 20, 2015
  2. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,054
  3. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Thank you rosor!
     
  4. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Very cool. :)
     
  5. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Thank you! :D
     
  6. arteria

    arteria

    Joined:
    May 31, 2007
    Posts:
    2,189
    Well done with this, great idea.
     
  7. dreamlarp

    dreamlarp

    Joined:
    Apr 22, 2011
    Posts:
    854
    Way to think ahead of time.
     
  8. petero181

    petero181

    Joined:
    Feb 23, 2011
    Posts:
    104
    can we use this script in ios, osx and android? and is that against apple rules? sorry for asking this stupid question.
     
  9. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Questions are never stupid. I am sorry but i have no ios or android device to test it. I also do not know if it is against the apple rules, if you click on one of the offer you will be simply redirected to paypal where you can do or cancel the payment.
     
  10. The13gate

    The13gate

    Joined:
    Jul 29, 2012
    Posts:
    2
    Nice job!
     
  11. Burletech

    Burletech

    Joined:
    Jul 1, 2010
    Posts:
    73
    Very nice bro! Be picking this up soon.
     
  12. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Thank you ImaGino and Burletech!
     
  13. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Nice idea!
     
  14. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Thank you! :D
     
  15. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Reduced price to 10$, would be great to get feedback from the one guy who bought it :D
     
  16. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Thread recreated :D
     
  17. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
  18. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    This looks nice, but I really don't want to give out my personal details just to download a free package. Anywhere else you could host it?
     
  19. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Just put in fake info. I did.
     
  20. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    why not put this in the asset store?
     
  21. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    Can somebody explain how this works a little bit? When a new user registers, where is there info saved? And how do I setup what items can be sold?
     
  22. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Well, I don't know.
    I will say this, however.

    I didn't feel like re-downloading this package (I have in the past, but couldn't find it) so I coded my own for my specific purposes (ties into my own account system).

    Here's how Paypal IPN works. After you've set up your merchant account in PayPal, and have it pointing to your IPN script on your website, you give users a specially formatted link (or, in the case of Unity, a button that calls Application.OpenURL).
    This link opens a purchase page, where users can log into paypal and buy the item.
    Then, after users have logged in and confirmed the purchase, PayPal will contact your IPN script on your website with details about the transaction. After your script confirms that the transaction is legitimate and all the data is correct (among other things), you then do what you want with the data. For instance, in my own IPN setup, I pass the user's account ID in the "custom" field. When my IPN script receives the transaction, it grabs the account ID from the custom field, and updates the account with that ID in my database with the number of credits the user purchased (determined via item name - not the cleanest way, but works. I have a lookup table that maps item name -> number of credits).

    That's a VERY basic overview, with a lot of details missing. If that package has documentation, I encourage you to read through it and see what the actual setup steps are and how to use it.
     
  23. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    Hey thanks for the answer, I appreciate it. In the documentation that is provided, I do not see how to add items to the shop. I am confused how to set up what items can be sold, and also do not understand what is happening with the php files. From looking at the code, I believe the user IDs and Passwords are stored in an SQL database, but I have never programmed any php/sql so this is very confusing :(

    Thanks for your reply, atleast I understand the basics of what is happening. Would you be willing to look at a script if I sent it to you? I'm sure you would know immediately is going on.
     
    Last edited: Apr 1, 2014
  24. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Well, I would encourage you to start learning PHP. It's a bit... arcane, to say the least, but once you get the hang of it it's actually not that hard.

    I bet in your register scripts you'll see some kind of mysql_connect line, this is where it connects to the database. There will probably also be a line where it selects which database to you (you can set up MySQL to host multiple databases).
    Probably some lines where it grabs user account information (either $_GET or $_POST, depending), sanitizes it (to prevent against SQL injection), and eventually gets to the bit where it inserts the user account into the database. Probably something like:

    Code (csharp):
    1.  
    2. $SQL = "INSERT INTO AccountsOrWhateverTheTableIsCalled VALUES ( ... )"
    3.  
    From that you should probably be able to figure out what the account table has to be named, and what values it should contain.
     
  25. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Hello, the sql script is included, you need to run it for example in phpmyadmin. Also all other php scripts are included. You have to add the "product" via phpmyadmin for example to the database and also inside unity.
     
  26. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    how do you use the credits?
     
  27. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    It is your choice how to use them. :)
     
  28. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    how would i make it to where the user can donate a certain amount of credits to an item.

    like the user picks an item name and can spend any amount that they have on those items
     
  29. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    This asset does not include this functionality. You would need to write this by yourself. Something like a shop system where the user can purchase items using credits.
     
  30. tredpro

    tredpro

    Joined:
    Nov 18, 2013
    Posts:
    515
    is there something im not understanding? after the payment is made. it doesn't post it to the database under payment. only way i know its posted is from my email paypal sends me
     
  31. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Thank you for the explaination. So far I understand how IPN works. But my main problem ist: After adding the new items to the user account in the database, how can I tell my unity game that it should update his data from the database? Right now the user gets the new values in the game only after re-login. I don't want to poll my database all the time so how can I notify my game that the payment went well?