Home > Software engineering >  How to disable card in stripe payment? Only show Apple Pay, google pay
How to disable card in stripe payment? Only show Apple Pay, google pay

Time:07-23

I implemented stripe and it uses JS to auto load a payment form with the following options. Card, Apple Pay/Google Pay, Klarna, Afterpay.

This is good and it works great only thing is it loads very slow.. for a couple secs the page will be blank. So what I want to do now is instead manually collect the card info via a form and pass it to stripe. Ive implemented this fine but how do I disable the other stripe element from asking for card details and only showing Apple Pay/Google Pay, Klarna, Afterpay.

I tried changing this 'payment_method_types' => ['card'],

This is my current code to load buttons `

</script>
        <script defer>
            const stripe_key = '{{ config('app.stripe_key') }}';
            const payment_intent_route = '{{ route('checkout.payment.intent') }}';
            const _token = '{{ csrf_token() }}';
            const place_order_route = '{{ route('checkout.store') }}';
            const order_cancel_route = '{{ route('checkout.cancel') }}';
            const finish_page = '{{ route('checkout.finished') }}';
            const buy_now_mode = '{{ $buy_now_mode ?? 0 }}';
        </script>
        <script src="{{ asset('js/checkout.js') }}" defer></script>

CodePudding user response:

Apple Pay and Google Pay are included in the card payment method type, so you can't disable collecting card details while leaving Apple Pay and Google Pay enabled.

So what I want to do now is instead manually collect the card info via a form and pass it to stripe.

I wanted to warn you that this seems pretty dangerous. It sounds like you're handling raw card details yourself, which opens you up to a significant PCI compliance burden. I strongly recommend you use the Payment Element exclusively to collect card details rather than using your own custom form.

[The Payment Element] loads very slow.. for a couple secs the page will be blank.

I know the current state isn't ideal, but I believe Stripe is working on improving this. You'll get those future improvements instantly, for free, with no further work on your part if you use the Payment Element.

  • Related