1.1.1 • Published 3 years ago

checkout-frames-react v1.1.1

Weekly downloads
100
License
MIT
Repository
github
Last release
3 years ago

checkout-frames-react Downloads Minified and zipped size

A wrapper Frames.js by Checkout.com covering Frames.js with types and clean API.

  • Written on TypeScript
  • Covers 100% of Frames.js with types
  • Light, zero dependencies

Example

Here is an example similar to Checkout.com official documentation with checkout-frames-react:

import React, { useState } from 'react';
import CheckoutForm, { CardNumberFrame, CVVFrame, ExpiryDateFrame } from 'checkout-frames-react';

const CardForm: React.FC = () => {
  const [cardToken, setCardToken] = useState('');
  const [payButtonDisabled, setPayButtonDisabled] = useState(true);

  const onCardValidationChanged = (valid: boolean): void => {
    setPayButtonDisabled(!valid);
  }

  const onCardTokenized = (token: string): void => {
    setCardToken(token);
  };

  return (
    <>
      <CheckoutForm
        publicKey="pk_test_6ff46046-30af-41d9-bf58-929022d2cd14"
        onCardValidationChanged={onCardValidationChanged}
        onCardTokenized={onCardTokenized}
      >
        <label>
          <span>Card number:</span>
          <CardNumberFrame />
        </label>
        <label>
          <span>Expiry date:</span>
          <ExpiryDateFrame />
        </label>
        <label>
          <span>CVV:</span>
          <CVVFrame />
        </label>

        <button type="submit" disabled={payButtonDisabled}>
          Pay
        </button>
      </CheckoutForm>

      {cardToken ? (
        <p>
        Card tokenization completed
        <br />
        {`Card token: ${cardToken}`}
        </p>
      ) : null}
    </>
  );
};

export default CardForm;
1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

4 years ago

1.0.0-0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago