-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26b576b
commit 51e2688
Showing
1 changed file
with
13 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
// Set your publishable key: remember to change this to your live publishable key in production | ||
// See your keys here: https://dashboard.stripe.com/apikeys | ||
const stripe = Stripe('pk_test_51OY9qdSBsBROTHWGSGXJTBcYu35dRhJsFFGj2iI7e7CS4WID4vUsZxCenCK8lmVaOGIVL6V334bPUj8pdkK38Flr00U6rRYMOd'); | ||
|
||
const stripe = Stripe( | ||
"pk_test_51OY9qdSBsBROTHWGSGXJTBcYu35dRhJsFFGj2iI7e7CS4WID4vUsZxCenCK8lmVaOGIVL6V334bPUj8pdkK38Flr00U6rRYMOd" | ||
); | ||
|
||
const options = { | ||
clientSecret: 'pi_3P7CDRSBsBROTHWG09B1BmKK_secret_6c5arXq9n0QZ1b00PMc6t4IgT' | ||
clientSecret: "pi_3P7DQzSBsBROTHWG0WtThewl_secret_CwfJsDWrv3EU7cZfWKyS7KbIT", | ||
}; | ||
|
||
// Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in a previous step | ||
const elements = stripe.elements(options); | ||
|
||
// Create and mount the Payment Element | ||
const paymentElement = elements.create('payment'); | ||
paymentElement.mount('#payment-element'); | ||
|
||
|
||
const paymentElement = elements.create("payment"); | ||
paymentElement.mount("#payment-element"); | ||
|
||
const form = document.getElementById('payment-form'); | ||
const form = document.getElementById("payment-form"); | ||
|
||
form.addEventListener('submit', async (event) => { | ||
form.addEventListener("submit", async (event) => { | ||
event.preventDefault(); | ||
|
||
const {error} = await stripe.confirmPayment({ | ||
const { error } = await stripe.confirmPayment({ | ||
//`Elements` instance that was used to create the Payment Element | ||
elements, | ||
confirmParams: { | ||
return_url: 'https://gentle-pond-023891e10.5.azurestaticapps.net/status', | ||
return_url: "https://gentle-pond-023891e10.5.azurestaticapps.net/status", | ||
description: "Payment for your order", | ||
}, | ||
}); | ||
|
||
if (error) { | ||
// This point will only be reached if there is an immediate error when | ||
// confirming the payment. Show error to your customer (for example, payment | ||
// details incomplete) | ||
const messageContainer = document.querySelector('#error-message'); | ||
const messageContainer = document.querySelector("#error-message"); | ||
messageContainer.textContent = error.message; | ||
} else { | ||
// Your customer will be redirected to your `return_url`. For some payment | ||
// methods like iDEAL, your customer will be redirected to an intermediate | ||
// site first to authorize the payment, then redirected to the `return_url`. | ||
} | ||
}); | ||
}); |