PeterF's avatar

Laravel 9 - Cashier/Stripe - Tax Location error

I promise I wont post about his again.... but... still can't make cashier work..... going quietly insane I think...

I create a setupIntent on my Auth::user() and pass it to my blade file.... my blade looks like this

<div class="flex flex-col w-4/5 py-12 pt-6 mx-auto mt-6 bg-gray-200 border-2 shadow-lg align-center">
        <div class='flex mx-auto'>
            <form id="payment-form" action="{{ route('payments.store') }}" method="POST">
                @csrf
                <input type="hidden" name="plan" id="plan" value="{{ request('plan') }}">
                <div id="payment-element">
                    <!-- Elements will create form elements here -->
                </div>
                <button type="submit"
                    class="py-2 my-2 mt-4 text-lg font-bold text-white uppercase transform bg-blue-600 border-2 border-blue-800 rounded-lg hover:scale-110 w-80"
                    id="card-button" data-secret="{{ $intent->client_secret }}">Subscribe
                </button>
                <div id="error-message">
                    <!-- Display error message to your customers here -->
                </div>
            </form>

        </div>
    </div>

    <script>
        const stripe = Stripe('{{ config('cashier.key') }}')
        const options = {
            clientSecret: '{{ $intent->client_secret }}',
            // Fully customizable with appearance API.
            appearance: {
                theme: 'minimal'
            },
        };

        // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in step 2
        const elements = stripe.elements(options);

        // Create and mount the Payment Element

        const paymentElement = elements.create('payment');
        paymentElement.mount('#payment-element');
        
    </script>

The stripe element appears, I enter the test credit card data, it prompts me for a country as well, so I do that too.... but then it fails.... every single time.... with..... a stripe invalidrequestException

The customer cus_Lo9VVOsIkhLQMv's location isn't recognized by the tax engine. Set an address on the customer object and verify with the tax[automatic_tax] status.

Yet, the doco for stripe, implies that it prompts for what it needs... ie... I am in Australia, so it prompts for a country only... in parts of the US you would get a state drop down as well..... I am really lost..... any pointers to working examples or anything would be most welcome.

thanks.

0 likes
3 replies
PeterF's avatar

My Controller looks like this...

public function store(Request $request)
    {
        $user = Auth::user();
        if ($request->user()->id != $user->id) {
            return abort('403');
        }
  
        $plan = Plans::where('identifier', $request->plan)
            ->orWhere('identifier', 'basic')
            ->first();
        Log::info("PaymentController:store -> plan found");
        Log::info("PaymentController:store -> identifier is ".$plan->identifier);
        Log::info("PaymentController:store -> stripe_id is ".$plan->stripe_id);
        Log::info("PaymentController:store -> token is ".$request->token);
 
        $request->user()->newSubscription($plan->identifier, $plan->stripe_id)->create(
            $request->token
        );
        return view('navigation.home');
}
lat4732's avatar

@PeterF I didn't accidentally say "show YOUR controller". This means show your full code.. Anyway, I need the method where you create stripe customer

Please or to participate in this conversation.