Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

87 lignes
2.0 KiB

  1. <template>
  2. <div class="modal-prompt">
  3. <section class="shadowbox">
  4. <h2>Update Billing</h2>
  5. <prompt v-if="step == 1" :err="err" @ok="() => step++" />
  6. <billing v-if="step == 2" :err="err" :sub="user.sub"/>
  7. <completed v-if="step == 3" :err="err" :status="sub.paymentStatus"/>
  8. </section>
  9. </div>
  10. </template>
  11. <script setup>
  12. import { ref, onMounted } from "vue"
  13. import Dialog from "../dialog.vue"
  14. import Prompt from "./prompt.vue"
  15. import Billing from "./billing.vue"
  16. import Completed from "./completed.vue"
  17. let err = ref("")
  18. const props = defineProps(['user'])
  19. const stripe = Stripe(process.env.STRIPE_KEY)
  20. const step = ref(1)
  21. const token = ref("")
  22. const sub = ref(null)
  23. const clientSecret = new URLSearchParams(window.location.search).get(
  24. 'payment_intent_client_secret'
  25. );
  26. function getCookie(name) {
  27. var re = new RegExp(name + "=([^;]+)")
  28. var value = re.exec(document.cookie)
  29. return (value != null) ? unescape(value[1]) : null
  30. }
  31. function intent(u) {
  32. return
  33. return fetch(`/api/user/subscribe`,
  34. {method: 'POST',
  35. body: JSON.stringify(u),
  36. headers: {
  37. "Accept": "application/json",
  38. "Authorization": `Bearer ${token.value}`,
  39. },
  40. }).then(resp => {
  41. if (resp.ok) {
  42. resp.json().then(s => {
  43. err.value = ""
  44. console.log(s)
  45. sub.value = s
  46. if (["processing", "succeeded"].includes(s.paymentStatus) &&
  47. clientSecret == s.clientSecret) {
  48. step.value = step.value + 2
  49. } else if (s.paymentStatus == "requires_payment_method") {
  50. step.value++
  51. } else {
  52. step.value = 0
  53. }
  54. })
  55. } else {
  56. resp.text().then( e => err.value = e)
  57. }
  58. })
  59. }
  60. onMounted(() => {
  61. console.log(props.user)
  62. })
  63. </script>
  64. <style scoped>
  65. section {
  66. max-width: 400px;
  67. margin: auto;
  68. }
  69. div.modal-prompt .form {
  70. }
  71. </style>