0.2.1 • Published 6 months ago

@xstak/xpay-element v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

XPay Embedded Element

XPay Fusion Embedded Element is a PCI DSS compliant solution to collect payments from your customers on your website without them having to redirect to a third party payment page. The @xstak/xpay-element is a React wrapper on top of the XPay Embedded Element SDK.

Example

  1. First install
npm i @xstak/xpay-element
  1. Import XPay provider and add the required keys.
import { XPay } from '@xstak/xpay-element';
    function XPayPayment() {
        return  (
            <XPay xpay={{ publishableKey: "", accountId: "", hmacSecret: ""}}>
                <Payment />
            </XPay>
        )
    }
  1. Import PaymentElement, useXPay hook to render payment element.
import React from 'react';
import { PaymentElement, useXpay } from '@xstak/xpay-element';

export const Payment = () => {
    const options = {
        override: true,
        fields: {
          creditCard: {
            placeholder: "1234 1234 1234 1234",
            label: "Enter your credit card",
          },
          exp: {
            placeholder: "Exp. Date",
          },
        },
        style: {
          ".input": {},
          ".invalid": {},
          ".label": {},
          ":focus": {},
          ":hover": {},
          "::placeholder": {},
          "::selection": {},
        },
      };

    const xpay = useXpay();
    const pay = async() => {
        const { message, error } = await xpay.createPaymentMethod("card", payment_intent_client_secret);
    }
    return(
        <>
        <PaymentElement options={options} onReady={(event) => {
            console.log("ready event", event);
          }} />
        <Button type="primary" onClick={pay}>
          Pay Now
        </Button>
        </>
    )
}

Custom Styling

XPay SDK supports custom styling and changing labels and placeholder texts of input fields as per your design to provide seamless experience to your customers.

Demo

You can start with our pre-configured demo project. You can find project here

Support

XPay React wrapper comes with TypeScript declarations.

0.2.1

6 months ago

0.2.0

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago