Blog

Home / Blog

Stripe payment gateway integration in wordpress without plugin free

Easily accept secure online payments on your WordPress website with Stripe's seamless payment gateway integration. No need for plugins - simply add your custom code for a hassle-free and fee-free payment process.

Stripe payment gateway wordpress plugin

Securely accept payments on your WordPress site with the Stripe Payment Gateway plugin. Seamlessly integrate Stripe's payment processing technology for a smooth and reliable checkout experience for your customers.

Stripe payment gateway integration in WordPress without a plugin allows website owners to accept credit card payments on their website securely and easily. This integration can be done by adding some code snippets to your WordPress website.

Stripe is one of the most popular payment gateways that is known for its simplicity and security. With Stripe, you can easily accept payments from customers around the world in different currencies.

In this article, we will guide you on how to integrate Stripe payment gateway in WordPress without using any plugins for free.

Before we begin the integration process, you need to have a Stripe account. If you don't have one, you can sign up for a free account on the Stripe website.

Step 1: Obtain your Stripe API keys

Once you have created your Stripe account, you will need to obtain your API keys. To do this, log in to your Stripe dashboard and navigate to the Developers section. Here you will find your Publishable key and Secret key.

Step 2: Add Stripe script to your website

To start the integration process, you need to add the Stripe script to your website. You can do this by adding the following code snippet to the header.php file of your WordPress theme:

```html

```

This script will load the Stripe library on your website and make it accessible for further integration.

Step 3: Create a payment form

Next, you need to create a payment form on your website where customers can enter their credit card details. You can create a simple payment form using HTML and CSS. Here is an example of a basic payment form:

```html








```

Step 4: Handle payment processing with PHP

To process payments securely, you need to create a PHP script that will handle the payment processing on the server-side. You can create a file called process_payment.php and add the following code:

```php

require 'vendor/autoload.php';

StripeStripe::setApiKey('YOUR_SECRET_KEY');

$token = $_POST['stripeToken'];

$charge = StripeCharge::create([
'amount' => 1000, // amount in cents
'currency' => 'usd',
'source' => $token,
]);

echo 'Payment successful.';
?>
```

In this script, we are using the Stripe PHP library to handle the payment processing. You should replace 'YOUR_SECRET_KEY' with your own Secret key that you obtained in Step 1.

Step 5: Add JavaScript to handle the payment submission

Lastly, you need to add some JavaScript code to handle the payment submission and send the credit card details securely to the server. Add the following script to your website:

```javascript
var stripe = Stripe('YOUR_PUBLISHABLE_KEY');

var elements = stripe.elements();
var cardElement = elements.create('card');

cardElement.mount('#cardNumber');

var paymentBtn = document.getElementById('paymentBtn');
var paymentForm = document.getElementById('paymentForm');

paymentForm.addEventListener('submit', function(e) {
e.preventDefault();

stripe.createToken(cardElement).then(function(result) {
if (result.error) {
console.log(result.error.message);
} else {
var token = result.token.id;

fetch('process_payment.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'stripeToken': token }),
}).then(function(response) {
return response.text();
}).then(function(data) {
console.log(data);
});
}
});
});
```

Replace 'YOUR_PUBLISHABLE_KEY' with your own Publishable key that you obtained in Step 1.

With this code in place, customers can now enter their credit card details in the payment form and securely process their payments on your website.

In conclusion, integrating Stripe payment gateway in WordPress without using any plugins is a cost-effective and efficient way to accept payments online. By following the steps outlined in this article, you can easily add Stripe payment functionality to your website and provide a seamless checkout experience for your customers.

Remember to always prioritize the security of your customers' payment information by ensuring that your website is SSL secured and that you comply with all relevant data protection regulations. Stripe helps to ensure that all payment transactions are securely processed, giving you peace of mind and building trust with your customers.

Payment gateway integration services

Streamline your online payment process with our expert payment gateway integration services. Securely accept payments and increase conversion rates with ease.