Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fransiskusbenny's avatar

Stripe create payment method Client Side vs Server Side

what is the difference between creating payment method on frontend using stripe.js

stripe.createPaymentMethod({...})

and payment method on server side using stripe php sdk.

PaymentMethod::create([
    'type' => 'card',
    'card' => [
        'number' => '4242 4242 4242',
        'exp_month' => 5,
        'exp_year' => 2025,
        'cvc' => '314',
    ],
]);

what is your recommended, using it on client side or server side?

0 likes
1 reply
drewdan's avatar

I'd recommend picking a convention and sticking with it. Personally I like doing stuff server side, seems a little more secure as people cannot see the code that's being executed, and you'd eventually need to hit the server to store some data too. So might as well do all of the grafting there.

I think the JavaScript library is more for non native web apps? And other front end focussed development. Though I'm not 100% sure on that

Please or to participate in this conversation.