#Suzz

1 messages · Page 1 of 1 (latest)

clear patrolBOT
eager echo
#

i'm using a custom pricing table view suing the react fe and using a checkout asp.net api. in that i'm creating the checkout session

var options = new SessionCreateOptions
{
PaymentMethodTypes = new List<string> { "card" },
SuccessUrl = $"{_baseUrl}/success.html?session_id={{CHECKOUT_SESSION_ID}}",
CancelUrl = $"{_baseUrl}/canceled.html",
Mode = "subscription",
LineItems = new List<SessionLineItemOptions>
{
new()
{
Price = paymentRequest.PriceId,
Quantity = 1
}
}
};

var session = await service.CreateAsync(options);
loud estuary
#

Great, thanks!

eager echo
#

on the success of the message i'm using another api to go to customer-portal

#

var options = new Stripe.BillingPortal.SessionCreateOptions
{
Customer = checkoutSession.CustomerId,
ReturnUrl = _baseUrl
};
var service = new Stripe.BillingPortal.SessionService(_client);
var session = await service.CreateAsync(options);

loud estuary
#

So let me get this straight. You only want a single Subscription for a Customer record?

eager echo
#

yes

#

signle subscritpion for a month

loud estuary
#

So do you know who the Customer is at the time you generate the Checkout Session?

eager echo
#

no

#

how will i set it up?

#

you mean while calling the create-chekout api?

loud estuary
#

Do you have any sort of authentication system that identifies who your user is when they are on your site?

#

Before you create the checkout session

eager echo
#

var list = await new CustomerService().ListAsync(new CustomerListOptions
{
Email = user.Email
});
var options = new SessionCreateOptions
{
PaymentMethodTypes = new List<string> { "card" },
SuccessUrl = $"{_baseUrl}/success.html?session_id={{CHECKOUT_SESSION_ID}}",
CancelUrl = $"{_baseUrl}/canceled.html",
Mode = "subscription",
LineItems = new List<SessionLineItemOptions>
{
new()
{
Price = paymentRequest.PriceId,
Quantity = 1
}
}
};
if (!list.Any())
options.CustomerEmail = user.Email;
else
options.Customer = list.First().Id;

    var service = new SessionService(_client);
    
        var session = await service.CreateAsync(options);
        Console.WriteLine(session.Url);
#

this is the complete code

#

i've setup jwt bearer token

loud estuary
#

The idea is that you would check wether a Subscription already exists before you create a new Subscription

eager echo
#

yes, i already configured it

loud estuary
#

And why is that not doing what you want?

eager echo
#

once the user subscribed how will i know?

loud estuary
#

At what point?

eager echo
#

are there any apis to get the subscribed user?

loud estuary
#

Sure there are webhook events

eager echo
#

on the second login or right after the subscription

eager echo
#

my webhook

loud estuary
#

You can listen to the customer.subscription.created event

eager echo
#

ok

loud estuary
eager echo
#

what should i do when i get thie error from the webhook

#

ok

loud estuary
#

The error message says you are using an expired API key. You should update your API key