#sergx_docs

1 messages ¡ Page 1 of 1 (latest)

distant questBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1231971520503484436

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

shrewd riverBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

high breach
#
@section('content')
    <main class="font-inter grid grid-cols-1 sm:grid-cols-2 min-h-screen">
        <section>
            <span>hola</span>
        </section>
        <section class="bg-[#F9FAFB] flex flex-col justify-center">
            <form id="payment-form" class="max-w-lg mx-auto w-full py-20" action="{{ route('stripe.checkout.create-subscription') }}" method="POST">
                @csrf
                <div id="payment-element"></div>
                <div id="address-element"></div>
                <x-ui.button type="submit" class="mt-4 w-full">
                    Pagar
                </x-ui.button>
            </form>
        </section>
    </main>
@endsection

@push('scripts_body')
    <script src="https://js.stripe.com/v3/"></script>
    <script>
        const stripe = Stripe("{{ config('app.stripe_key') }}");
        const clientSecret = "{{ $intent->client_secret }}";
        const appearance = { 
            theme: 'stripe',
        };
        const options = { mode: 'billing' };
        const elements = stripe.elements({ clientSecret, appearance });
        const addressElement = elements.create('address', options);
        const paymentElement = elements.create('payment');
        addressElement.mount('#address-element');
        paymentElement.mount('#payment-element');
    </script>
@endpush
#
public function showCreatingSubscriptionCheckout()
    {
        $user = User::find(auth()->id());
        return view('pages.dashboard.billing.checkout.create-subscription', [
            'user' => $user,
            'intent' => $user->createSetupIntent(),
        ]);
    }
    public function createSubscriptionCheckout(Request $request)
    {
        return dd($request->all());
    }
shrewd riverBOT
subtle pond
#

Hello

#

What data exactly are you looking for here?

high breach
#

Payment Intent and billing details from here

subtle pond
#

What do you want/need it for exactly? All of that information will be associated to the PaymentMethod upon confirmation

high breach
#

When the user fills everything I need to add the payment method and billing details to that customer

#

Then using Laravel Cashier, I need to pass that payment method

subtle pond
#

Let's back up

#

You are trying to set up a Subscription integration?

high breach
#

Yes exactly! I'm creating a custom checkout to allow user subscribes to a plan. The first payment the user won't have a payment method, for that reason I'm using stripe elements and adding the payment element, to get the payment method as well as the billing details and process subscription

subtle pond
#

When you say "the first payment the user won't have a payment method", do you mean you are starting Subscriptions on trial?

high breach
#

The reason why I'm building the checkout manually, is because I will need to add another input VAT, and create customer's tax id (this is not possible to do with Stripe Checkout as required)

#

Nope, there's any free trial. When the user finish their registration, they will be redirect to the checkout to start the payment proceess for the subscription

#
  1. Customer registers > 2. Appears the checkout page (in this moment, customer didn't put any payment method yet) > 3. Collect all payment informtion (including VAT input I will add to create customer's tax id) > 4. Process subscription payment
#

The problem is that I don't know how to process the data

subtle pond
#

Okay well in that case you want to create a SetupIntent and use that to confirm client-side using confirmSetup()

#

All the data you are looking for will be associated to the PaymentMethod that is created when you do that

high breach
#

Alright I understand, so the address will be associated with the payment method

subtle pond
#

Yep

high breach
#

But, also if I would like to update customer's billing details with that address how could I do that?

#

The reason Is because in the invoice, I would like that address to appear as well as the tax id

subtle pond
#

You can just inspect the PaymentMethod and update the Customer in that case

high breach
#

Perfect thank you very much! Another doubt I have. To avoid creating 2 different pages (one checkout for users without payment method, and another one for thouse who have a payment method)

I'm wondering if it's possible with Stripe Elements, to pass the payment method id or something, and auto-fill all the data for users that currently have a payment method

subtle pond
#

Saved PaymentMethods with Payment Element is being worked on as we speak. It should hopefully be available in GA soon. If you are interested in seeing if you can get early access then you can reach out to our Support team via https://support.stripe.com/contact/login

high breach
#

Alright perfect, thank you very much I will try everything!