Skip to content

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

License

Notifications You must be signed in to change notification settings

tegomass/lit-payment-form

Repository files navigation

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);

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published