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
0
Question by MichaelTheGreat · Nov 27, 2014 at 03:59 AM · in app purchase

In App Purchasing is NOT working!!!

I have tried the last two weeks to get this working using multiple plugins.

I am using Prime 31 as the pluging now and here is the rundown.

I have a sprite acting like a button, when someone presses this texture, I want the google payment screen to pop up (which it does) and when the payment succeeds, add 500 coins to the player pref?

Here is my code

 using UnityEngine;
 using System.Collections;
 
 public class coins500 : MonoBehaviour {
     static int coins01; 
     static int bought;
 
     void OnEnable(){
         IABAndroidManager.purchaseSucceededEvent += purchaseSucceededEvent;
     }
     // Use this for initialization
     void Start () {
         var key = "etc";
         IABAndroid.init( key );
         IABAndroid.startCheckBillingAvailableRequest();
     }
 
     void purchaseSucceededEvent( string productId )
     {
         coins01 = 500 + PlayerPrefs.GetInt ("Coins");
         PlayerPrefs.SetInt ("Coins", + coins01);
         PlayerPrefs.Save ();
     }
 
     
     void OnMouseDown () {
         IABAndroid.purchaseProduct ("android.test.purchased");
                 }                
             
         }
 
     }



It wont give the player the 500 coins when the purchase works? what im I missing???

Comment
Add comment · Show 2
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 meat5000 ♦ · Nov 27, 2014 at 04:26 AM 0
Share

Signed you apk with the matching Hash you registered on Google Developer Console?

avatar image MichaelTheGreat · Nov 27, 2014 at 04:34 AM 0
Share

Yeah, I just didnt post it here but on my end I have the key where its supposed to be.

The payment screen pops up and can "pretend" pay for it, but somehow its not giving the player the 500 coins?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by psycocrusher · Nov 27, 2014 at 04:54 AM

You need to specify a product id:

 void purchaseSucceededEvent( string productId ){
     
     if(productId == "YourProductID"){
 
        coins01 = 500 + PlayerPrefs.GetInt ("Coins");
        PlayerPrefs.SetInt ("Coins", + coins01);
        PlayerPrefs.Save ();
 
     }
 }
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 MichaelTheGreat · Nov 27, 2014 at 02:14 PM 0
Share

That fixed it and the fact that you need to publish your store page on Google Developer Console.

avatar image HarshadK · Nov 27, 2014 at 02:24 PM 0
Share

A word of caution:

You should not store your in-app purchased products information in PlayerPrefs as they are not at all secure. User can easily change this data. Try to use some other method like binary files with encryption to make it a little more secure.

avatar image Eck · Nov 27, 2014 at 02:31 PM 0
Share

Adding that if-statement would not fix the problem. It would just restrict it to the purchased item (if it was working).

avatar image
0

Answer by Eck · Nov 27, 2014 at 02:35 PM

It looks like the answer was publishing the store page on Google Developer Console.

Next time, you can attach a debugger or throw in some Debug.Log messages to see what's going on. If you would have put some log messages in purchaseSucceededEvent, you probably would have seen that you never got those messages because the purchase never succeeded.

Comment
Add comment · 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

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

29 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 avatar image avatar image avatar image

Related Questions

Can't understand OpenIAB skus 0 Answers

ingameshop tutorial c# 1 Answer

i need a script to remove ads by with an in app purchase subscrition 0 Answers

Can't import IAP store package 0 Answers

OpenIAB support multiple platforms dynamically? 0 Answers


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