stripe/stripe-java

PriceCreateParams.Recurring.builder() causing unexpected 400 error.

shanewow opened this issue · 1 comments

Describe the bug

400 error.

POST /v1/prices
Status
400 ERR
ID
req_hxeOWTQL6YsM4A
Time
4/2/23, 1:12:50 PM
IP address
73.28.54.96
API version
2022-11-15
Source
ReactorNetty/1.0.22
Idempotency
Key — 6ee896e6-add2-4901-bf97-28270475288c

invalid_request_error - recurring
Invalid object

Was this useful?

Yes

No
{
"active": "true",
"recurring": "{interval=month}",
"unit_amount_decimal": "6E+1",
"product": "prod_NdlWmg1eB5O4uj",
"currency": "usd",
"nickname": "3 ONE_WEEK"
}
Response body
{
"error": {
"message": "Invalid object",
"param": "recurring",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_hxeOWTQL6YsM4A?t=1680455570",
"type": "invalid_request_error"
}
}
Request POST body
{
"active": "true",
"recurring": "{interval=month}",
"unit_amount_decimal": "6E+1",
"product": "prod_NdlWmg1eB5O4uj",
"currency": "usd",
"nickname": "3 ONE_WEEK"
}

To Reproduce

Use the Recurring class like below to create a new price with a recurring interval of MONTH.

public static PriceCreateParams toPriceParams(ServiceOffer serviceOffer){ return PriceCreateParams.builder() .setCurrency("usd") .setUnitAmountDecimal(serviceOffer.getPrice()) .setProduct(serviceOffer.getType().getStripeProductId()) .setRecurring(PriceCreateParams.Recurring.builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build() ) .build(); }

Expected behavior

Price should be successfully created just as it is with this curl command:

curl https://api.stripe.com/v1/prices \ -u sk_test_*******: \ -d unit_amount_decimal=60.00 \ -d currency=usd \ -d "recurring[interval]"=month \ -d product=prod_NcLGvZUqOUgHGG

Code snippets

No response

OS

macOS

Java version

11

stripe-java version

com.stripe:stripe-java:22.14.0

API version

2022-11-15

Additional context

No response

Sorry guys. I discovered the root cause and it is related to MY code and NOT the Stripe library.