From f2a2926cd14c6d6045433028b628157a90515074 Mon Sep 17 00:00:00 2001 From: Manuel Caspari <5877862+manuelsc@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:26:45 +0100 Subject: [PATCH] (nobids) map apple purchase keys to inhouse keys (#2975) --- exporter/appsubscription_oracle.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/exporter/appsubscription_oracle.go b/exporter/appsubscription_oracle.go index b47798150e..8ae81b33d1 100644 --- a/exporter/appsubscription_oracle.go +++ b/exporter/appsubscription_oracle.go @@ -223,6 +223,21 @@ func rejectReason(valid bool) string { return "expired" } +func mapAppleProductID(productID string) string { + mappings := map[string]string{ + "orca.yearly.apple": "orca.yearly", + "orca.apple": "orca", + "dolphin.yearly.apple": "dolphin.yearly", + "dolphin.apple": "dolphin", + "guppy.yearly.apple": "guppy.yearly", + "guppy.apple": "guppy", + } + if mapped, ok := mappings[productID]; ok { + return mapped + } + return productID +} + func verifyApple(apple *api.StoreClient, receipt *types.PremiumData) (*VerifyResponse, error) { response := &VerifyResponse{ Valid: false, @@ -287,7 +302,7 @@ func verifyApple(apple *api.StoreClient, receipt *types.PremiumData) (*VerifyRes response.RejectReason = "invalid_product_id" return response, nil } - receipt.ProductID = productId + receipt.ProductID = mapAppleProductID(productId) expiresDateFloat, ok := claims["expiresDate"].(float64) if !ok {