Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by salvador007 · Jan 13, 2015 at 08:50 AM · c#macpaymentdesktoppaypal

How to open unity desktop app from web browser?

Hello Friends,

Actually I am working on a PC/Mac game and I have integrated a payment gateway also. What I want is that after payment success it should automatically open the application.

Currently if a user taps "Pay" button then he/she is take to payment page which gets open in a browser. then after payment he/she has to manually return to app. If any one has answer please help me. Thanks in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LRG · Jan 13, 2015 at 10:30 AM

I don't think there is any built-in way in Unity to do this.

You first need to be able to detect purchase completions. This is relatively easy, as you can just signal the program from the server when paypal reports success.

Opening the App again is harder, and I can think of some alternatives:

Open new browser, close it after buying

You would need to ensure that the payment page is opened in a new browser window, and that tabs and URL bar is disabled. That way you should be able to close it after the purchase is done without annoying the user by closing its main browser window. Once it is closed, if the user did not meanwhile switch to other window, your program should automagically recover focus. You can start the browser as a child process to close it easily.

This will need further work, but for instance, to open a Chrome new window you can:

 // Requires using the System.Diagnostics namespace
 Process proc = new Process();
 proc.StartInfo.FileName = @"chrome";
 proc.StartInfo.Arguments = @"unity3d.com --new-window";
 proc.Start();

Once that window is closed, focus should return on its own.

Explicitly switch focus again once the payment is done

This can be done through low level WINAPI functions such as SwitchToThisWindow. However, they tend to not work very realiably, and you will need plugins / pinvoke to use it, so unless you can find a better one, I would try the first approach.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image salvador007 · Jan 14, 2015 at 07:31 AM 1
Share

Thanks LRG , How can I open a new window from unity app . All I know is Application.OpenUrl.

avatar image LRG · Jan 14, 2015 at 09:03 AM 0
Share

Added a Process.Start example. Though it will need some work (particularly, it won't work if chrome is not installed).

avatar image salvador007 · Jan 14, 2015 at 12:14 PM 1
Share

but desktop app gets $$anonymous$$imised in background. Even if we close the browser it will not help.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How do i make my enemy attack my player? 0 Answers

Payment with Credit on PayPal possible? 1 Answer

System.IO.DriveInfo returns wrong disk space values on Mac 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges