#Luca
1 messages · Page 1 of 1 (latest)
Hello! I suspect you're using the wrong builder, SessionsCreateParams is likely for Checkout hence the different parameters
which would you recommend?
But thats what the documentation is given me
Well setSuccessUrl isn't a paremter on the portal
Should be setReturnUrl: https://stripe.com/docs/customer-management/integrate-customer-portal?architecture-style=resources#redirect
👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
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'
which version of the SDK are you using?
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
Add support for redirect_on_completion, return_url, and ui_mode on Checkout.Session and checkout.SessionCreateParams
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
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
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
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
would you mind sharing the java imports on the top of your file?
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;
```
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
import com.stripe.param.billingportal.SessionCreateParams;
Thanks a lot. I needed the other session import for the webhook thats why i never questioned it. thank you