| 5 | const [sdkReady, setSdkReady] = useState(false); |
| 6 | |
| 7 | const addPaypalSdk = async () => { |
| 8 | const result = await axios.get("/api/config/paypal"); |
| 9 | const clientID = result.data; |
| 10 | const script = document.createElement('script'); |
| 11 | script.type = 'text/javascript'; |
| 12 | script.src = 'https://www.paypal.com/sdk/js?client-id=' + clientID; |
| 13 | script.async = true; |
| 14 | script.onload = () => { |
| 15 | setSdkReady(true); |
| 16 | } |
| 17 | document.body.appendChild(script); |
| 18 | } |
| 19 | |
| 20 | const createOrder = (data, actions) => actions.order.create({ |
| 21 | purchase_units: [ |