Foxy / foxy-elements

Elements and resources for use in other front-end code, like the admin and customer portal.
https://elements.foxy.dev
MIT License
7 stars 8 forks source link

Credit card entry/update element #140

Closed brettflorio closed 1 week ago

brettflorio commented 8 months ago

The Goal

We need an element that we can add to the customer portal to allow customers to update their payment details. In most cases, this will be a credit/debit card, so we'll need to do the appropriate modern js+iframe approach to ensure the inputs can't be accessed from other scripts on the page. There are 2 primary use cases, related but different:

  1. On the checkout, this element will send data to a Foxy-controlled endpoint, and an encrypted payload will be returned. This encrypted payload will then be submitted when the checkout is submitted, decrypted serverside by Foxy, and handled basically as if a credit card was submitted directly to Foxy. (This is actually fairly similar to how Apple Pay and Google Pay work.)
    • Validation and inline errors will be limited in this case to ensuring the card number passes the luhn check, the expiration is in the future, the security code is 3 or 4 integers, etc. The card isn't actually verified at this step so no additional UI for messaging is required.
  2. On the customer portal, submitting new payment details will (typically) result in the card being verified at that point. The response will not include an encrypted payload. Instead, it will contain a success or error message.

Some of our supported gateways (Stripe, Square, etc.) have their own js/iframe approach. In both the checkout and portal, we'd likely have a container component that loads either this new component of ours or a 3rd party embed/form/whatever.

The Details

Notes from our Slack discussion:

Other Considerations

TBD.

pheekus commented 5 months ago

In progress: https://github.com/Foxy/foxy-elements/tree/feature/tokenization-embed

pheekus commented 1 week ago

Released in v1.27.0