-
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.
Add error handling to payment-processor form
- Loading branch information
1 parent
d94223b
commit cec2260
Showing
1 changed file
with
14 additions
and
5 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,17 +1,26 @@ | ||
// const server = require('stripe'); | ||
// var server = require('stripe'); | ||
|
||
const stripe = Stripe('pk_test_zzdvAwrOg37SAhRt6yik1LTu'); // update with real API key | ||
const elements = stripe.elements(); // create a new instance of elements | ||
var stripe = Stripe('pk_test_zzdvAwrOg37SAhRt6yik1LTu'); // update with real API key | ||
var elements = stripe.elements(); // create a new instance of elements | ||
|
||
|
||
// Custom styling can be passed to options when creating an Element. | ||
const style = { | ||
var style = { | ||
base: { | ||
// Add your base input styles here. For example: | ||
fontSize: '16px', | ||
lineHeight: '24px', | ||
}, | ||
}; | ||
|
||
const card = elements.create('card', { style: style }); | ||
var card = elements.create('card', { style: style }); | ||
card.mount('#card-element'); | ||
|
||
card.addEventListener('change', function(event) { | ||
var displayError = document.getElementById('card-errors'); | ||
if (event.error) { | ||
displayError.textContent = event.error.message; | ||
} else { | ||
displayError.textContent = ''; | ||
} | ||
}); |