title: Testing Titanium's In-App Billing module for Android
body: <p>Does anyone know how to properly test live android in app purchases in titanium debug mode?</p>
  
  <p>Previously, I was successfully able to test live in-app purchases and create real transactions when debugging from Titanium Studio. That was because previously, I had incorrectly created my Google Play store listing using the development .apk as per:
  <a href="http://developer.appcelerator.com/question/123704/what-keystore-does-titanium-studio-use-to-build-android-app-during-development" rel="nofollow">http://developer.appcelerator.com/question/123704/what-keystore-does-titanium-studio-use-to-build-android-app-during-development</a></p>
  
  <p>and therefore, Google play had associated my dev_keystore with my in-app purchase codes.</p>
  
  <p>However, when I then tried to build and upload my production release using a generated keypair/certificate as per:
  wiki.appcelerator.org/display/guides/Distributing+Android+apps</p>
  
  <p>the Google Play store then (correctly) rejected my production candidate complaining that my APK had been signed with a different certificate to the one that was used in the original upload:</p>
  
  <pre><code>You uploaded an APK that is signed with a different certificate to your previous APKs. 
  You must use the same certificate. Your existing APKs are signed with the certificate(s) 
  with fingerprint(s): [ SHA1: ...:9D:47:9F ] and the certificate(s) used to sign the APK 
  you uploaded have fingerprint(s): [ SHA1: ...:5D:E2:4E ]
  </code></pre>
  
  <p>As such, I had to delete my google play store listing and recreate it from scratch using the signed APK as described by the appcelerator guide referenced above.</p>
  
  <p>This has now resulted in my in-app purchases becoming associated with the signed APK which means that now when I am testing a development build of the app and attempt to make an in-app purchase, I am greeted with:</p>
  
  <pre><code>This version of the application is not configured for billing through Google Play
  </code></pre>
  
  <p>It is not a timing issue (I have waited 24 hours) as suggested by:
  stackoverflow.com/questions/11068686/this-version-of-the-application-is-not-configured-for-billing-through-google-pla</p>
  
  <p>It is occurring because the dev_keystore in my development build doesn't match the certificate associated with the in-app purchase codes.</p>
  
  <p>I imagine I might be able to get around this if Titanium studio allowed me to specify my apps certificate certificate when debugging as per:
  <a href="http://jira.appcelerator.org/browse/TISTUD-1214" rel="nofollow">http://jira.appcelerator.org/browse/TISTUD-1214</a></p>
  
  <p>In the interim, a testing workaround to debug purchases is that I have created an additional and separate 'test' duplicate google play application with identical in app purchases and associated it with my development .apk (instead of my signed apk). During testing, I then just need to change:</p>
  
  <pre><code>require('ti.inappbilling').setPublicKey(...)
  </code></pre>
  
  <p>to point to the test project instead of the real one. Then, when i'm comfortable with the payments, I will build using the real key.</p>
  
  <p>This is a really sub-standard workaround and i'm hoping someone has a better way of doing things.</p>