#paulh92 - stripe js

1 messages ยท Page 1 of 1 (latest)

hardy falcon
#

hey there, can you share a snippet of code and the exact error you get?

analog swan
#

Hi mate as below

#

"message": "No such payment_intent: 'pm_1KFHnwHgUVSiTDjyBAkgXvFA'",
"param": "intent",

im wondering if we need to manually set this intent value

#

var stripe = Stripe('{{env('STRIPE_KEY')}}', { stripeAccount: "{{ connected_account }}" });

#

Set this as it seems to be the thing online setting a missing stripeAccount bit

#

Its on laravel stripe

gentle drift
#

๐Ÿ‘‹ The first thing that's jumping out is that pm_1KFHnwHgUVSiTDjyBAkgXvFA is a Payment Method ID, not a Payment Intent ID. This error also wouldn't be coming from the code that you have in the screenshot (that code is for a setup intent)

analog swan
#

There is a payment handler file i believe also in the controllers

#

Ill have to send that when i get back home

gentle drift
#

Yeah, the code specific to Payment Intents is what you want - it's likely that somewhere in your code you're using the pm_xxx ID instead of the pi_yyy ID

analog swan
#

Not sure if this works but ive pasted the controller here

#

var stripe = Stripe('{{env('STRIPE_KEY')}}', { stripeAccount:"acct_1ECrKYHgUVSiTDjy" });
var elements = stripe.elements();

        var cardElement = elements.create('card', {style: style});
        var displayError = document.getElementById('card-errors');
        var cardHolderName = document.getElementById('cardholder-name');
        var cardButton = document.getElementById('card-button');
        var couponCode = document.getElementById('coupon_code');
        var paymentMethod = document.getElementById('payment_method');
        var clientSecret = cardButton.dataset.secret;
        var form = document.getElementById('payment-form');

        cardElement.mount('#card-element');

        cardButton.addEventListener('click', async (e) => {
            e.preventDefault();
            const {setupIntent, error} = await stripe.handleCardSetup(
                clientSecret, cardElement, {
                    payment_method_data: {
                        billing_details: {name: cardHolderName.value}
                    }
                }
            );
            if (error) {
                displayError.textContent = result.error.message;
            } else {
                paymentMethod.value = setupIntent.payment_method;

                // Submit form or redirect to thank you
                form.submit();
                //window.location.href = window.location.protocol + '//' + window.location.hostname + '/payment/thankyou';
            }

        });
gentle drift
#

Taking a look now!

analog swan
#

Thank you mate, i didnt build this one so a bit clueless on it

gentle drift
#

I believe the issue is specifically with these lines:

return redirect()->route(
    'cashier.payment',
    [$paymentMethod, 'redirect' => route('account.subscription.index')]
);

I haven't used laravel cashier, but it sounds like this is trying to redirect to a payment page but is using the ID of the Payment Method and I don't think you even need those lines. I'd just remove the two places you use that and replace them with

\Auth::user()
    ->newSubscription('main', $plan)
    ->create($paymentMethod);

to create the subscription

analog swan
#

Amazing, ill give that a try when i get home and let you know if it is worked ๐Ÿ˜„

gentle drift
#

๐Ÿ‘