#Luca

1 messages · Page 1 of 1 (latest)

sterile hamletBOT
dense rivet
#

Hello! I suspect you're using the wrong builder, SessionsCreateParams is likely for Checkout hence the different parameters

subtle axle
#

which would you recommend?
But thats what the documentation is given me

dense rivet
#

Well setSuccessUrl isn't a paremter on the portal

true delta
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

subtle axle
#

Yes, the portal session is not working for me.
The code your colleague provided says:

public String generateCustomerPortalURL(String customerId) throws StripeException {
        Stripe.apiKey = stripeApiKey;

        String URL = "http://localhost:3000/pricing?success=true";

        SessionCreateParams params =
                SessionCreateParams.builder()
                        .setCustomer(customerId)
                        .setReturnUrl("https://example.com/account")
                        .build();

        Session session = Session.create(params);
        return session.getUrl();
    }

But:
Cannot resolve method 'setReturnUrl' in 'Builder'

true delta
#

which version of the SDK are you using?

subtle axle
#

what I need is the window hosted from stripe where the customer can update his payment, add tax ... and change the subscription. not the hard coded link provided from the dashboard.
SDK: 20

true delta
#

Add support for redirect_on_completion, return_url, and ui_mode on Checkout.Session and checkout.SessionCreateParams

subtle axle
#

Change checkout.SessionCreateParams.success_url to be optional

But its not. it is required. when i set it, its asking me for: You must pass either subscription_data or line_items or mode.; request-id: req_zjv3zMZ0bZEYCQ

dense rivet
#

You're trying to use the customer portal here yes? Then Checkout is irrelevant. The issue is you're importing/using the SessionCreateParams.builder() for Checkout, not the customer portal

true delta
#

oh my bad, I read SessionCreate and automatically assumed it's Checkout

#

I'm totally sorry about this

#

But its not. it is required. when i set it, its asking me for: You must pass either subscription_data or line_items or mode.; request-id: req_zjv3zMZ0bZEYCQ
this means that your imports are incorrect

#

would you mind sharing the java imports on the top of your file?

#

they need to reference the correct Session and SessionCreateParams

subtle axle
#

Yes, i tried many things.

Map<String, Object> params = new HashMap<>();
params.put("customer", "cus_OqxUMp7iAiwVQr");
params.put(
  "return_url",
  "https://example.com/account"
);

Session session = Session.create(params);

Official from the docs.
But I get: The return_url parameter can only be used with ui_mode: custom or ui_mode: embedded.; request-id: req_FMSlq4Ba9LLuBy

From custom i get:
Invalid ui_mode: must be one of hosted or embedded; request-id: req_HAWGPdQl8wXu8H

and so on

true delta
#

would you mind sharing the java imports on the top of your file?

subtle axle
#
import com.botbucket.be.api.authentication.AuthenticationService;
import com.botbucket.be.api.stripe.request.CustomerRequest;
import com.botbucket.be.api.stripe.response.*;
import com.botbucket.be.errors.exceptions.BadRequestException;
import com.botbucket.be.persistence.models.users.UserEntity;
import com.botbucket.be.persistence.repositories.UserRepository;
import com.stripe.Stripe;
import com.stripe.exception.SignatureVerificationException;
import com.stripe.exception.StripeException;
import com.stripe.model.*;
import com.stripe.model.checkout.Session;
import com.stripe.net.Webhook;
import com.stripe.param.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import java.util.stream.Collectors;
```
true delta
#

import com.stripe.model.checkout.Session;
this is wrong

#

you need to be importing the CustomerPortal Session one

#

import com.stripe.mode.billingPortal.Session

#

import com.stripe.param.billingportal.SessionCreateParams;

#

you need to be specific about the imports otherwise you would be referencing a totally different entity

subtle axle
#

but which builder now?

#

thank you so far btw

true delta
#

import com.stripe.param.billingportal.SessionCreateParams;

subtle axle
#

Thanks a lot. I needed the other session import for the webhook thats why i never questioned it. thank you