Add an interface for one-time purchase retrieval

This commit is contained in:
Ravi Khadiwala authored and ravi-signal committed 2026-08-05 13:24:14 -05:00
1 parent e4b09112f1
commit 5b6d6f28c9
10 files changed
+80 -40

No files matched your search

@@ -23,12 +23,10 @@ import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.time.Instant;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.glassfish.jersey.server.ServerProperties;
@@ -258,9 +256,9 @@ class OneTimeDonationControllerTest extends AbstractV1SubscriptionControllerTest
@MethodSource
void createBoostReceiptPaymentRequired(final ChargeFailure chargeFailure, boolean expectChargeFailure)
throws IOException {
when(STRIPE_MANAGER.getPaymentDetails(any())).thenReturn(Optional.of(new PaymentDetails(
when(STRIPE_MANAGER.claimOneTimePurchase(any())).thenReturn(Optional.of(new PaymentDetails(
"id",
Collections.emptyMap(),
null,
PaymentStatus.FAILED,
Instant.now(),
chargeFailure))
@@ -341,9 +339,9 @@ class OneTimeDonationControllerTest extends AbstractV1SubscriptionControllerTest
ServerSecretParams.generate().getPublicParams()).createReceiptCredentialRequestContext(
new ReceiptSerial(new byte[ReceiptSerial.SIZE])).getRequest();
when(STRIPE_MANAGER.getPaymentDetails(any())).thenReturn(Optional.of(new PaymentDetails(
when(STRIPE_MANAGER.claimOneTimePurchase(any())).thenReturn(Optional.of(new PaymentDetails(
"id",
Collections.emptyMap(),
ONETIME_CONFIG.boost().level(),
PaymentStatus.SUCCEEDED,
Instant.now(),
null)));
@@ -20,7 +20,6 @@ import com.stripe.model.PaymentIntent;
import jakarta.annotation.Nullable;
import java.io.IOException;
import java.time.Instant;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@@ -271,8 +270,8 @@ public class OneTimeDonationsGrpcServiceTest extends
void createBoostReceiptCredentialsPaymentRequired(
@Nullable final ChargeFailure chargeFailure,
final boolean expectChargeFailure) throws IOException {
when(stripeManager.getPaymentDetails(any())).thenReturn(
Optional.of(new PaymentDetails("id", Collections.emptyMap(), PaymentStatus.FAILED,
when(stripeManager.claimOneTimePurchase(any())).thenReturn(
Optional.of(new PaymentDetails("id", null, PaymentStatus.FAILED,
clock.instant(), chargeFailure)));
final CreateBoostReceiptCredentialsResponse response =
@@ -305,9 +304,9 @@ public class OneTimeDonationsGrpcServiceTest extends
ServerSecretParams.generate().getPublicParams()).createReceiptCredentialRequestContext(
new ReceiptSerial(new byte[ReceiptSerial.SIZE])).getRequest();
when(stripeManager.getPaymentDetails(any())).thenReturn(
Optional.of(new PaymentDetails("id", Collections.emptyMap(), PaymentStatus.SUCCEEDED,
clock.instant(), null)));
when(stripeManager.claimOneTimePurchase(any())).thenReturn(
Optional.of(new PaymentDetails("id", oneTimeDonationConfiguration.boost().level(),
PaymentStatus.SUCCEEDED, clock.instant(), null)));
doThrow(WriteConflictException.class).when(issuedReceiptsManager)
.recordIssuance(any(), any(), any(), any());