diff --git a/api/application.js b/api/application.js index 14f4219..d9e4ba1 100644 --- a/api/application.js +++ b/api/application.js @@ -95,7 +95,7 @@ const confirmationEmail = (application) => {

What happens next?

    -
  1. Complete your registration payment (if you haven't already)
  2. +
  3. Complete your registration payment (if you haven't already)
  4. Our team will review your application
  5. We may reach out with follow-up questions
  6. You'll receive a decision within 2-3 weeks
  7. diff --git a/api/mollie.js b/api/mollie.js index ba35ded..bad6a2b 100644 --- a/api/mollie.js +++ b/api/mollie.js @@ -437,8 +437,72 @@ async function getPaymentStatus(req, res) { } } +// Resume payment โ€” re-creates a Mollie payment for unpaid applications and redirects to checkout +async function resumePayment(req, res) { + res.setHeader('Access-Control-Allow-Origin', '*'); + + try { + const { id } = req.query; + if (!id) { + return res.status(400).json({ error: 'Missing application id' }); + } + + const result = await pool.query( + `SELECT id, first_name, last_name, email, payment_status, payment_amount, + accommodation_type, contribution_amount + FROM applications WHERE id = $1`, + [id] + ); + + if (result.rows.length === 0) { + return res.status(404).json({ error: 'Application not found' }); + } + + const app = result.rows[0]; + + // Already paid โ€” redirect to status page + if (app.payment_status === 'paid') { + return res.redirect(`/payment-return.html?id=${app.id}`); + } + + // Look up the original Mollie payment to get metadata (weeks, ticket type) + let weeksCount = 1; + let selectedWeeks = []; + const existingPayment = await pool.query( + 'SELECT mollie_payment_id FROM applications WHERE id = $1 AND mollie_payment_id IS NOT NULL', + [id] + ); + if (existingPayment.rows.length > 0 && existingPayment.rows[0].mollie_payment_id) { + try { + const oldPayment = await mollieClient.payments.get(existingPayment.rows[0].mollie_payment_id); + weeksCount = oldPayment.metadata.weeksCount || 1; + selectedWeeks = oldPayment.metadata.selectedWeeks || []; + } catch (e) { + console.error('Failed to fetch old payment metadata:', e.message); + } + } + + // Create a fresh Mollie payment + const paymentResult = await createPayment( + app.id, + app.contribution_amount || 'registration', + weeksCount, + app.email, + app.first_name, + app.last_name, + app.accommodation_type, + selectedWeeks + ); + + return res.redirect(paymentResult.checkoutUrl); + } catch (error) { + console.error('Resume payment error:', error); + return res.status(500).json({ error: 'Failed to resume payment. Please contact team@valleyofthecommons.com' }); + } +} + module.exports = { - createPayment, handleWebhook, getPaymentStatus, + createPayment, handleWebhook, getPaymentStatus, resumePayment, PRICE_PER_WEEK, PROCESSING_FEE_PERCENT, ACCOMMODATION_PRICES, ACCOMMODATION_LABELS, TICKET_LABELS, calculateAmount, getPricingTier, diff --git a/apply.html b/apply.html index 38b290b..d646c17 100644 --- a/apply.html +++ b/apply.html @@ -183,42 +183,6 @@ margin-top: 0.25rem; } - /* Theme ranking */ - .theme-list { - display: flex; - flex-direction: column; - gap: 0.5rem; - } - - .theme-item { - display: flex; - align-items: center; - gap: 1rem; - padding: 0.75rem 1rem; - background: var(--sand); - border-radius: 8px; - cursor: grab; - user-select: none; - } - - .theme-item:active { cursor: grabbing; } - - .theme-item .emoji { font-size: 1.25rem; } - .theme-item .text { flex: 1; font-size: 0.9rem; } - - .theme-item .rank { - width: 24px; - height: 24px; - background: var(--forest); - color: white; - border-radius: 50%; - display: flex; - align-items: center; - justify-content: center; - font-size: 0.75rem; - font-weight: 600; - } - /* Week cards */ .week-cards { display: flex; flex-direction: column; gap: 0.75rem; } @@ -354,7 +318,7 @@
    -
    Question 1 of 12
    +
    Question 1 of 9

    Contact Information

    @@ -391,7 +355,7 @@
    -
    Question 2 of 12
    +
    Question 2 of 9

    How did you hear about Valley of the Commons? *

    @@ -406,7 +370,7 @@
    -
    Question 3 of 12
    +
    Question 3 of 9

    Referral name(s) (optional)

    Who can vouch for you?

    @@ -422,7 +386,7 @@
    -
    Question 4 of 12
    +
    Question 4 of 9

    What are your affiliations? *

    What projects or groups are you affiliated with?

    @@ -438,7 +402,7 @@
    -
    Question 5 of 12
    +
    Question 5 of 9

    Why would you like to join Valley of the Commons, and why are you a good fit? *

    @@ -453,7 +417,7 @@
    -
    Question 6 of 12
    +
    Question 6 of 9

    What are you currently building, researching, or working on? *

    @@ -468,7 +432,7 @@
    -
    Question 7 of 12
    +
    Question 7 of 9

    How will you contribute to Valley of the Commons? *

    Villagers co-create their experience. You can start an interest club, lead a discussion or workshop, teach a cooking class, or more.

    @@ -482,108 +446,11 @@
    - +
    -
    Question 8 of 12
    -

    Please rank your interest in our themes *

    -

    Drag to reorder from most interested (top) to least interested (bottom).

    - -
    -
    - 1 - ๐Ÿž๏ธ - Developing the Future of the Valley -
    -
    - 2 - ๐ŸŒ - Cosmo-localism -
    -
    - 3 - ๐Ÿช™ - Funding Models & Token Engineering -
    -
    - 4 - ๐Ÿ‘พ - Fablabs & Hackerspaces -
    -
    - 5 - ๐ŸŒŒ - Future Living Design & Development -
    -
    - 6 - ๐Ÿง‘โ€โš–๏ธ - Network Societies & Decentralized Governance -
    -
    - 7 - โ›ฒ๏ธ - Commons Theory & Practice -
    -
    - 8 - ๐Ÿ‘ค - Privacy & Digital Sovereignty -
    -
    - 9 - ๐ŸŒ - d/acc: defensive accelerationism -
    -
    - 10 - ๐Ÿ’ญ - (Meta)rationality & Cognitive Sovereignty -
    -
    - -
    - - -
    -
    - - -
    -
    Question 9 of 12
    -

    Please explain your familiarity and interest in our themes and event overall *

    -

    ๐Ÿž๏ธ Valley Future ยท ๐ŸŒ Cosmo-localism ยท ๐Ÿช™ Funding & Token Engineering ยท ๐Ÿ‘พ Fablabs ยท ๐ŸŒŒ Future Living ยท ๐Ÿง‘โ€โš–๏ธ Network Governance ยท โ›ฒ๏ธ Commons ยท ๐Ÿ‘ค Privacy ยท ๐ŸŒ d/acc ยท ๐Ÿ’ญ (Meta)rationality

    - -
    - -
    - -
    - - -
    -
    - - -
    -
    Question 10 of 12
    -

    Describe a belief you have updated within the last 1-2 years *

    -

    What was the belief and why did it change?

    - -
    - -
    - -
    - - -
    -
    - - -
    -
    Question 11 of 12
    +
    Question 8 of 9

    Which week(s) would you like to attend? *

    -

    Select the weeks you'd like to join. Base registration is โ‚ฌ300 per week.

    +

    Select the weeks you'd like to join.

    @@ -725,9 +592,9 @@
    - -
    -
    Question 12 of 12
    + +
    +
    Question 9 of 9

    Anything else you'd like to add? (optional)

    @@ -775,7 +642,7 @@