Giter Site home page Giter Site logo

stripe-elements's Introduction

Published on webcomponents.org

<stripe-elements>

Polymer wrapper for Stripe.js v3 Elements. Creates a card element ร  la https://stripe.com/docs/elements

Note Before Using

You should make sure to load stripe.js on your app's index.html, as per Stripe's recommendation, before loading <stripe-elements>. If window.Stripe is not available when you load up the component, it will fail with a reasonably-polite console warning.

Usage

<script src="https://js.stripe.com/v3/"></script>

<p>Insert a test key to create the element, then use a <a href="https://stripe.com/docs/testing#cards">test card</a> to generate a token.</p>

<paper-input label="Stripe Publishable Key" value="{{key}}"></paper-input>

<div style="display:flex;">

  <stripe-elements id="stripe" stripe-ready="{{ready}}" publishable-key="[[key]]" token="{{token}}"></stripe-elements>

  <paper-button disabled="[[!ready]]" onclick="stripe.submit();">Get Token</paper-button>

</div>

<paper-toast opened="[[token]]" text="Token received for ๐Ÿ’ณ [[token.card.last4]]! ๐Ÿค‘"></paper-toast>

Styling

A word about nomenclature before we list custom properties and mixins. Stripe v3 Introduces 'Stripe Elements'. These are not custom elements, but rather forms hosted by stripe and injected into your page via an iFrame. When we refer to the 'Stripe Element' in this document, we are referring to the hosted Stripe form, not the <stripe-element> custom element.

The following custom properties and mixins are available for styling the <stripe-elements> component:

Custom property Description Default
--stripe-elements-width Min-width of the stripe-element 300px
--stripe-elements-height Min-width of the stripe-element 50px
--stripe-elements-element Mixin applied to the Stripe Element {}
--stripe-elements-element-focus Mixin applied to the Stripe Element in its focused state. {}
--stripe-elements-element-invalid Mixin applied to the Stripe Element in its invalid state {}
--stripe-elements-element-webkit-autofill Mixin applied to the Stripe Element's webkit autofill. {}

When you apply CSS to the custom properties below, they're parsed and sent to Stripe, who should apply them to the Stripe Element they return in the iFrame.

base styles are inherited by all other variants.
complete styles are applied when the Stripe Element has valid input.
empty styles are applied when the Stripe Element has no user input.
invalid styles are applied when the Stripe Element has invalid input.

Custom property
--stripe-elements-base-color
--stripe-elements-base-font-family
--stripe-elements-base-font-size
--stripe-elements-base-font-smoothing
--stripe-elements-base-font-variant
--stripe-elements-base-icon-color
--stripe-elements-base-line-height
--stripe-elements-base-letter-spacing
--stripe-elements-base-text-decoration
--stripe-elements-base-text-shadow
--stripe-elements-base-text-transform
--stripe-elements-complete-color
--stripe-elements-complete-font-family
--stripe-elements-complete-font-size
--stripe-elements-complete-font-smoothing
--stripe-elements-complete-font-variant
--stripe-elements-complete-icon-color
--stripe-elements-complete-line-height
--stripe-elements-complete-letter-spacing
--stripe-elements-complete-text-decoration
--stripe-elements-complete-text-shadow
--stripe-elements-complete-text-transform
--stripe-elements-empty-color
--stripe-elements-empty-font-family
--stripe-elements-empty-font-size
--stripe-elements-empty-font-smoothing
--stripe-elements-empty-font-variant
--stripe-elements-empty-icon-color
--stripe-elements-empty-line-height
--stripe-elements-empty-letter-spacing
--stripe-elements-empty-text-decoration
--stripe-elements-empty-text-shadow
--stripe-elements-empty-text-transform
--stripe-elements-invalid-color
--stripe-elements-invalid-font-family
--stripe-elements-invalid-font-size
--stripe-elements-invalid-font-smoothing
--stripe-elements-invalid-font-variant
--stripe-elements-invalid-icon-color
--stripe-elements-invalid-line-height
--stripe-elements-invalid-letter-spacing
--stripe-elements-invalid-text-decoration
--stripe-elements-invalid-text-shadow
--stripe-elements-invalid-text-transform

stripe-elements's People

Contributors

bennypowers avatar morbidick avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.