Advanced Commerce API SKU verification

Hello! In our app we use Advanced Commerce API with generic consumable products. Does Apple validate SKU of payment request? So if user have several pending purchase requests with same SKU (inside item) will Apple charge only for the latest one or all of pending requests even though SKU is the same?

Hello! Generally speaking, the same SKU is allowed for consumable purchases. In the case of multiple pending purchase requests, finishTransaction must be invoked before starting a new transaction. Specifically for consumables, if another consumable purchase is issued after the previous consumable transaction has been finished, another charge will be created.

In the scenario of an error, an appropriate error code is thrown depending on the exact failure that occurred. For example, see this InvalidSKUError, and there's a general validation on length, for example.

Thanks! So in our app there are plenty of digital items thats why we use Advanced Commerce API. I'm asking if Apple validates duplicated pending requests by their SKU to determine architecture for payments. The flow that is under the question is so:

  1. User try to make payment and for some reason payment falling into pending state
  2. On that pending state I send to our BE info that this item for that user is in pending status
  3. BE marks such item for user as pending and will not allow user to try to purchase that item, while it in pending status (not to make several payment requests, so Apple will not charge user several times for single digital item)
  4. BE & iOS app waits for succeed info (app waits Transaction.updates, BE for server notificatio)
  5. On succeed notification BE unlocks digital item for user and purchase finished (from app side via .finish() method).

The problem is how we know that for some reason Apple converted pending purchase request to failed or even erased at all. In case when pending purchase changed to failed or removed by Apple -> BE and app has no notify for that-> BE still keep digital item as pending so user will not have ability to try to initiated purchase once more.

So main problems: Best approach to save user from multiple charges for single digital item If we must monitoring and preventing duplicated payment requests from our side how to know that pending purchase request is killed by Apple or converted to failure?

To be specific, are you asking about flows such as Ask to Buy here, or what does "pending" mean in this scenario?

Yes Ask to Buy or any other reason when user try to buy digital item and Apple receives status .pending

Once the transaction marked as pending, the app will be notified of successful transactions via transaction updates, as pointed out here: https://developer.apple.com/documentation/storekit/product/purchaseresult/pending.

Yes, the flow with successful payment is clear. But what if payment from pending state will be killed by apple or failed? How to know about it?

We appreciate your feedback.

To clarify, while the transaction is in a pending state as a result from an Ask to Buy state, as in the formal Product.Purchaseresult.pending state, if multiple transactions are executed against the same generic consumable product, it would be treated as refreshing the Ask to Buy window.

Advanced Commerce API SKU verification
 
 
Q