Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
85839f80afcaccd622aa30bf53a414cdffbd57bc
7b0e14a8a4b606fa2cc641579a18e077e25aaac9
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2369
v2391
47 changes: 44 additions & 3 deletions src/main/java/com/stripe/StripeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.stripe.exception.SignatureVerificationException;
import com.stripe.exception.StripeException;
import com.stripe.model.Event;
import com.stripe.model.StripeObject;
import com.stripe.model.v2.core.EventNotification;
import com.stripe.net.*;
Expand Down Expand Up @@ -115,9 +116,10 @@ public EventNotification parseEventNotification(String payload, String sigHeader
}

/**
* Returns an StripeEvent instance using the provided JSON payload. Throws a JsonSyntaxException
* if the payload is not valid JSON, and a SignatureVerificationException if the signature
* verification fails for any reason.
* Constructs a <a href="https://docs.stripe.com/event-destinations#thin-payload">thin event
* notification</a> from an incoming webhook after verifying its authenticity. To work with a
* webhook that has already been verified (i.e. one from a cloud provider, an asynchronous queue,
* or during testing), see {@code parseEventNotificationWithoutVerification}.
*
* @param payload the payload sent by Stripe.
* @param sigHeader the contents of the signature header sent by Stripe.
Expand Down Expand Up @@ -174,6 +176,45 @@ public com.stripe.model.Event constructEvent(
return event;
}

/**
* Constructs a <a href="https://docs.stripe.com/event-destinations#snapshot-payload">snapshot
* event</a> from an incoming webhook without first verifying its authenticity. Should be used
* after calling {@code Webhook.Signature.verifyHeader(...)} or with input from a trusted source
* (such as <a href="https://docs.stripe.com/event-destinations/eventbridge">AWS EventBridge</a>,
* or <a href="https://docs.stripe.com/event-destinations/eventgrid">Azure Event Grid</a>
* payload). Or, to verify &amp; construct in a single call, use {@code constructEvent(...)}
* instead.
*
* @param payload the JSON payload: a raw Stripe Event or an AWS EventBridge/Azure Event Grid
* envelope.
* @return the Event instance.
* @throws IllegalArgumentException if the payload is a thin event notification, or if the format
* is not recognized.
*/
public com.stripe.model.Event constructEventWithoutVerification(String payload) {
Event event = Webhook.constructEventWithoutVerification(payload);
event.setResponseGetter(this.getResponseGetter());
return event;
}

/**
* Constructs a <a href="https://docs.stripe.com/event-destinations#thin-payload">thin event
* notification</a> from an incoming webhook without first verifying its authenticity. Should be
* used after calling {@code Webhook.Signature.verifyHeader(...)} or with input from a trusted
* source (such as <a href="https://docs.stripe.com/event-destinations/eventbridge">AWS
* EventBridge</a>, or <a href="https://docs.stripe.com/event-destinations/eventgrid">Azure Event
* Grid</a> payload). Or, to verify &amp; parse in a single call, use {@code
* parseEventNotification(...)} instead.
*
* @param payload the JSON payload: a raw Stripe Event, or an AWS EventBridge/Azure Event Grid
* envelope.
* @return the EventNotification instance.
* @throws IllegalArgumentException if the payload format is not recognized.
*/
public EventNotification parseEventNotificationWithoutVerification(String payload) {
return EventNotification.fromJson(Webhook.maybeExtractFromCloudProviderEnvelope(payload), this);
}

