Unity Access Google pay

Source: Internet
Author: User

Reasons for the article

The previous time was responsible for unity access to Google in the purchase function, the first study of other people's technical blog found that their articles are some years, some of the details of the place is not like N years ago, technology will always need to be updated, And this is the last article in the end of 2016 to access Google in the purchase of articles to the needs of the people

Preparatory work

1. Will own Google account, pay $25, become Google Developer account, developer information feel free to fill in (some blog written must fill the United States, in fact, I filled in China)
2. A four-piece Android mobile phone and VPN with Google set
3. A Unity Mini demo for testing, just make the payment button just fine

Google developer background settings 1. Create a new app 2. The following is required before publishing the application (complete all the options with the * number, the upper left corner of the gray tick all green to be able to publish), Please attach all 3 of the information you need to fill in. In-app product filling is different from other blogs, and by the time I write a blog, only the "managed goods" and "subscription" are left, and "managed goods" is Google helping you record purchases, such as one-time purchases of all open levels, If the player re-install the game, but also can not pay back the original purchase of these levels. However, some people will ask, if you cancel the "non-managed goods", I can buy unlimited gifts in the game and Gold Diamond Gift package, do not worry, the following code will mention this. After creating the interface for unity because the code needed to be written to Android, the Unity project was packaged as an Android project and then developed two times. The first is Android and Unity Communication, if not, you can go to see the Rain Pine Blog. Buykey This parameter is the id--(jb_1) and (Lb_1) that were previously created in the in-app product, and this parameter needs to be uploaded to wirelessly for processing. Message This parameter is messages returned by Android and, if needed, can be followed up in unity. Next you need to package your unity project as an Android project. First fill in the appropriate package name and signature and fixed must modify the section after the start package for Android project to add payment code in Android I use the eclpise for two development, if you use Androidstudio is not a problem, the code is the same way of thinking, Configured in a different way. Start by creating an empty project in eclipse (note the callout on the picture), and then drag the folder from the Android project that you just exported to the new project, and select Overwrite all Our project content will be replaced with unity content: Android Engineering setup is complete. Next is the most critical access to Google in the purchase, first we need to download the SDK manager in the internal purchase SDK. This is his official demo, which shows how to access the in-house purchase in Android. Put the required classes into our Android project and drag them into the path that might be reported to introduce the wrong, Notice that the normal path to your own project is modified to add the inside purchase permission in the Androidmainfest file and then we write in the Java code in the code that is called by unity and the return message to unity, you must write the Base64 RAS public key. Find "Services and APIs" in our list of newly created apps, with public keys the next few functions are 1 of what we need to buy in-house. After calling the inside purchase function, execute the "purchase result handler" because weProducts are managed goods, only allowed to buy once, if you want to buy again, you must first consume, only the consumption of success, Google will allow the continued purchase. If you have unlimited purchases such as coins or gift bags, you can execute the consumption function immediately after each successful purchase. 2. After the successful purchase, execute the "consume result processing function", for example, to determine the user's consumption success, The corresponding event 3 is executed. The function is the function that the program initializes automatically, you can add the list of items you want to execute to consume, and if it is a one-time purchase, do not add it to the list 4. The function must be added to your code (modeled after the demo) to Google, which will then package the Android project as an apk, and Ipse how to package as an APK file. After packing, upload to the Google Developer console, I uploaded the Alpha version and selected the closed Alpha version of the test, and then the need to test the Google account to add to the tester list, not only to be added here as a tester, Also to add the test Google account in the licensing test options in the settings, you must both be added to the first upload alpha apk success, wait a few hours, then use the test account to enter the URL, and then click OK to become a tester, Then wait 15 minutes-1 hours after the Google store to download our test app to test, of course, you can also use the previous APK directly installed on the phone test conclusion access to all the steps are here, there are some pit points, the follow-up will be updated, if the feeling where said not carefully, please private messages me, I'm going to add it all together, let's make progress.

Unity access to Google pay

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.