Skip to content
Merged
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 API_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0de52cdca31a7c51c6d11187fc88ab23ea3a1c5b
7019a9a61be5a9cc3ffa998a36dbe33057249d39
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0de52cdca31a7c51c6d11187fc88ab23ea3a1c5b
v2049

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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.v2.core.Account;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.Event.RelatedObject;
import lombok.Getter;
import lombok.Setter;

@Getter
public final class V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent
extends Event {
/** Data for the v2.core.account[configuration.card_creator].capability_status_updated event. */
@SerializedName("data")
V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent.EventData data;

@Getter
@Setter
public static final class EventData {
/**
* Open Enum. The capability which had its status updated.
*
* <p>One of {@code commercial.celtic.charge_card}, {@code commercial.celtic.spend_card}, {@code
* commercial.cross_river_bank.charge_card}, {@code commercial.cross_river_bank.spend_card},
* {@code commercial.stripe.charge_card}, or {@code commercial.stripe.prepaid_card}.
*/
@SerializedName("updated_capability")
String updatedCapability;
}

@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 Account fetchRelatedObject() throws StripeException {
return (Account) super.fetchRelatedObject(this.relatedObject);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.v2.core.Account;
import com.stripe.model.v2.core.Event.RelatedObject;
import com.stripe.model.v2.core.EventNotification;
import lombok.Getter;

@Getter
public final
class V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEventNotification
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 Account fetchRelatedObject() throws StripeException {
return (Account) super.fetchRelatedObject(this.relatedObject);
}
/** Retrieve the corresponding full event from the Stripe API. */
@Override
public V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent fetchEvent()
throws StripeException {
return (V2CoreAccountIncludingConfigurationCardCreatorCapabilityStatusUpdatedEvent)
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.v2.core.Account;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.Event.RelatedObject;
import lombok.Getter;

@Getter
public final class V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent 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 Account fetchRelatedObject() throws StripeException {
return (Account) super.fetchRelatedObject(this.relatedObject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@

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

@Getter
public final class V2BillingBillSettingUpdatedEventNotification extends EventNotification {
public final class V2CoreAccountIncludingConfigurationCardCreatorUpdatedEventNotification
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 BillSetting fetchRelatedObject() throws StripeException {
return (BillSetting) super.fetchRelatedObject(this.relatedObject);
public Account fetchRelatedObject() throws StripeException {
return (Account) super.fetchRelatedObject(this.relatedObject);
}
/** Retrieve the corresponding full event from the Stripe API. */
@Override
public V2BillingBillSettingUpdatedEvent fetchEvent() throws StripeException {
return (V2BillingBillSettingUpdatedEvent) super.fetchEvent();
public V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent fetchEvent()
throws StripeException {
return (V2CoreAccountIncludingConfigurationCardCreatorUpdatedEvent) super.fetchEvent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.stripe.events.V1BillingMeterErrorReportTriggeredEventNotification;
import com.stripe.exception.StripeException;
import com.stripe.model.billing.Meter;
import com.stripe.model.v2.core.Event;
import com.stripe.model.v2.core.EventNotification;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
Expand Down Expand Up @@ -67,33 +66,39 @@ public void handle(HttpExchange exchange) throws IOException {
String sigHeader = exchange.getRequestHeaders().getFirst("Stripe-Signature");

try {
EventNotification eventNotif =
EventNotification notif =
client.parseEventNotification(webhookBody, sigHeader, WEBHOOK_SECRET);

// determine what sort of event you have
if (eventNotif instanceof V1BillingMeterErrorReportTriggeredEventNotification) {
if (notif instanceof V1BillingMeterErrorReportTriggeredEventNotification) {
V1BillingMeterErrorReportTriggeredEventNotification eventNotification =
(V1BillingMeterErrorReportTriggeredEventNotification) eventNotif;
(V1BillingMeterErrorReportTriggeredEventNotification) notif;

// after casting, can fetch the related object (which is correctly typed)
Meter meter = eventNotification.fetchRelatedObject();
System.out.println(meter.getId());
// there's basic info about the related object in the notification
System.out.println(
"Meter w/ id " + eventNotification.getRelatedObject().getId() + " had a problem");

// or you can fetch the full object form the API for more details
Meter meter = eventNotification.fetchRelatedObject();
StringBuilder sb = new StringBuilder();
sb.append("Meter ")
.append(meter.getDisplayName())
.append(" (")
.append(meter.getId())
.append(") had a problem");
System.out.println(sb.toString());

// And you can always fetch the full event:
V1BillingMeterErrorReportTriggeredEvent event = eventNotification.fetchEvent();
System.out.println(event.getData().getDeveloperMessageSummary());

// add additional logic
}
// ... check other event types you know about
else if (eventNotif instanceof UnknownEventNotification) {
UnknownEventNotification unknownEvent = (UnknownEventNotification) eventNotif;
System.out.println("Received unknown event: " + unknownEvent.getId());
// can keep matching on the "type" field
// other helper methods still work, but you'll have to handle types yourself
System.out.println("More info: " + event.getData().getDeveloperMessageSummary());
} else if (notif instanceof UnknownEventNotification) {
// Events that were introduced after this SDK version release are
// represented as `UnknownEventNotification`s.
// They're valid, the SDK just doesn't have corresponding classes for them.
// You must match on the "type" property instead.
UnknownEventNotification unknownEvent = (UnknownEventNotification) notif;
if (unknownEvent.getType().equals("some.new.event")) {
Event event = unknownEvent.fetchEvent();
System.out.println(event.getReason());
// handle
// you can still `.fetchEvent()` and `.fetchRelatedObject()`, but the latter may
// return `null` if that event type doesn't have a related object.
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Error returned when user tries to cancel an OutboundPayment that was already canceled. */
public final class AlreadyCanceledException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** The resource already exists. */
public final class AlreadyExistsException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Returned when the bank account cannot be added due to previous suspicious activity. */
public final class BlockedByStripeException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/**
* Returned when the PayoutMethodBankAccount object is controlled by the Stripe Dashboard, and
* cannot be archived.
*/
public final class ControlledByDashboardException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/**
* Error returned when recipient does not have the active features required to receive funds from
* this OutboundPayment request.
*/
public final class FeatureNotEnabledException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
public final class FinancialAccountNotOpenException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/**
* Error returned when the balance of provided financial account and balance type in the
* OutboundPayment/OutboundTransfer request does not have enough funds.
*/
public final class InsufficientFundsException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import com.stripe.net.StripeResponseGetter;
import lombok.Getter;

/** Information about the error that occurred. */
/**
* Returned in cases where the bank account provided is not valid (wrong format of account number or
* a routing number that does not correspond to a banking institution).
*/
public final class InvalidPaymentMethodException extends ApiException {
private static final long serialVersionUID = 2L;
@Getter String invalidParam;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Returned in cases where the ID provided doesn't correspond to a valid payout method. */
public final class InvalidPayoutMethodException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Error thrown if a user tries to close an account that has non-zero balances. */
public final class NonZeroBalanceException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Error returned when user tries to cancel an OutboundPayment that is not cancelable. */
public final class NotCancelableException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** Returned when attempting to update an archived card. */
public final class QuotaExceededException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/**
* Error returned when the user enables notifications in the OutboundPayment request, but an email
* is not set up on the recipient account.
*/
public final class RecipientNotNotifiableException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.stripe.model.StripeObject;
import com.stripe.net.StripeResponseGetter;

/** Information about the error that occurred. */
/** The temporary session token has expired. */
public final class TemporarySessionExpiredException extends ApiException {
private static final long serialVersionUID = 2L;

Expand Down
Loading
Loading