// The beginning of the section generated from our OpenAPI spec
public com.stripe.service.V1Services v1() {
return new com.stripe.service.V1Services(this.getResponseGetter());
Expand Down
104 changes: 104 additions & 0 deletions src/main/java/com/stripe/StripeEventNotificationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
import com.stripe.events.V1ApplicationFeeRefundUpdatedEventNotification;
import com.stripe.events.V1ApplicationFeeRefundedEventNotification;
import com.stripe.events.V1BalanceAvailableEventNotification;
import com.stripe.events.V1BalanceSettingsUpdatedEventNotification;
import com.stripe.events.V1BillingAlertTriggeredEventNotification;
import com.stripe.events.V1BillingCreditBalanceTransactionCreatedEventNotification;
import com.stripe.events.V1BillingCreditGrantCreatedEventNotification;
import com.stripe.events.V1BillingCreditGrantUpdatedEventNotification;
import com.stripe.events.V1BillingMeterCreatedEventNotification;
import com.stripe.events.V1BillingMeterDeactivatedEventNotification;
import com.stripe.events.V1BillingMeterErrorReportTriggeredEventNotification;
import com.stripe.events.V1BillingMeterNoMeterFoundEventNotification;
import com.stripe.events.V1BillingMeterReactivatedEventNotification;
import com.stripe.events.V1BillingMeterUpdatedEventNotification;
import com.stripe.events.V1BillingPortalConfigurationCreatedEventNotification;
import com.stripe.events.V1BillingPortalConfigurationUpdatedEventNotification;
import com.stripe.events.V1BillingPortalSessionCreatedEventNotification;
Expand Down Expand Up @@ -71,13 +79,18 @@
import com.stripe.events.V1CustomerUpdatedEventNotification;
import com.stripe.events.V1EntitlementsActiveEntitlementSummaryUpdatedEventNotification;
import com.stripe.events.V1FileCreatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountAccountNumbersUpdatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountCreatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountDeactivatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountDisconnectedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountExpectedDeactivationDateUpdatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountReactivatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountRefreshedBalanceEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountRefreshedOwnershipEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountRefreshedTransactionsEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountSupportedPaymentMethodTypesUpdatedEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountUpcomingAccountNumberExpiryEventNotification;
import com.stripe.events.V1FinancialConnectionsAccountUpcomingDeactivationEventNotification;
import com.stripe.events.V1IdentityVerificationSessionCanceledEventNotification;
import com.stripe.events.V1IdentityVerificationSessionCreatedEventNotification;
import com.stripe.events.V1IdentityVerificationSessionProcessingEventNotification;
Expand All @@ -93,6 +106,7 @@
import com.stripe.events.V1InvoiceOverpaidEventNotification;
import com.stripe.events.V1InvoicePaidEventNotification;
import com.stripe.events.V1InvoicePaymentActionRequiredEventNotification;
import com.stripe.events.V1InvoicePaymentAttemptRequiredEventNotification;
import com.stripe.events.V1InvoicePaymentFailedEventNotification;
import com.stripe.events.V1InvoicePaymentPaidEventNotification;
import com.stripe.events.V1InvoicePaymentSucceededEventNotification;
Expand Down Expand Up @@ -616,12 +630,48 @@ public StripeEventNotificationHandler onV1BalanceAvailable(
return this;
}

public StripeEventNotificationHandler onV1BalanceSettingsUpdated(
Callback<V1BalanceSettingsUpdatedEventNotification> callback) {
this.register("v1.balance_settings.updated", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingAlertTriggered(
Callback<V1BillingAlertTriggeredEventNotification> callback) {
this.register("v1.billing.alert.triggered", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingCreditBalanceTransactionCreated(
Callback<V1BillingCreditBalanceTransactionCreatedEventNotification> callback) {
this.register("v1.billing.credit_balance_transaction.created", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingCreditGrantCreated(
Callback<V1BillingCreditGrantCreatedEventNotification> callback) {
this.register("v1.billing.credit_grant.created", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingCreditGrantUpdated(
Callback<V1BillingCreditGrantUpdatedEventNotification> callback) {
this.register("v1.billing.credit_grant.updated", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingMeterCreated(
Callback<V1BillingMeterCreatedEventNotification> callback) {
this.register("v1.billing.meter.created", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingMeterDeactivated(
Callback<V1BillingMeterDeactivatedEventNotification> callback) {
this.register("v1.billing.meter.deactivated", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingMeterErrorReportTriggered(
Callback<V1BillingMeterErrorReportTriggeredEventNotification> callback) {
this.register("v1.billing.meter.error_report_triggered", callback);
Expand All @@ -634,6 +684,18 @@ public StripeEventNotificationHandler onV1BillingMeterNoMeterFound(
return this;
}

public StripeEventNotificationHandler onV1BillingMeterReactivated(
Callback<V1BillingMeterReactivatedEventNotification> callback) {
this.register("v1.billing.meter.reactivated", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingMeterUpdated(
Callback<V1BillingMeterUpdatedEventNotification> callback) {
this.register("v1.billing.meter.updated", callback);
return this;
}

public StripeEventNotificationHandler onV1BillingPortalConfigurationCreated(
Callback<V1BillingPortalConfigurationCreatedEventNotification> callback) {
this.register("v1.billing_portal.configuration.created", callback);
Expand Down Expand Up @@ -946,6 +1008,12 @@ public StripeEventNotificationHandler onV1FileCreated(
return this;
}

public StripeEventNotificationHandler onV1FinancialConnectionsAccountAccountNumbersUpdated(
Callback<V1FinancialConnectionsAccountAccountNumbersUpdatedEventNotification> callback) {
this.register("v1.financial_connections.account.account_numbers_updated", callback);
return this;
}

public StripeEventNotificationHandler onV1FinancialConnectionsAccountCreated(
Callback<V1FinancialConnectionsAccountCreatedEventNotification> callback) {
this.register("v1.financial_connections.account.created", callback);
Expand All @@ -964,6 +1032,14 @@ public StripeEventNotificationHandler onV1FinancialConnectionsAccountDisconnecte
return this;
}

public StripeEventNotificationHandler
onV1FinancialConnectionsAccountExpectedDeactivationDateUpdated(
Callback<V1FinancialConnectionsAccountExpectedDeactivationDateUpdatedEventNotification>
callback) {
this.register("v1.financial_connections.account.expected_deactivation_date_updated", callback);
return this;
}

public StripeEventNotificationHandler onV1FinancialConnectionsAccountReactivated(
Callback<V1FinancialConnectionsAccountReactivatedEventNotification> callback) {
this.register("v1.financial_connections.account.reactivated", callback);
Expand All @@ -988,6 +1064,28 @@ public StripeEventNotificationHandler onV1FinancialConnectionsAccountRefreshedTr
return this;
}

public StripeEventNotificationHandler
onV1FinancialConnectionsAccountSupportedPaymentMethodTypesUpdated(
Callback<V1FinancialConnectionsAccountSupportedPaymentMethodTypesUpdatedEventNotification>
callback) {
this.register(
"v1.financial_connections.account.supported_payment_method_types_updated", callback);
return this;
}

public StripeEventNotificationHandler onV1FinancialConnectionsAccountUpcomingAccountNumberExpiry(
Callback<V1FinancialConnectionsAccountUpcomingAccountNumberExpiryEventNotification>
callback) {
this.register("v1.financial_connections.account.upcoming_account_number_expiry", callback);
return this;
}

public StripeEventNotificationHandler onV1FinancialConnectionsAccountUpcomingDeactivation(
Callback<V1FinancialConnectionsAccountUpcomingDeactivationEventNotification> callback) {
this.register("v1.financial_connections.account.upcoming_deactivation", callback);
return this;
}

public StripeEventNotificationHandler onV1IdentityVerificationSessionCanceled(
Callback<V1IdentityVerificationSessionCanceledEventNotification> callback) {
this.register("v1.identity.verification_session.canceled", callback);
Expand Down Expand Up @@ -1078,6 +1176,12 @@ public StripeEventNotificationHandler onV1InvoicePaymentActionRequired(
return this;
}

public StripeEventNotificationHandler onV1InvoicePaymentAttemptRequired(
Callback<V1InvoicePaymentAttemptRequiredEventNotification> callback) {
this.register("v1.invoice.payment_attempt_required", callback);
return this;
}

public StripeEventNotificationHandler onV1InvoicePaymentFailed(
Callback<V1InvoicePaymentFailedEventNotification> callback) {
this.register("v1.invoice.payment_failed", callback);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// File generated from our OpenAPI spec
package com.stripe.events;

import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.BalanceSettings;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.Event.RelatedObject;
import lombok.Getter;

@Getter
public final class V1BalanceSettingsUpdatedEvent extends Event {
@SerializedName("related_object")

/** Object containing the reference to API resource relevant to the event. */
RelatedObject relatedObject;

/** Retrieves the related object from the API. Make an API request on every call. */
public BalanceSettings fetchRelatedObject() throws StripeException {
return (BalanceSettings) super.fetchRelatedObject(this.relatedObject);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// File generated from our OpenAPI spec
package com.stripe.events;

import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.BalanceSettings;
import com.stripe.model.v2.core.Event.RelatedObject;
import com.stripe.model.v2.core.EventNotification;
import lombok.Getter;

@Getter
public final class V1BalanceSettingsUpdatedEventNotification extends EventNotification {
@SerializedName("related_object")

/** Object containing the reference to API resource relevant to the event. */
RelatedObject relatedObject;

/** Retrieves the related object from the API. Make an API request on every call. */
public BalanceSettings fetchRelatedObject() throws StripeException {
return (BalanceSettings) super.fetchRelatedObject(this.relatedObject);
}
/** Retrieve the corresponding full event from the Stripe API. */
@Override
public V1BalanceSettingsUpdatedEvent fetchEvent() throws StripeException {
return (V1BalanceSettingsUpdatedEvent) super.fetchEvent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// File generated from our OpenAPI spec
package com.stripe.events;

import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.billing.CreditBalanceTransaction;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.Event.RelatedObject;
import lombok.Getter;

@Getter
public final class V1BillingCreditBalanceTransactionCreatedEvent extends Event {
@SerializedName("related_object")

/** Object containing the reference to API resource relevant to the event. */
RelatedObject relatedObject;

/** Retrieves the related object from the API. Make an API request on every call. */
public CreditBalanceTransaction fetchRelatedObject() throws StripeException {
return (CreditBalanceTransaction) super.fetchRelatedObject(this.relatedObject);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// File generated from our OpenAPI spec
package com.stripe.events;

import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.billing.CreditBalanceTransaction;
import com.stripe.model.v2.core.Event.RelatedObject;
import com.stripe.model.v2.core.EventNotification;
import lombok.Getter;

@Getter
public final class V1BillingCreditBalanceTransactionCreatedEventNotification
extends EventNotification {
@SerializedName("related_object")

/** Object containing the reference to API resource relevant to the event. */
RelatedObject relatedObject;

/** Retrieves the related object from the API. Make an API request on every call. */
public CreditBalanceTransaction fetchRelatedObject() throws StripeException {
return (CreditBalanceTransaction) super.fetchRelatedObject(this.relatedObject);
}
/** Retrieve the corresponding full event from the Stripe API. */
@Override
public V1BillingCreditBalanceTransactionCreatedEvent fetchEvent() throws StripeException {
return (V1BillingCreditBalanceTransactionCreatedEvent) super.fetchEvent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// File generated from our OpenAPI spec
package com.stripe.events;

import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.billing.CreditGrant;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.Event.RelatedObject;
import lombok.Getter;

@Getter
public final class V1BillingCreditGrantCreatedEvent extends Event {
@SerializedName("related_object")

/** Object containing the reference to API resource relevant to the event. */
RelatedObject relatedObject;

/** Retrieves the related object from the API. Make an API request on every call. */
public CreditGrant fetchRelatedObject() throws StripeException {
return (CreditGrant) super.fetchRelatedObject(this.relatedObject);
}
}
Loading
Loading