If for whatever reason a purchase doesn’t complete, and the user makes another, in the iOS receipt, you’ll have multiple transactions in the inApp field. Something like this:
{
environment: Sandbox,
receipt: {
…
in_app: {
{
is_trial_period: false,
original_purchase_date: 2016-05-1814: 19: 12Etc/GMT,
original_purchase_date_ms: 1463581152000,
original_purchase_date_pst: 2016-05-1807: 19: 12America/Los_Angeles,
original_transaction_id: 1000000212147818,
product_id: product_1,
purchase_date: 2016-05-1814: 19: 12Etc/GMT,
purchase_date_ms: 1463581152000,
purchase_date_pst: 2016-05-1807: 19: 12America/Los_Angeles,
quantity: 1,
transaction_id: 1000000212147818
},
{
is_trial_period: false,
original_purchase_date: 2016-05-1814: 17: 38Etc/GMT,
original_purchase_date_ms: 1463581058000,
original_purchase_date_pst: 2016-05-1807: 17: 38America/Los_Angeles,
original_transaction_id: 1000000212147465,
product_id: product_2,
purchase_date: 2016-05-1814: 17: 38Etc/GMT,
purchase_date_ms: 1463581058000,
purchase_date_pst: 2016-05-1807: 17: 38America/Los_Angeles,
quantity: 1,
transaction_id: 1000000212147465
}
},
…
},
status: 0
}
where “product_1” is the purchase that’s currently going on, and “product_2” is the purchase that hasn’t been validated.
Now, I can validate and give both on the server, however, when I get the return, and call Complete on the purchase, only “product_1” is cleared. Even explicitly calling RefreshAppReceipt won’t clear “product_2” even though technically it’s been treated.
I can’t call Complete on that one, as the ConfirmPendingPurchase() method only takes a Product, not a transactionID, and the Product in question won’t have that data.
If I call ConfirmPendingPurchase() on “product_2”, I get an error, as it doesn’t have the transactionID/receipt set on it.
I can’t set that data on it (transactionID and receipt) as the fields are internal/private.
I can’t create a new Product with the right data for the same reason.
So every purchase after this will include the transaction for “product_2” even though it’s been treated (I can check for this on the server however).
How can I clear this product specifically? UnityIAP’s not notifying me of it (see [Solved] Unity IAPs ProcessPurchase not calling after purchase, only after app restart - Unity Services - Unity Discussions and [Closed] RestorePurchase on iOS not return ProcessPurchase callback - Unity Services - Unity Discussions)
Thanks