0.2.6 • Published 2 years ago

lit-payment-form v0.2.6

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

lit-payment-form

codecov

Simple integration to lit component of the Credit Card Payment Form created by Adam Quinlan on CodePen.

image

Demo

Demo on StackBlitz

Installation

$ npm install lit-payment-form --save

Usage

Use this component by adding the tag to the DOM :

<payment-form></payment-form>

Bind a function to the @checkoutform event to trigger the function on click on the checkout button :

<payment-form @checkoutform="function_here"></payment-form>

Examples

Into an html page

<html lang="en">
<head>
    <title>Payment form</title>
    <script type="module" src="https://cdn.jsdelivr.net/npm/lit-payment-form@latest/dist/lit-payment-form.es.js"></script>
</head>
<body>
<lit-payment-form>
    Title here
</lit-payment-form>
</body>
<script>
    document.querySelector('payment-form').addEventListener('checkoutform', (e) => {
        console.log('form details', e.detail); // {name: '', cardnumber: '', expirationdate: '', securitycode: ''}
    })
</script>
</html>

Into a component

Simple use case :

import 'lit-payment-form';

class MyElement extends LitElement {
  render() {
    return html`<lit-payment-form>Title here</lit-payment-form>`;
  }
}

customElements.define('my-element', MyElement);

Call a function on click on the checkout button :

import 'lit-payment-form';

class MyElement extends LitElement {
  on_checkout_click(e) {
    console.log('form details', e.detail); // {name: '', cardnumber: '', expirationdate: '', securitycode: ''}
  }

  render() {
    return html`<lit-payment-form @checkoutform="on_checkout_click">Title here</lit-payment-form>`;
  }
}

customElements.define('my-element', MyElement);
0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago