Updated donate URL and fetch request

This commit is contained in:
Mitchell McCaffrey 2020-10-17 11:14:24 +11:00
parent e9e7794027
commit b98d95d3a5
3 changed files with 14 additions and 2 deletions

1
.env
View File

@ -1,4 +1,5 @@
REACT_APP_BROKER_URL=http://localhost:9000
REACT_APP_ICE_SERVERS_URL=http://localhost:9000/iceservers
REACT_APP_STRIPE_API_KEY=pk_test_8M3NHrF1eI2b84ubF4F8rSTe0095R3f0My
REACT_APP_STRIPE_URL=http://localhost:9000
REACT_APP_VERSION=$npm_package_version

View File

@ -1,4 +1,5 @@
REACT_APP_BROKER_URL=https://test.owlbear.rodeo
REACT_APP_ICE_SERVERS_URL=https://test.owlbear.rodeo/iceservers
REACT_APP_STRIPE_API_KEY=pk_live_MJjzi5djj524Y7h3fL5PNh4e00a852XD51
REACT_APP_STRIPE_API_KEY=pk_test_8M3NHrF1eI2b84ubF4F8rSTe0095R3f0My
REACT_APP_STRIPE_URL=https://payment.owlbear.rodeo
REACT_APP_VERSION=$npm_package_version

View File

@ -49,7 +49,17 @@ function Donate() {
return;
}
const response = await fetch("/create-session", { method: "POST" });
const response = await fetch(
process.env.REACT_APP_STRIPE_URL + "/create-checkout-session",
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ currency: "usd", amount: value * 100 }),
}
);
const session = await response.json();
const result = await stripe.redirectToCheckout({ sessionId: session.id });