diff --git a/CHANGELOG.md b/CHANGELOG.md index 33bdaf31..d58a5341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +### v3.35.0 (2025-07-18) +* * * + +### New Resources: +* BillingConfiguration has been added. +* Brand has been added. + +### New Attributes: +* has_children has been added to Hierarchy +* coupon_applicability_mappings has been added to QuotedRamp. + +### New Endpoint: +* listHierarchyDetail has been added to Customer. + +### New Input parameters: +* change_reason children has been added to Entitlement#CreateRequest. +* entitlements[apply_grandfathering] has been added to Entitlement#CreateRequest. +* replace_primary_payment_source has been added to Purchase#CreateRequest. +* omnichannel_subscription has been added to RecordedPurchase#CreateRequest. +* contract_term has been added to Subscription#RemoveScheduledCancellationRequest. +* contract_term_billing_cycle_on_renewal has been added to Subscription#RemoveScheduledCancellationRequest. + +### New Enums: +* payconiq_by_bancontact has been added to PaymentMethodType. +* solidgate has been added to Gateway. +* solidgate has been added to PaymentMethod. + ### v3.34.0 (2025-06-23) * * * diff --git a/README.md b/README.md index 0bbeb02c..0ef6407e 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,64 @@ public class Sample { ``` `isIdempotencyReplayed()` method can be accessed to differentiate between original and replayed requests. + +### Retry HandlingAdd commentMore actions + +Chargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is **disabled by default** but can be **enabled when needed**. + +#### Key features include: + +- **Automatic retries for specific HTTP status codes**: Retries are automatically triggered for status codes `500`, `502`, `503`, and `504`. +- **Exponential backoff**: Retry delays increase exponentially to prevent overwhelming the server. +- **Rate limit management**: If a `429 Too Many Requests` response is received with a `Retry-After` header, the SDK waits for the specified duration before retrying. + > *Note: Exponential backoff and max retries do not apply in this case.* +- **Customizable retry behavior**: Retry logic can be configured using the `retryConfig` parameter in the environment configuration. + +#### Example: Customizing Retry Logic + +You can enable and configure the retry logic by passing a `retryConfig` object when initializing the Chargebee environment: + +```java +import com.chargebee.Environment; +public class Sample { + public static void main(String[] args) throws Exception { + Environment.configure("{site}", "{site_api_key}"); + Environment.defaultConfig().updateRetryConfig( + new com.chargebee.internal.RetryConfig( + true, + 3, + 500, + new java.util.HashSet<>(java.util.Arrays.asList(500)) + ) + ); + // ... your Chargebee API operations ... + } + } + +``` + +#### Example: Rate Limit retry logic + +You can enable and configure the retry logic for rate-limit by passing a `retryConfig` object when initializing the Chargebee environment: + +```java +import com.chargebee.Environment; +public class Sample { + public static void main(String[] args) throws Exception { + Environment.configure("{site}", "{site_api_key}"); + Environment.defaultConfig().updateRetryConfig( + new com.chargebee.internal.RetryConfig( + true, + 3, + 500, + new java.util.HashSet<>(java.util.Arrays.asList(429)) + ) + ); + // ... your Chargebee API operations ... + } + } +``` + ## Contribution *** You may contribute patches to any of the **Active** versions of this library. To do so, raise a PR against the [respective branch](#library-versions). diff --git a/pom.xml b/pom.xml index ae6b9e7d..f94212bb 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.chargebee chargebee-java - 3.34.1-SNAPSHOT + 3.35.0 jar @@ -14,6 +14,14 @@ https://github.com/chargebee/chargebee-java + + + MIT License + https://opensource.org/licenses/MIT + repo + + + ChargeBee http://www.chargebee.com @@ -80,12 +88,6 @@ - - org.sonatype.oss - oss-parent - 9 - - @@ -96,6 +98,16 @@ + + org.sonatype.central + central-publishing-maven-plugin + 0.8.0 + true + + central + false + + org.apache.maven.plugins maven-gpg-plugin diff --git a/src/main/java/com/chargebee/Environment.java b/src/main/java/com/chargebee/Environment.java index d4959bb3..7940c7ff 100644 --- a/src/main/java/com/chargebee/Environment.java +++ b/src/main/java/com/chargebee/Environment.java @@ -38,7 +38,7 @@ public class Environment { public static final String API_VERSION = "v2"; - public static final String LIBRARY_VERSION = "3.34.0"; + public static final String LIBRARY_VERSION = "3.35.0"; private final String apiBaseUrl; diff --git a/src/main/java/com/chargebee/internal/HttpUtil.java b/src/main/java/com/chargebee/internal/HttpUtil.java index cffe8918..5c8b2e20 100644 --- a/src/main/java/com/chargebee/internal/HttpUtil.java +++ b/src/main/java/com/chargebee/internal/HttpUtil.java @@ -45,7 +45,7 @@ public static Result get(String url, Params params, Map headers, url = url + '?' + toQueryStr(params); // fixme: what about url size restrictions ?? } HttpURLConnection conn = createConnection(url, Method.GET, headers, env); - Resp resp = sendRequestWithRetry(conn, env); + Resp resp = sendRequestWithRetry(conn, env, false); return resp.toResult(); } @@ -54,16 +54,22 @@ public static ListResult getList(String url, Params params, Map h url = url + '?' + toQueryStr(params, true); // fixme: what about url size restrictions ?? } HttpURLConnection conn = createConnection(url, Method.GET, headers, env); - Resp resp = sendRequestWithRetry(conn, env); + Resp resp = sendRequestWithRetry(conn, env, false); return resp.toListResult(); } + public static Result post(String url, Params params, Map headers, Environment env, boolean isIdempotent) throws IOException { + return doFormSubmit(url, Method.POST, toQueryStr(params), headers, env, isIdempotent); + } public static Result post(String url, Params params, Map headers, Environment env) throws IOException { - return doFormSubmit(url, Method.POST, toQueryStr(params), headers, env); + return doFormSubmit(url, Method.POST, toQueryStr(params), headers, env, false); } - public static Result post(String url, String content, Map headers, Environment env) throws IOException { - return doFormSubmit(url, Method.POST, content, headers, env); + return doFormSubmit(url, Method.POST, content, headers, env, false); + } + + public static Result post(String url, String content, Map headers, Environment env, boolean isIdempotent) throws IOException { + return doFormSubmit(url, Method.POST, content, headers, env, isIdempotent); } @@ -100,10 +106,10 @@ private static String enc(String val) { } } - private static Result doFormSubmit(String url, Method m, String queryStr, Map headers, Environment env) throws IOException { + private static Result doFormSubmit(String url, Method m, String queryStr, Map headers, Environment env, boolean isIdempotent) throws IOException { HttpURLConnection conn = createConnection(url, m, headers, env); writeContent(conn, queryStr); - Resp resp = sendRequestWithRetry(conn, env); + Resp resp = sendRequestWithRetry(conn, env,isIdempotent); return resp.toResult(); } @@ -129,11 +135,17 @@ static HttpURLConnection createConnection(String url, Method m, Map 0) { + conn.setRequestProperty("X-CB-Retry-Attempt", String.valueOf(attempt)); + if (isIdempotent && conn.getRequestProperty("X-CB-Idempotency-Key") == null) { + conn.setRequestProperty("X-CB-Idempotency-Key", UUID.randomUUID().toString()); + } + } return sendRequest(conn); } catch (Exception e) { int statusCode = extractStatusCode(e); diff --git a/src/main/java/com/chargebee/internal/Request.java b/src/main/java/com/chargebee/internal/Request.java index 124db4f9..dad5609d 100644 --- a/src/main/java/com/chargebee/internal/Request.java +++ b/src/main/java/com/chargebee/internal/Request.java @@ -34,6 +34,11 @@ public Request(Method httpMethod, String uri, String pathParam, String subDomain this.isJsonRequest = isContentTypeJson; } + public U setIdempotency(boolean isIdempotent) { + this.isIdempotent = isIdempotent; + return (U) this; + } + public U param(String paramName, Object value){ params.add(paramName, value); return (U)this; @@ -43,6 +48,7 @@ public Result request() throws Exception { return request(Environment.defaultConfig()); } + public Result request(Environment env) throws Exception { RequestWrap c = new RequestWrap(env, this) { @@ -70,12 +76,12 @@ private static Result _request(Environment env, Request req) throws IOExcepti return HttpUtil.get(url, req.params(), req.headers, env); case POST: if(req instanceof BatchRequest) { - return HttpUtil.post(url, ((BatchRequest) req).buildRequest(), req.headers, env); + return HttpUtil.post(url, ((BatchRequest) req).buildRequest(), req.headers, env, req.isIdempotent); } else if(req.isJsonRequest){ req.headers.put(HttpUtil.CONTENT_TYPE_HEADER_NAME, "application/json;charset=" + Environment.CHARSET); - return HttpUtil.post(url, req.params.toString(), req.headers, env); + return HttpUtil.post(url, req.params.toString(), req.headers, env, req.isIdempotent); }else { - return HttpUtil.post(url, req.params(), req.headers, env); + return HttpUtil.post(url, req.params(), req.headers, env, req.isIdempotent); } default: throw new RuntimeException("Not handled type [" + req.httpMeth + "]"); diff --git a/src/main/java/com/chargebee/internal/RequestBase.java b/src/main/java/com/chargebee/internal/RequestBase.java index 24abd9d8..87d0133d 100644 --- a/src/main/java/com/chargebee/internal/RequestBase.java +++ b/src/main/java/com/chargebee/internal/RequestBase.java @@ -18,6 +18,7 @@ public class RequestBase { protected Map headers = new HashMap(); protected String subDomain; protected boolean isJsonRequest; + protected boolean isIdempotent; public U setIdempotencyKey(String idempotencyKey){ headers.put(IDEMPOTENCY_HEADER, idempotencyKey); diff --git a/src/main/java/com/chargebee/internal/ResultBase.java b/src/main/java/com/chargebee/internal/ResultBase.java index 39ee2415..ebf7c59d 100644 --- a/src/main/java/com/chargebee/internal/ResultBase.java +++ b/src/main/java/com/chargebee/internal/ResultBase.java @@ -132,6 +132,10 @@ public QuotedRamp quotedRamp() { return (QuotedRamp)get("quoted_ramp"); } + public BillingConfiguration billingConfiguration() { + return (BillingConfiguration)get("billing_configuration"); + } + public QuoteLineGroup quoteLineGroup() { return (QuoteLineGroup)get("quote_line_group"); } @@ -340,6 +344,10 @@ public UsageFile usageFile() { return (UsageFile)get("usage_file"); } + public Brand brand() { + return (Brand)get("brand"); + } + public List advanceInvoiceSchedules() { return (List) getList("advance_invoice_schedules", "advance_invoice_schedule"); } @@ -376,10 +384,6 @@ public List inAppSubscriptions() { return (List) getList("in_app_subscriptions", "in_app_subscription"); } - public List differentialPrices() { - return (List) getList("differential_prices", "differential_price"); - } - private List getList(String pluralName, String singularName) { JSONArray listModels = jsonObj.optJSONArray(pluralName); diff --git a/src/main/java/com/chargebee/internal/RetryConfig.java b/src/main/java/com/chargebee/internal/RetryConfig.java index 1d448cba..8b9565b1 100644 --- a/src/main/java/com/chargebee/internal/RetryConfig.java +++ b/src/main/java/com/chargebee/internal/RetryConfig.java @@ -25,6 +25,6 @@ public boolean shouldRetry(int statusCode, int retryCount) { } public static RetryConfig defaultConfig() { - return new RetryConfig(false, 3, 500, new HashSet<>(Arrays.asList(500))); + return new RetryConfig(false, 3, 500, new HashSet<>(Arrays.asList(500, 502, 503, 504))); } } diff --git a/src/main/java/com/chargebee/models/BillingConfiguration.java b/src/main/java/com/chargebee/models/BillingConfiguration.java new file mode 100644 index 00000000..d2629f30 --- /dev/null +++ b/src/main/java/com/chargebee/models/BillingConfiguration.java @@ -0,0 +1,57 @@ +package com.chargebee.models; + +import com.chargebee.*; +import com.chargebee.internal.*; +import com.chargebee.filters.*; +import com.chargebee.filters.enums.SortOrder; +import com.chargebee.internal.HttpUtil.Method; +import com.chargebee.models.enums.*; +import org.json.*; +import java.io.*; +import java.sql.Timestamp; +import java.util.*; + +public class BillingConfiguration extends Resource { + + public static class BillingDate extends Resource { + public BillingDate(JSONObject jsonObj) { + super(jsonObj); + } + + public Timestamp startDate() { + return optTimestamp("start_date"); + } + + public Timestamp endDate() { + return optTimestamp("end_date"); + } + + } + + //Constructors + //============ + + public BillingConfiguration(String jsonStr) { + super(jsonStr); + } + + public BillingConfiguration(JSONObject jsonObj) { + super(jsonObj); + } + + // Fields + //======= + + public Boolean isCalendarBillingEnabled() { + return reqBoolean("is_calendar_billing_enabled"); + } + + public List billingDates() { + return optList("billing_dates", BillingConfiguration.BillingDate.class); + } + + // Operations + //=========== + + +} diff --git a/src/main/java/com/chargebee/models/Brand.java b/src/main/java/com/chargebee/models/Brand.java new file mode 100644 index 00000000..3049fb33 --- /dev/null +++ b/src/main/java/com/chargebee/models/Brand.java @@ -0,0 +1,42 @@ +package com.chargebee.models; + +import com.chargebee.*; +import com.chargebee.internal.*; +import com.chargebee.filters.*; +import com.chargebee.filters.enums.SortOrder; +import com.chargebee.internal.HttpUtil.Method; +import com.chargebee.models.enums.*; +import org.json.*; +import java.io.*; +import java.sql.Timestamp; +import java.util.*; + +public class Brand extends Resource { + + //Constructors + //============ + + public Brand(String jsonStr) { + super(jsonStr); + } + + public Brand(JSONObject jsonObj) { + super(jsonObj); + } + + // Fields + //======= + + public String id() { + return reqString("id"); + } + + public String name() { + return reqString("name"); + } + + // Operations + //=========== + + +} diff --git a/src/main/java/com/chargebee/models/Card.java b/src/main/java/com/chargebee/models/Card.java index a4edca5e..d11cb1d4 100644 --- a/src/main/java/com/chargebee/models/Card.java +++ b/src/main/java/com/chargebee/models/Card.java @@ -65,6 +65,7 @@ public enum PoweredBy { GIROPAY, CARD, LATAM_LOCAL_CARD, + PAYCONIQ, NOT_APPLICABLE, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ diff --git a/src/main/java/com/chargebee/models/CreditNote.java b/src/main/java/com/chargebee/models/CreditNote.java index 0570e37b..cca30e1a 100644 --- a/src/main/java/com/chargebee/models/CreditNote.java +++ b/src/main/java/com/chargebee/models/CreditNote.java @@ -1110,11 +1110,13 @@ private RetrieveRequest(Method httpMeth, String uri) { super(httpMeth, uri); } + @Deprecated public StringFilter lineItemSubscriptionId() { return new StringFilter("line_item[subscription_id]",this); } + @Deprecated public StringFilter lineItemCustomerId() { return new StringFilter("line_item[customer_id]",this); } diff --git a/src/main/java/com/chargebee/models/Customer.java b/src/main/java/com/chargebee/models/Customer.java index 7f38651a..8f6fea30 100644 --- a/src/main/java/com/chargebee/models/Customer.java +++ b/src/main/java/com/chargebee/models/Customer.java @@ -209,7 +209,7 @@ public Boolean sendBillingEmail() { public static class PaymentMethod extends Resource { public enum Type { - CARD,PAYPAL_EXPRESS_CHECKOUT,AMAZON_PAYMENTS,DIRECT_DEBIT,GENERIC,ALIPAY,UNIONPAY,APPLE_PAY,WECHAT_PAY,IDEAL,GOOGLE_PAY,SOFORT,BANCONTACT,GIROPAY,DOTPAY,UPI,NETBANKING_EMANDATES,VENMO,PAY_TO,FASTER_PAYMENTS,SEPA_INSTANT_TRANSFER,AUTOMATED_BANK_TRANSFER,KLARNA_PAY_NOW,ONLINE_BANKING_POLAND, + CARD,PAYPAL_EXPRESS_CHECKOUT,AMAZON_PAYMENTS,DIRECT_DEBIT,GENERIC,ALIPAY,UNIONPAY,APPLE_PAY,WECHAT_PAY,IDEAL,GOOGLE_PAY,SOFORT,BANCONTACT,GIROPAY,DOTPAY,UPI,NETBANKING_EMANDATES,VENMO,PAY_TO,FASTER_PAYMENTS,SEPA_INSTANT_TRANSFER,AUTOMATED_BANK_TRANSFER,KLARNA_PAY_NOW,ONLINE_BANKING_POLAND,PAYCONIQ_BY_BANCONTACT, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ } @@ -822,6 +822,11 @@ public static HierarchyRequest hierarchy(String id) { return new HierarchyRequest(Method.GET, uri); } + public static CustomerListHierarchyDetailRequest listHierarchyDetail(String id) { + String uri = uri("customers", nullCheck(id), "hierarchy_detail"); + return new CustomerListHierarchyDetailRequest(uri); + } + public static UpdateHierarchySettingsRequest updateHierarchySettings(String id) { String uri = uri("customers", nullCheck(id), "update_hierarchy_settings"); return new UpdateHierarchySettingsRequest(Method.POST, uri); @@ -2624,6 +2629,24 @@ public Params params() { } } + public static class CustomerListHierarchyDetailRequest extends ListRequest { + + private CustomerListHierarchyDetailRequest(String uri) { + super(uri); + } + + public CustomerListHierarchyDetailRequest hierarchyOperationType(com.chargebee.models.enums.HierarchyOperationType hierarchyOperationType) { + params.add("hierarchy_operation_type", hierarchyOperationType); + return this; + } + + + @Override + public Params params() { + return params; + } + } + public static class UpdateHierarchySettingsRequest extends Request { private UpdateHierarchySettingsRequest(Method httpMeth, String uri) { diff --git a/src/main/java/com/chargebee/models/Entitlement.java b/src/main/java/com/chargebee/models/Entitlement.java index 255c206b..5ad77ee0 100644 --- a/src/main/java/com/chargebee/models/Entitlement.java +++ b/src/main/java/com/chargebee/models/Entitlement.java @@ -135,6 +135,12 @@ public CreateRequest action(com.chargebee.models.enums.Action action) { } + public CreateRequest changeReason(String changeReason) { + params.addOpt("change_reason", changeReason); + return this; + } + + public CreateRequest entitlementEntityId(int index, String entitlementEntityId) { params.add("entitlements[entity_id][" + index + "]", entitlementEntityId); return this; @@ -151,6 +157,10 @@ public CreateRequest entitlementValue(int index, String entitlementValue) { params.addOpt("entitlements[value][" + index + "]", entitlementValue); return this; } + public CreateRequest entitlementApplyGrandfathering(int index, Boolean entitlementApplyGrandfathering) { + params.addOpt("entitlements[apply_grandfathering][" + index + "]", entitlementApplyGrandfathering); + return this; + } @Override public Params params() { return params; diff --git a/src/main/java/com/chargebee/models/Estimate.java b/src/main/java/com/chargebee/models/Estimate.java index ad560cdd..62935900 100644 --- a/src/main/java/com/chargebee/models/Estimate.java +++ b/src/main/java/com/chargebee/models/Estimate.java @@ -68,12 +68,12 @@ public List unbilledChargeEstimates() { public static CreateSubscriptionRequest createSubscription() { String uri = uri("estimates", "create_subscription"); - return new CreateSubscriptionRequest(Method.POST, uri); + return new CreateSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static CreateSubItemEstimateRequest createSubItemEstimate() { String uri = uri("estimates", "create_subscription_for_items"); - return new CreateSubItemEstimateRequest(Method.POST, uri); + return new CreateSubItemEstimateRequest(Method.POST, uri).setIdempotency(false); } public static CreateSubForCustomerEstimateRequest createSubForCustomerEstimate(String id) { @@ -83,17 +83,17 @@ public static CreateSubForCustomerEstimateRequest createSubForCustomerEstimate(S public static CreateSubItemForCustomerEstimateRequest createSubItemForCustomerEstimate(String id) { String uri = uri("customers", nullCheck(id), "create_subscription_for_items_estimate"); - return new CreateSubItemForCustomerEstimateRequest(Method.POST, uri); + return new CreateSubItemForCustomerEstimateRequest(Method.POST, uri).setIdempotency(false); } public static UpdateSubscriptionRequest updateSubscription() { String uri = uri("estimates", "update_subscription"); - return new UpdateSubscriptionRequest(Method.POST, uri); + return new UpdateSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static UpdateSubscriptionForItemsRequest updateSubscriptionForItems() { String uri = uri("estimates", "update_subscription_for_items"); - return new UpdateSubscriptionForItemsRequest(Method.POST, uri); + return new UpdateSubscriptionForItemsRequest(Method.POST, uri).setIdempotency(false); } public static RenewalEstimateRequest renewalEstimate(String id) { @@ -103,12 +103,12 @@ public static RenewalEstimateRequest renewalEstimate(String id) { public static AdvanceInvoiceEstimateRequest advanceInvoiceEstimate(String id) { String uri = uri("subscriptions", nullCheck(id), "advance_invoice_estimate"); - return new AdvanceInvoiceEstimateRequest(Method.POST, uri); + return new AdvanceInvoiceEstimateRequest(Method.POST, uri).setIdempotency(false); } public static RegenerateInvoiceEstimateRequest regenerateInvoiceEstimate(String id) { String uri = uri("subscriptions", nullCheck(id), "regenerate_invoice_estimate"); - return new RegenerateInvoiceEstimateRequest(Method.POST, uri); + return new RegenerateInvoiceEstimateRequest(Method.POST, uri).setIdempotency(false); } public static Request upcomingInvoicesEstimate(String id) { @@ -118,47 +118,47 @@ public static Request upcomingInvoicesEstimate(String id) { public static ChangeTermEndRequest changeTermEnd(String id) { String uri = uri("subscriptions", nullCheck(id), "change_term_end_estimate"); - return new ChangeTermEndRequest(Method.POST, uri); + return new ChangeTermEndRequest(Method.POST, uri).setIdempotency(false); } public static CancelSubscriptionRequest cancelSubscription(String id) { String uri = uri("subscriptions", nullCheck(id), "cancel_subscription_estimate"); - return new CancelSubscriptionRequest(Method.POST, uri); + return new CancelSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static CancelSubscriptionForItemsRequest cancelSubscriptionForItems(String id) { String uri = uri("subscriptions", nullCheck(id), "cancel_subscription_for_items_estimate"); - return new CancelSubscriptionForItemsRequest(Method.POST, uri); + return new CancelSubscriptionForItemsRequest(Method.POST, uri).setIdempotency(false); } public static PauseSubscriptionRequest pauseSubscription(String id) { String uri = uri("subscriptions", nullCheck(id), "pause_subscription_estimate"); - return new PauseSubscriptionRequest(Method.POST, uri); + return new PauseSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static ResumeSubscriptionRequest resumeSubscription(String id) { String uri = uri("subscriptions", nullCheck(id), "resume_subscription_estimate"); - return new ResumeSubscriptionRequest(Method.POST, uri); + return new ResumeSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static GiftSubscriptionRequest giftSubscription() { String uri = uri("estimates", "gift_subscription"); - return new GiftSubscriptionRequest(Method.POST, uri); + return new GiftSubscriptionRequest(Method.POST, uri).setIdempotency(false); } public static GiftSubscriptionForItemsRequest giftSubscriptionForItems() { String uri = uri("estimates", "gift_subscription_for_items"); - return new GiftSubscriptionForItemsRequest(Method.POST, uri); + return new GiftSubscriptionForItemsRequest(Method.POST, uri).setIdempotency(false); } public static CreateInvoiceRequest createInvoice() { String uri = uri("estimates", "create_invoice"); - return new CreateInvoiceRequest(Method.POST, uri); + return new CreateInvoiceRequest(Method.POST, uri).setIdempotency(false); } public static CreateInvoiceForItemsRequest createInvoiceForItems() { String uri = uri("estimates", "create_invoice_for_items"); - return new CreateInvoiceForItemsRequest(Method.POST, uri); + return new CreateInvoiceForItemsRequest(Method.POST, uri).setIdempotency(false); } public static PaymentSchedulesRequest paymentSchedules() { diff --git a/src/main/java/com/chargebee/models/Hierarchy.java b/src/main/java/com/chargebee/models/Hierarchy.java index 8a8134be..89ecd545 100644 --- a/src/main/java/com/chargebee/models/Hierarchy.java +++ b/src/main/java/com/chargebee/models/Hierarchy.java @@ -43,6 +43,10 @@ public String invoiceOwnerId() { return reqString("invoice_owner_id"); } + public Boolean hasChildren() { + return optBoolean("has_children"); + } + public List childrenIds() { return optList("children_ids", String.class); } diff --git a/src/main/java/com/chargebee/models/Invoice.java b/src/main/java/com/chargebee/models/Invoice.java index 0d68f725..a08b1489 100644 --- a/src/main/java/com/chargebee/models/Invoice.java +++ b/src/main/java/com/chargebee/models/Invoice.java @@ -3780,11 +3780,13 @@ private RetrieveRequest(Method httpMeth, String uri) { super(httpMeth, uri); } + @Deprecated public StringFilter lineItemSubscriptionId() { return new StringFilter("line_item[subscription_id]",this); } + @Deprecated public StringFilter lineItemCustomerId() { return new StringFilter("line_item[customer_id]",this); } diff --git a/src/main/java/com/chargebee/models/PaymentIntent.java b/src/main/java/com/chargebee/models/PaymentIntent.java index 67633a3b..5bce3805 100644 --- a/src/main/java/com/chargebee/models/PaymentIntent.java +++ b/src/main/java/com/chargebee/models/PaymentIntent.java @@ -44,6 +44,7 @@ public enum PaymentMethodType { SEPA_INSTANT_TRANSFER, KLARNA_PAY_NOW, ONLINE_BANKING_POLAND, + PAYCONIQ_BY_BANCONTACT, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ } diff --git a/src/main/java/com/chargebee/models/Purchase.java b/src/main/java/com/chargebee/models/Purchase.java index c5826b8f..5ebd153f 100644 --- a/src/main/java/com/chargebee/models/Purchase.java +++ b/src/main/java/com/chargebee/models/Purchase.java @@ -61,7 +61,7 @@ public static CreateRequest create() { public static EstimateRequest estimate() { String uri = uri("purchases", "estimate"); - return new EstimateRequest(Method.POST, uri); + return new EstimateRequest(Method.POST, uri).setIdempotency(false); } @@ -86,6 +86,12 @@ public CreateRequest paymentSourceId(String paymentSourceId) { } + public CreateRequest replacePrimaryPaymentSource(Boolean replacePrimaryPaymentSource) { + params.addOpt("replace_primary_payment_source", replacePrimaryPaymentSource); + return this; + } + + public CreateRequest invoiceInfoPoNumber(String invoiceInfoPoNumber) { params.addOpt("invoice_info[po_number]", invoiceInfoPoNumber); return this; diff --git a/src/main/java/com/chargebee/models/QuotedRamp.java b/src/main/java/com/chargebee/models/QuotedRamp.java index 844b91ae..c1dac7bd 100644 --- a/src/main/java/com/chargebee/models/QuotedRamp.java +++ b/src/main/java/com/chargebee/models/QuotedRamp.java @@ -115,22 +115,6 @@ public String rampTierId() { return optString("ramp_tier_id"); } - public Long discountAmount() { - return optLong("discount_amount"); - } - - public String mdDiscountAmount() { - return optString("md_discount_amount"); - } - - public Long itemLevelDiscountAmount() { - return optLong("item_level_discount_amount"); - } - - public String mdItemLevelDiscountAmount() { - return optString("md_item_level_discount_amount"); - } - public Long discountPerBillingCycle() { return optLong("discount_per_billing_cycle"); } @@ -147,14 +131,6 @@ public String itemLevelDiscountPerBillingCycleInDecimal() { return optString("item_level_discount_per_billing_cycle_in_decimal"); } - public Long netAmount() { - return optLong("net_amount"); - } - - public String mdNetAmount() { - return optString("md_net_amount"); - } - public Long amountPerBillingCycle() { return optLong("amount_per_billing_cycle"); } @@ -198,12 +174,6 @@ public enum ApplyOn { java-client version incompatibility. We suggest you to upgrade to the latest version */ } - public enum ApplyOnItemType { - PLAN,ADDON,CHARGE, - _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a - java-client version incompatibility. We suggest you to upgrade to the latest version */ - } - public Discount(JSONObject jsonObj) { super(jsonObj); } @@ -212,10 +182,6 @@ public String id() { return reqString("id"); } - public String name() { - return reqString("name"); - } - public String invoiceName() { return optString("invoice_name"); } @@ -260,10 +226,6 @@ public ApplyOn applyOn() { return reqEnum("apply_on", ApplyOn.class); } - public ApplyOnItemType applyOnItemType() { - return optEnum("apply_on_item_type", ApplyOnItemType.class); - } - public String itemPriceId() { return optString("item_price_id"); } @@ -287,6 +249,12 @@ public Timestamp endDate() { } public static class ItemTier extends Resource { + public enum PricingType { + PER_UNIT,FLAT_FEE,PACKAGE, + _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a + java-client version incompatibility. We suggest you to upgrade to the latest version */ + } + public ItemTier(JSONObject jsonObj) { super(jsonObj); } @@ -323,6 +291,29 @@ public String rampTierId() { return optString("ramp_tier_id"); } + public PricingType pricingType() { + return optEnum("pricing_type", PricingType.class); + } + + public Integer packageSize() { + return optInteger("package_size"); + } + + } + + public static class CouponApplicabilityMapping extends Resource { + public CouponApplicabilityMapping(JSONObject jsonObj) { + super(jsonObj); + } + + public String couponId() { + return optString("coupon_id"); + } + + public List applicableItemPriceIds() { + return optList("applicable_item_price_ids", String.class); + } + } //Constructors @@ -355,6 +346,10 @@ public List itemTiers() { return optList("item_tiers", QuotedRamp.ItemTier.class); } + public List couponApplicabilityMappings() { + return optList("coupon_applicability_mappings", QuotedRamp.CouponApplicabilityMapping.class); + } + // Operations //=========== diff --git a/src/main/java/com/chargebee/models/RecordedPurchase.java b/src/main/java/com/chargebee/models/RecordedPurchase.java index 757f4d4f..1f4b35b3 100644 --- a/src/main/java/com/chargebee/models/RecordedPurchase.java +++ b/src/main/java/com/chargebee/models/RecordedPurchase.java @@ -159,6 +159,11 @@ public CreateRequest googlePlayStorePurchaseToken(String googlePlayStorePurchase return this; } + public CreateRequest omnichannelSubscriptionId(String omnichannelSubscriptionId) { + params.addOpt("omnichannel_subscription[id]", omnichannelSubscriptionId); + return this; + } + @Override public Params params() { return params; diff --git a/src/main/java/com/chargebee/models/Subscription.java b/src/main/java/com/chargebee/models/Subscription.java index 3fdbf342..7c5b798d 100644 --- a/src/main/java/com/chargebee/models/Subscription.java +++ b/src/main/java/com/chargebee/models/Subscription.java @@ -3071,6 +3071,22 @@ public RemoveScheduledCancellationRequest billingCycles(Integer billingCycles) { } + public RemoveScheduledCancellationRequest contractTermBillingCycleOnRenewal(Integer contractTermBillingCycleOnRenewal) { + params.addOpt("contract_term_billing_cycle_on_renewal", contractTermBillingCycleOnRenewal); + return this; + } + + + public RemoveScheduledCancellationRequest contractTermActionAtTermEnd(ContractTerm.ActionAtTermEnd contractTermActionAtTermEnd) { + params.addOpt("contract_term[action_at_term_end]", contractTermActionAtTermEnd); + return this; + } + + public RemoveScheduledCancellationRequest contractTermCancellationCutoffPeriod(Integer contractTermCancellationCutoffPeriod) { + params.addOpt("contract_term[cancellation_cutoff_period]", contractTermCancellationCutoffPeriod); + return this; + } + @Override public Params params() { return params; diff --git a/src/main/java/com/chargebee/models/UnbilledCharge.java b/src/main/java/com/chargebee/models/UnbilledCharge.java index cd4b0732..0f44d6ee 100644 --- a/src/main/java/com/chargebee/models/UnbilledCharge.java +++ b/src/main/java/com/chargebee/models/UnbilledCharge.java @@ -218,7 +218,7 @@ public static UnbilledChargeListRequest list() { public static InvoiceNowEstimateRequest invoiceNowEstimate() { String uri = uri("unbilled_charges", "invoice_now_estimate"); - return new InvoiceNowEstimateRequest(Method.POST, uri); + return new InvoiceNowEstimateRequest(Method.POST, uri).setIdempotency(false); } diff --git a/src/main/java/com/chargebee/models/UsageEvent.java b/src/main/java/com/chargebee/models/UsageEvent.java index 63b9b03e..deb3f48d 100644 --- a/src/main/java/com/chargebee/models/UsageEvent.java +++ b/src/main/java/com/chargebee/models/UsageEvent.java @@ -48,12 +48,12 @@ public Map properties() { public static CreateRequest create() { String uri = uri("usage_events"); - return new CreateRequest(Method.POST, uri); + return new CreateRequest(Method.POST, uri).setIdempotency(false); } public static BatchIngestRequest batchIngest() { String uri = uri("batch", "usage_events"); - return new BatchIngestRequest(Method.POST, uri); + return new BatchIngestRequest(Method.POST, uri).setIdempotency(false); } diff --git a/src/main/java/com/chargebee/models/UsageFile.java b/src/main/java/com/chargebee/models/UsageFile.java index e020cd33..264a94c5 100644 --- a/src/main/java/com/chargebee/models/UsageFile.java +++ b/src/main/java/com/chargebee/models/UsageFile.java @@ -117,7 +117,7 @@ public UsageFile.UploadDetail uploadDetails() { public static UploadRequest upload() { String uri = uri("usage_files", "upload"); - return new UploadRequest(Method.POST, uri); + return new UploadRequest(Method.POST, uri).setIdempotency(false); } public static Request status(String id) { diff --git a/src/main/java/com/chargebee/models/enums/Gateway.java b/src/main/java/com/chargebee/models/enums/Gateway.java index 4c04b151..1b6cb891 100644 --- a/src/main/java/com/chargebee/models/enums/Gateway.java +++ b/src/main/java/com/chargebee/models/enums/Gateway.java @@ -51,6 +51,7 @@ public enum Gateway { EBANX, DLOCAL, NUVEI, + SOLIDGATE, PAYSTACK, JP_MORGAN, GOCARDLESS, diff --git a/src/main/java/com/chargebee/models/enums/PaymentMethod.java b/src/main/java/com/chargebee/models/enums/PaymentMethod.java index 9c84c025..08e48a67 100644 --- a/src/main/java/com/chargebee/models/enums/PaymentMethod.java +++ b/src/main/java/com/chargebee/models/enums/PaymentMethod.java @@ -33,6 +33,7 @@ public enum PaymentMethod { AUTOMATED_BANK_TRANSFER, KLARNA_PAY_NOW, ONLINE_BANKING_POLAND, + PAYCONIQ_BY_BANCONTACT, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ } \ No newline at end of file diff --git a/src/main/java/com/chargebee/models/enums/PaymentMethodType.java b/src/main/java/com/chargebee/models/enums/PaymentMethodType.java index 0b49bc34..da6f67ae 100644 --- a/src/main/java/com/chargebee/models/enums/PaymentMethodType.java +++ b/src/main/java/com/chargebee/models/enums/PaymentMethodType.java @@ -25,6 +25,7 @@ public enum PaymentMethodType { AUTOMATED_BANK_TRANSFER, KLARNA_PAY_NOW, ONLINE_BANKING_POLAND, + PAYCONIQ_BY_BANCONTACT, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ } \ No newline at end of file diff --git a/src/main/java/com/chargebee/models/enums/Type.java b/src/main/java/com/chargebee/models/enums/Type.java index cf89f00e..2f7917ff 100644 --- a/src/main/java/com/chargebee/models/enums/Type.java +++ b/src/main/java/com/chargebee/models/enums/Type.java @@ -25,6 +25,7 @@ public enum Type { AUTOMATED_BANK_TRANSFER, KLARNA_PAY_NOW, ONLINE_BANKING_POLAND, + PAYCONIQ_BY_BANCONTACT, _UNKNOWN; /*Indicates unexpected value for this enum. You can get this when there is a java-client version incompatibility. We suggest you to upgrade to the latest version */ } \ No newline at end of file diff --git a/src/test/java/com/chargebee/internal/HttpUtilRetryTest.java b/src/test/java/com/chargebee/internal/HttpUtilRetryTest.java index ae092c03..9272cc65 100644 --- a/src/test/java/com/chargebee/internal/HttpUtilRetryTest.java +++ b/src/test/java/com/chargebee/internal/HttpUtilRetryTest.java @@ -162,7 +162,7 @@ void testRetryOnPostRequest() throws IOException { mockedHttpUtil.when(() -> HttpUtil.createConnection(eq(url), eq(HttpUtil.Method.POST), eq(headers), eq(env))) .thenAnswer(invocation -> callCount.getAndIncrement() == 0 ? mockConn1 : mockConn2); - assertDoesNotThrow(() -> HttpUtil.post(url, params, headers, env)); + assertDoesNotThrow(() -> HttpUtil.post(url, params, headers, env, true)); } }