0.0.23 • Published 7 months ago

@magicpay/magicpay-js v0.0.23

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

How to use in React Project

  • Using Magic Link to Launch the hosted page.

  • To Launch the Development Hosted page add 'isSandbox' at tag.

  • To Launch the Production Hosted page do not add 'isSandbox' at tag.

  • To Send Response after Operation in Onsuccess to hosted page, use 'sendEventToChild' function with argument response format of:

    response = {
      'type': 'SUCCESS_RESPONSE',
      'message': 'success message',
    }, 
    response = {
      'type': 'ERROR_RESPONSE',
      'message': 'error message,
    }
  • Use this way to Add MagicLink, Here it's example for react.
  • onSuccess and onError are function which need to pass when component is mounted, for that use 'reference' concept according to framework.
import "@magicpay/magicpay-js";
import {sendEventToChild} from "@magicpay/magicpay-js";
import React, { useRef, useEffect } from 'react';

function App() {
  const link_token = "<example_magic_link_token>";
  const checkout_id = "<example_checkout_object_id>";
  const myRef = useRef(null);
  const onError = (data) => {
    console.log("Error Occured: ", data);
  };
  const onSuccess = (data) => {
    console.log("Success: ", data);
    response = {
      'type': 'SUCCESS_RESPONSE',
      'message': 'successful',
    }
    sendEventToChild(response)
  };
  useEffect(() => {
    const element = myRef.current;
    if (element) {
      element.onSuccess = onSuccess;
      element.onError = onError;
    }
  }, []);
  return (
    <div>
      <magic-link
        checkoutId={checkout_id}
        linkToken={link_token}
        ref={myRef}
        isSandbox
      />
    </div>
  );
}

export default App;

Using Magic Marketing Component

import "@magicpay/magicpay-js";

function App() {
  return (
    <div>
      <magic-info />
    </div>
  );
}

export default App;

Using Magic Button

import "@magicpay/magicpay-js";

function App() {
  const handleButtonClick = () => {
    console.log("Handle Button Click");
  };
  return (
    <div>
      <magic-btn onClick={handleButtonClick} />
    </div>
  );
}

export default App;
0.0.23

7 months ago

0.0.22

7 months ago

0.0.21

7 months ago

0.0.20

7 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago