IAP 4.12.2 - Empty Order ID for Deferred Purchases

When a deferred purchase is made, the order number on the google receipt is null. I can confirm that this was not the case in version 4.9. After the purchase is confirmed, the order number takes value.

Unity version: 2021.3.40f1
IAP package: 4.12.2
Platform: Android

Here is the code I use to get receipt:

googlePlayConfiguration = builder.Configure<IGooglePlayConfiguration>();
googlePlayConfiguration.SetDeferredPurchaseListener(OnDeferredPurchase);
private void OnDeferredPurchase(Product product)
{
        var orderId = GetOrderId(product);
        ...
}
string GetOrderId(Product product)
{
	try
	{
		var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
		var result = validator.Validate(product.receipt);
	
		foreach (IPurchaseReceipt productReceipt in result)
		{
			var googleReceipt = productReceipt as GooglePlayReceipt;
			if (googleReceipt != null)
			{
               orderId = googleReceipt.orderID;
               Debug.Log(googleReceipt.orderID); // Log: empty
			}
		}
	}
	catch (IAPSecurityException ex) { Debug.LogException(ex); }
  return orderId;
}

This is the correct behaviour, since Google Play Billing Library v6, Google no longer returns an Order ID for pending purchases

Is there a use case where this is problematic for you?

I currently use the order ID to recognize purchases, which I need for some specific sales. I believe using the purchase token instead would solve this issue.
Thank you.

1 Like