diff --git a/purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt b/purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt index 7ed8fb4387..2f06bf9873 100644 --- a/purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt +++ b/purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt @@ -667,9 +667,9 @@ internal class Backend( onSuccessHandler: (CustomerInfo) -> Unit, onErrorHandler: (PurchasesError) -> Unit, ) { - val endpoint = Endpoint.PostRedeemWebPurchase(appUserID) + val endpoint = Endpoint.PostRedeemWebPurchase val path = endpoint.getPath() - val body = mapOf("redemption_token" to redemptionToken) + val body = mapOf("redemption_token" to redemptionToken, APP_USER_ID to appUserID) val call = object : Dispatcher.AsyncCall() { override fun call(): HTTPResult { return httpClient.performRequest( diff --git a/purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/Endpoint.kt b/purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/Endpoint.kt index 8dedc0ace1..69106e9c95 100644 --- a/purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/Endpoint.kt +++ b/purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/Endpoint.kt @@ -40,11 +40,11 @@ internal sealed class Endpoint(val pathTemplate: String, val name: String) { ) { override fun getPath() = pathTemplate.format(Uri.encode(userId)) } - data class PostRedeemWebPurchase(val userId: String) : Endpoint( - "/subscribers/%s/redeem_web_purchase", + object PostRedeemWebPurchase : Endpoint( + "/subscribers/redeem_purchase", "post_redeem_web_purchase", ) { - override fun getPath() = pathTemplate.format(Uri.encode(userId)) + override fun getPath() = pathTemplate } val supportsSignatureVerification: Boolean @@ -54,7 +54,7 @@ internal sealed class Endpoint(val pathTemplate: String, val name: String) { PostReceipt, is GetOfferings, GetProductEntitlementMapping, - is PostRedeemWebPurchase, + PostRedeemWebPurchase, -> true is GetAmazonReceipt, @@ -71,7 +71,7 @@ internal sealed class Endpoint(val pathTemplate: String, val name: String) { is GetCustomerInfo, LogIn, PostReceipt, - is PostRedeemWebPurchase, + PostRedeemWebPurchase, -> true is GetAmazonReceipt, diff --git a/purchases/src/test/java/com/revenuecat/purchases/common/backend/BackendRedeemWebPurchaseTest.kt b/purchases/src/test/java/com/revenuecat/purchases/common/backend/BackendRedeemWebPurchaseTest.kt index fd0ed1f101..40b36df36c 100644 --- a/purchases/src/test/java/com/revenuecat/purchases/common/backend/BackendRedeemWebPurchaseTest.kt +++ b/purchases/src/test/java/com/revenuecat/purchases/common/backend/BackendRedeemWebPurchaseTest.kt @@ -15,11 +15,6 @@ import com.revenuecat.purchases.common.createCustomerInfo import com.revenuecat.purchases.common.networking.Endpoint import com.revenuecat.purchases.common.networking.HTTPResult import com.revenuecat.purchases.common.networking.RCHTTPStatusCodes -import com.revenuecat.purchases.customercenter.CustomerCenterConfigData -import com.revenuecat.purchases.customercenter.CustomerCenterConfigData.HelpPath -import com.revenuecat.purchases.customercenter.CustomerCenterConfigData.Screen -import com.revenuecat.purchases.customercenter.CustomerCenterConfigData.Screen.ScreenType -import com.revenuecat.purchases.customercenter.RCColor import com.revenuecat.purchases.utils.Responses import io.mockk.every import io.mockk.mockk @@ -29,7 +24,6 @@ import org.junit.Assert.fail import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import java.io.File import java.net.URL import java.util.concurrent.CountDownLatch import java.util.concurrent.LinkedBlockingQueue @@ -37,7 +31,6 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit import kotlin.time.Duration.Companion.seconds -@OptIn(ExperimentalPreviewRevenueCatPurchasesAPI::class) @RunWith(AndroidJUnit4::class) class BackendRedeemWebPurchaseTest { @@ -136,8 +129,8 @@ class BackendRedeemWebPurchaseTest { verify(exactly = 1) { httpClient.performRequest( mockBaseURL, - Endpoint.PostRedeemWebPurchase("test-user-id"), - body = mapOf("redemption_token" to "test-redemption-token"), + Endpoint.PostRedeemWebPurchase, + body = mapOf("redemption_token" to "test-redemption-token", "app_user_id" to "test-user-id"), postFieldsToSign = null, any() ) diff --git a/purchases/src/test/java/com/revenuecat/purchases/common/networking/EndpointTest.kt b/purchases/src/test/java/com/revenuecat/purchases/common/networking/EndpointTest.kt index 4e4cf702b2..f115440475 100644 --- a/purchases/src/test/java/com/revenuecat/purchases/common/networking/EndpointTest.kt +++ b/purchases/src/test/java/com/revenuecat/purchases/common/networking/EndpointTest.kt @@ -20,7 +20,7 @@ class EndpointTest { Endpoint.PostAttributes("test-user-id"), Endpoint.PostDiagnostics, Endpoint.PostPaywallEvents, - Endpoint.PostRedeemWebPurchase("test-user-id"), + Endpoint.PostRedeemWebPurchase, ) @Test @@ -88,8 +88,8 @@ class EndpointTest { @Test fun `PostRedeemWebPurchase has correct path`() { - val endpoint = Endpoint.PostRedeemWebPurchase("test user-id") - val expectedPath = "/subscribers/test%20user-id/redeem_web_purchase" + val endpoint = Endpoint.PostRedeemWebPurchase + val expectedPath = "/subscribers/redeem_purchase" assertThat(endpoint.getPath()).isEqualTo(expectedPath) } @@ -101,7 +101,7 @@ class EndpointTest { Endpoint.PostReceipt, Endpoint.GetOfferings("test-user-id"), Endpoint.GetProductEntitlementMapping, - Endpoint.PostRedeemWebPurchase("test-user-id"), + Endpoint.PostRedeemWebPurchase, ) for (endpoint in expectedSupportsValidationEndpoints) { assertThat(endpoint.supportsSignatureVerification) @@ -142,7 +142,7 @@ class EndpointTest { Endpoint.GetCustomerInfo("test-user-id"), Endpoint.LogIn, Endpoint.PostReceipt, - Endpoint.PostRedeemWebPurchase("test-user-id"), + Endpoint.PostRedeemWebPurchase, ) for (endpoint in expectedEndpoints) { assertThat(endpoint.needsNonceToPerformSigning)