11
Apr
How to integrate Stripe Pyament into website ?
Let me explain the simple method of Integration of Stripe Payment .
1. Put the Stripe.js in your footer or head tag where all the JavaScript reside
<script src="https://js.stripe.com/v3/"></script>
2. Put some html code at website page where you want to show Payment button
<form id="payment-form"><br />
<div id="card-element"><!--Stripe.js injects the Card Element--></div><br />
<button id="submit"></button></p>
<p><div class="spinner hidden" id="spinner"> </div><br />
<button id="submit"><span id="button-text">Pay</span></button></p>
</form>
3. initialize the stripe with your publishable API keys .
var stripe = Stripe("pk_test_TYooMQauvdEDq54NiTphI7jx");
4. put the server code for stripe API calling
install the stripe payment library for PHP
composer require stripe/stripe-php
intialize stripe payment api
\Stripe\Stripe::setApiKey('api key goes here');
call stripe api
stripe
.confirmCardPayment(clientSecret, {
payment_method: {
card: card
}
})
provide response to ajax call
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
Thats it !