Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow public access to ApiRequestParams subclass constructors/fields #1393

Open
shaun-wild opened this issue Jul 18, 2022 · 3 comments
Open
Labels

Comments

@shaun-wild
Copy link

shaun-wild commented Jul 18, 2022

Is your feature request related to a problem? Please describe.

I am using Kotlin and the use of the builders provided on these classes is overly verbose.

Describe the solution you'd like

Make the constructors public, so I can build the objects myself, using Kotlin's Type Safe Builders.

Also, I believe the fields will need to be accessible.

Or even create a Kotlin extensions library with the type-safe builders included.

Describe alternatives you've considered

I've tried creating a wrapper around the builders themselves, but it turned out to be extremely cumbersome.

Additional context

For example, instead of:

val lineItem = SessionCreateParams.LineItem.builder()
            .setPrice(priceID)
            .setQuantity(1)
            .build()

SessionCreateParams.builder().apply {
            setMode(SUBSCRIPTION)
            addPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD)
            addLineItem(lineItem)
            setSuccessUrl("$domainURL/stripe/checkout?sessionID={CHECKOUT_SESSION_ID}&success=true")
            setCancelUrl("$domainURL/stripe/checkout?success=false")
            setAllowPromotionCodes(true)
            setSubscriptionData(subscriptionData)

I could simply do

createSessionParams {
  mode = SUBSCRIPTION
  paymentMethodTypes += CARD
  lineItems = listOf(
    lineItem {
      price = priceID
      quantity = 1
    }
  )
  successUrl = "$domainURL/stripe/checkout?sessionID={CHECKOUT_SESSION_ID}&success=true"
  cancelUrl = "$domainURL/stripe/checkout?success=false"
  allowPromitionCodes = true
  subscriptionData = 
}

But I cannot instantiate the classes myself, as the constructors are private.

@shaun-wild shaun-wild changed the title Allow public access to ApiRequestParams child constructors Allow public access to ApiRequestParams subclass constructors/fields Jul 18, 2022
@shaun-wild
Copy link
Author

Side note: An equals method would be super helpful if we're mocking out Stripe in unit tests!

@pakrym-stripe
Copy link
Contributor

Thank you for your feature request! It's a pretty large change to the design of the library. We'll have to investigate and assess tradeoffs of this change. We might not be able to get to this soon because of other commitments, marking for the future.

@shaun-wild
Copy link
Author

Thanks for your response, I look forward to any updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants