Creating a unique button for STRIPE payments in Laravel 5.1

I have a Stripe payment button in my ecommerce website that looks like this:

<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_yNuawoy0jUqj1GC14jwcQR5d"
data-amount="{{ $total * 100}}"
data-name="dixard"
data-description="Widget"
data-image="https://s3.amazonaws.com/stripe-uploads/acct_14s03fK9wMx3sd9Bmerchant-icon-1416180891533-icona.jpg"
data-locale="auto"
data-currency="eur"
data-id="stripe">
</script>

I am interested in customizing this button using CSS. Is it possible to do so? How can I customize the script with CSS?

Thank you for your assistance!

Answer №1

If you want to style the default button using CSS, unfortunately, that is not possible. However, you can create your own custom button and integrate it with Stripe's Custom Checkout feature. This involves adding some JavaScript code to your webpage to handle the click event on your custom button, which will then trigger the Checkout process.

For a simple example, you can check out this demo: Custom Checkout Demo. The basic idea is to follow a similar approach as shown below:

var handler = StripeCheckout.configure({
  key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
  token: function(token) {
      $("#stripeToken").val(token.id);
      $("#stripeEmail").val(token.email);
      $("#myForm").submit();
  }
});

$('#customButton').on('click', function(e) {
  var amount = $("#amount").val() *100;
  // Initiate Checkout process with additional options
  handler.open({
    name: 'Demo Site',
    description: '2 widgets ($20.00)',
    amount: amount
  });
  e.preventDefault();
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

span tag used within a Twitter Bootstrap 2 modal

Using span structure in modal view is causing overflow issues when using .row, .row-fluid, or spans within the modal. <div id="login_register_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&g ...

I am eager to develop a Loopback model tailored specifically for handling this JSON data

"US Virgin Islands": [ "Charlotte Amalie", "Christiansted", "Frederiksted", "Kingshill", "St John Island" ], I'm currently working with a JSON file that contains country names and corresponding cities. I want to store this data in my database using M ...

Why does i18next only function on http://localhost:3000/de (landing page) in NextJS and not on http://localhost:3000/de/about?

I'm new to this and feeling lost on how to tackle this issue. I tried following the instructions on https://github.com/i18next/next-i18next, but I'm struggling with index.js. When I toggle /de on my landing page, it translates correctly in the UR ...

verifying changes in data with ReactJS

In my coding project, I have a GUser class that is designed to store data from the GitHub API and process it: import axios from "axios"; export default class GUser { constructor(userName) { this.userName=userName; this.getUserData(this ...

Deactivating an asp.net label using client-side scripting

Having a web form with numerous controls and a submit button can be tricky. The issue arises when a user initially submits clean data, resulting in the display of a "form submitted successfully" message using an asp.net label control. However, if the same ...

Encountering issues with browser tabs and Socket.IO

I'm currently working on a real-time chat using Socket.IO, but I've encountered a major issue. The aim is to allow users to log in, select another connected user, and start chatting... var http = require('http'), fs = require(&ap ...

The CSS Grid does not align properly in the horizontal direction when displayed on mobile devices

I am currently working on a responsive layout where the header and footer should each take up around 5% of the screen space and remain fixed. The middle section should scroll based on the number of elements within it. Despite using the fr and % values, the ...

Tips for integrating CSS keyframes in MUI v5 (using emotion)

Hey there! I'm currently working on adding some spinning text, similar to a carousel, using keyframes in my React app. The setup involves MUI v5 with @emotion. Basically, I want a "box" element to show different words every few seconds with a rotating ...

the attempt to substitute an image with a canvas is unsuccessful

I attempted to utilize a function that transforms images into canvas elements. In my approach, I aimed to swap out the generated canvas with the corresponding image by using jQuery's .replaceWith() method, but unfortunately, the process did not yield ...

Ionic - Landscape Mode Causing Alignment Distortion

I'm currently working on designing a grid-based image display for an Ionic Mobile App. One of the main challenges I'm facing is adjusting the heights of the images based on the screen size. I want to set a maximum height for both portrait and lan ...

Issue with ReactJS and Material UI: FlexGrow functionality malfunctioning

I'm currently grappling with the implementation of FlexBox, particularly in understanding how to effectively utilize flexGrow. Despite my efforts, I haven't been able to achieve the desired result as the background appears to only wrap around the ...

Scrollable panel feature in Flexbox

I am attempting to create a design that expands to fill the screen, but allows for scrolling when the content exceeds the available space. My current approach using basic flexbox, as suggested in this answer, successfully fills the screen. However, overfl ...

Having trouble with installing create-react-app for my_app using npm because it seems to be stuck on f

I've hit a roadblock while trying to create a react app on my 2011 MacBook Pro. To start, I downloaded the latest version of Node from their official website. Following the instructions from React documentation, I ran the following commands: npm uni ...

Is my class more specific than my ID when using the parent ID and descendant combinator in CSS specificity?

Could it be that my logic is flawed and this CSS rule is actually valid? Let's break it down: My ID is more specific than my class. Furthermore: My ID is more specific than the parent ID. However: Is parent ID, when combined with the descenda ...

Creating client side scripts for an ajax call to generate a Json object is simple once you understand the basics

Typically, when I make ajax calls, I request pure HTML. However, for various reasons, I require guidance on constructing a table (let's say of individuals and their information) when receiving a Json object. While I am capable of creating a table in J ...

Issues with z-index in a multi-column menu using React-Router are causing unexpected behavior

I am currently working on a multi-tier, multi-column menu created using the https://github.com/kontentino/react-multilevel-dropdown library. However, I am facing an issue where the submenu items are appearing under the main items despite several attempts t ...

Searching for repeated values across disparate object fields?

Inquiring about the method to utilize mongoose for identifying duplicate values across different fields. Providing a sample document for reference: { "followers": { { "_id": "5bf6d610d3a3f31a6c75a9f4" }, ...

Utilize jQuery to animate the hiding of my right sidebar

Looking for help with implementing a jQuery animation to hide the right sidebar on my 3-columns page. I created a demo online here - JsFiddle: http://jsfiddle.net/yhfXX/ In my template, the columns are arranged as follows: menu (on the left) is fixed co ...

Trouble with implementing useEffect to assign value to TextField

I'm currently working on a project where I am using the useEffect hook to retrieve initial data from a database and set it as the initial value of a Material-UI TextField upon loading the page. Although this approach works most of the time, there are ...

Sometimes, IE8 fails to load CSS files properly

This issue is really frustrating me, guys The website displays correctly in Firefox and IE9, but has minor layout problems in Chrome and mobile Safari. When trying to load the page from the server in IE7 or IE8, it's very unreliable. It usually work ...