Giter VIP home page Giter VIP logo

Comments (5)

0xphilipp avatar 0xphilipp commented on June 12, 2024 1

Thanks for the very fast answer, after looking through available events, I will try to do it this way:

if (stripeEvent.Type == Events.PaymentMethodAttached)
                {
                    var element = stripeEvent.Data.Object as Stripe.PaymentMethod;
                    
                    var service = new CustomerService();
                    var customer = await service.GetAsync(element.CustomerId);
                    if (customer.Address == null)
                    {
                        var address = element.BillingDetails.Address;
                        await service.UpdateAsync(element.CustomerId, new CustomerUpdateOptions()
                        {
                            Address = new AddressOptions()
                            {
                                City = address.City,
                                State = address.State,
                                Country = address.Country,
                                Line1 = address.Line1,
                                Line2 = address.Line2,
                                PostalCode = address.PostalCode
                            }
                        });
                    }
                }

So when the first payment method is attached, I will apply the address to the customer.
Only question is if I'm fast enough, so that the update is done before the invoice is created and sent to the user. I just hope so and will need to check in Live-Mode, as in Dev Mode the email is not created automatically, so the code is always fast enough.

Btw. it would be awesome if one could configure included elements in the webhook definition. Something like, please include the customer in the webhook. (Expand like)

For all finding this post, yes it works and invoices have the right address.

from checkout-single-subscription.

cjavilla-stripe avatar cjavilla-stripe commented on June 12, 2024

Sorry for the delayed response! The billing address will be on the PaymentMethod attached to the Customer.

from checkout-single-subscription.

0xphilipp avatar 0xphilipp commented on June 12, 2024

@cjavilla-stripe Hi, sorry to open the topic up again, but this leads to big issues.
The invoice created from a subscription through checkout does not contain the customer address. I think the reason is, that the customer created by stripe checkout does not have the billing address set, but only contains it on the PaymentMethod.

Do you have any proposal on how to fix it?

from checkout-single-subscription.

cjavilla-stripe avatar cjavilla-stripe commented on June 12, 2024

One option is to update the customer when you receive the checkout.session.completed event.

from checkout-single-subscription.

cjavilla-stripe avatar cjavilla-stripe commented on June 12, 2024

Thanks for the update, @Phmager. Happy to hear this solution works for you.

from checkout-single-subscription.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.