Created
November 22, 2023 12:30
-
-
Save shlomoweb1/88b41039cd654e3ceaf9184b9fc24512 to your computer and use it in GitHub Desktop.
verifon iframe (react)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useContext, useEffect, useRef } from "react"; | |
| import { DispatchOrderContext } from "./wrapper"; | |
| export const ShowJ5Form = () => { | |
| const { state: { charge: { j5: { url } } } } = useContext(DispatchOrderContext); | |
| const paymentDiv = useRef<HTMLDivElement>() | |
| useEffect(()=>{ | |
| if(!url) { | |
| if(paymentDiv && paymentDiv.current){ | |
| paymentDiv.current.innerHTML = ''; | |
| } | |
| return; | |
| } | |
| const script = document.createElement('script'); | |
| script.src = url + "&containerId=payment_form_container&nocahe=" + (+new Date()); | |
| script.defer = true; | |
| document.body.appendChild(script); | |
| console.log(script) | |
| console.log(script.src) | |
| return () => { | |
| // document.body.removeChild(script); | |
| } | |
| }, [url]) | |
| return ( | |
| <div id="payment_form_container" ref={paymentDiv} style={{height: '150px', background: 'white'}}> | |
| <script defer src={url}></script> | |
| </div> | |
| ) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using docs
https://verifone.cloud/docs/online-payments/checkout/accepting-payments(need to click iframe to see instruction)