Examples of code I've written in PHP, Javascript, SCSS, etc.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

43 líneas
1.0 KiB

  1. <template>
  2. <form id="payment-form" action="">
  3. <label for="name">Name on Card</label>
  4. <input @input="$emit('updateBillingName', $event)" id="billing-name" type="name">
  5. <div id="card-element"></div>
  6. <div id="card-errors"></div>
  7. <div id=save-card>
  8. <input name="save-card" type="checkbox" checked="true">
  9. <label for="">Save Card</label>
  10. </div>
  11. </form>
  12. </template>
  13. <script>
  14. function mountPaymentForm() {
  15. let card = this.stripe.elements().create('card')
  16. card.mount('#card-element')
  17. this.$emit('setCard', card)
  18. card.on('change', function(event) {
  19. let displayError = document.getElementById('card-errors');
  20. if (event.error) {
  21. displayError.textContent = event.error.message;
  22. displayError.textContent = '';
  23. this.$emit('cardValid', true)
  24. } else {
  25. displayError.textContent = '';
  26. this.$emit('cardValid', true)
  27. }
  28. }.bind(this));
  29. }
  30. export default {
  31. data() {
  32. return {billingName: null}
  33. },
  34. methods: {mountPaymentForm},
  35. props: ['stripe'],
  36. mounted: mountPaymentForm,
  37. emits: ['updateBillingName', 'cardValid', 'setCard']
  38. }
  39. </script>