#mariob0310

1 messages · Page 1 of 1 (latest)

upper spireBOT
wild radish
#

The error makes it sound like you passed in an empty string "" instead of the payment method's ID "pm_123". I would recommend printing out the variable that you are passing in just before you make this call to confirm that it is empty and then working backwards to see why it is not getting set properly

solar coyote
#

yes I just printed it, and it is a valid payment Method's ID: Payment intent performed with an ID: pi_3NzfF5Qn6iaCjmZ70K70TW67, methodId: pm_1NzfF4Qn6iaCjmZ73E2tqrY3, and sourceId:

#

sourceId is empty

#

and this is being set inside my checkout.session_completed:
else if (stripeEvent.Type == Events.CheckoutSessionCompleted)
{
try
{
_logger.LogInformation($"StripeWebhook with event type of {stripeEvent.Type}");
var checkoutSession = stripeEvent.Data.Object as Stripe.Checkout.Session;

                    if (checkoutSession.Mode.Equals("payment"))
                    {
                        var paymentIntentService = new PaymentIntentService();
                        var paymentIntent = paymentIntentService.Get(checkoutSession.PaymentIntentId, requestOptions: new RequestOptions() { StripeAccount = stripeEvent.Account });
                        _logger.LogWarning($"Payment intent performed with an ID: {paymentIntent.Id}, methodId: {paymentIntent.PaymentMethodId}, and sourceId: {paymentIntent.SourceId}");
                        var customerService = new CustomerService();
                        var customerOptions = new CustomerUpdateOptions
                        {
                            InvoiceSettings = new CustomerInvoiceSettingsOptions()
                            {
                                DefaultPaymentMethod = paymentIntent.PaymentMethodId
                            }
                        };
                        Customer customer = customerService.Update(checkoutSession.CustomerId, customerOptions, requestOptions: new RequestOptions() { StripeAccount = stripeEvent.Account });
#

omg I think I managed to find the issue...

#

ok, I'll make the change and see will the issue be existing...

#

sorry

#

I just overriden DefaultPaymentId with an empty string some time ago with "HACK" comment, when I attempted to use it so it's my bad. please feel free to close this thread

wild radish
#

Nice! Glad you found it. Can definitely be easy to overwrite the value like that and forget about it later.

solar coyote
#

sure