12

I have a test user account that is working just fine for testing in app purchases.

I would like to "delete" a purchase from this account, so I can test the purchase multiple times. Right now, if I try to purchase, it logically says the the Test User has already purchased the product in question.

Can I delete a purchase from a Test User account so that I can test the same purchase multiple times. I'd hate to have to create a new Test User every time I want to test the purchase.

EDIT: Each time I try to purchase, I get a dialog with "You've Already Purchased this. Tap OK to download it again for free".

Don Wilson
  • 2,303
  • 3
  • 26
  • 34
  • Can I clarify again: 1) Is this in-app purchase, or purchase from app store? 2) If this is in-app purchase, how does the app knows that you have purchased the item? The state must be saved somewhere. – nhahtdh May 23 '12 at 03:43
  • Does this question help: http://stackoverflow.com/questions/7604578/how-can-i-reset-sandboxed-in-app-purchases-on-ios-for-testing ? – borrrden May 23 '12 at 03:53
  • I only know of 3 ways to store data: iCloud, on device, and app's own server. – nhahtdh May 23 '12 at 03:58
  • 2
    In-App purchases are registered in iTunes Connect, and come from Apple's servers. The purchase data is associated with an Apple ID in order to sync it across devices. OP is probably not using MKStoreKit, now that I think about it. This data is not data that you store in your application. This is billing data that is stored with APPLE. – borrrden May 23 '12 at 04:01

2 Answers2

8

If you really want to test it clean, you are going to have to create another test user. However, I don't see the need for this. Redownloading an in-app purchase is a nearly identical code flow. The actual purchase and verification logic is not part of your application, and a user buying something multiple times is not something that is supposed to happen (unless you specify that it is that kind of consumable). If it works for redownloading, it is safe to assume it will work for the initial purchase.

You do not have access to this data. If Apple exposed a way to reset purchases, they would risk opening themselves up to a security risk since I assume their sandbox server code is practically identical to their production code (otherwise the sandbox would be meaningless). Because the data is on Apple's servers, associated with an iTunes account, it can span across multiple devices.

An alternate idea would be to delete the in app purchase from your iTunes Connect, and make a new one.

borrrden
  • 33,256
  • 8
  • 74
  • 109
  • 5
    **[...] "Redownloading an in-app purchase is a nearly identical code flow."[...]** Just wanted to chime in and mention that although this statement is true for a given transaction handler...it is not necessarily true for the App code itself since an initial purchase could be treated substantially differently from restoring an old purchase. – Questor Jan 19 '14 at 00:04
  • 1
    What about receipt check validation code ? You need to test scenarios where there is no product present and vice versa with your code receipt check. – the Reverend Nov 05 '14 at 22:09
  • @theReverend That might be something that you need to mock (i.e. for testing purposes, have a method that returns YES every time and one that returns NO every time). – borrrden Nov 05 '14 at 23:57
2

If the type of your in-app purchase is consumable then you can just reinstall your app. If your in-app purchase is non-cosumable, then you will need to create additional test users.

Maksim
  • 2,054
  • 3
  • 17
  • 33
  • May we change IAP type from `consumable` to `non-consumable` before releasing to Appstore? It would be the solution for testing. – brigadir May 23 '12 at 06:01
  • We can't change IAP type in iTunesConnect after we create them, we just can create additional `consumable` IAPs for testing purposes. – Maksim May 23 '12 at 06:05