diff --git a/components/Button.tsx b/components/Button.tsx index 28d4ad6..6c5aeb1 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -4,7 +4,7 @@ type ButtonProps = { children: ComponentChildren; } & JSX.HTMLAttributes; -const className = "p-2 border(gray-100 2) hover:bg-gray-200 bg-blue-200 w-max font-medium"; +const className = "p-2 border(gray-100 2) hover:bg-gray-200 bg-blue-200 font-medium"; export function Button(props: ButtonProps) { const { children, className: additionalClass = "", ...buttonProps } = props; diff --git a/islands/DonationSection.tsx b/islands/DonationSection.tsx index e0ecca2..84dec1d 100644 --- a/islands/DonationSection.tsx +++ b/islands/DonationSection.tsx @@ -26,11 +26,11 @@ export const DonationSection = function () {

Jeg ønsker at NRSS skal være gratis tilgjengelig for alle. Imidlertid koster det penger og tid å drifte og vedlikeholde en nettside. Dersom du har råd til det (og bare da!) setter jeg stor pris på om du vil støtte - prosjektet med et valgfritt, månedlig beløp via Vipps. + prosjektet med et lite, månedlig beløp via Vipps.

-
+ { if (!emailValid) { e.preventDefault(); @@ -70,18 +71,15 @@ export const DonationSection = function () { > Eposten brukes utelukkende som referanse dersom du ønsker å avslutte støtten. Du kommer ikke til å motta noen eposter. + + Du kan når som helst avslutte støtten fra{" "} + + denne siden + . +

-

- - Du kan når som helst avslutte støtten fra{" "} - - denne siden - . - -

-

Opplever du problemer med betalingen, eller har du andre spørsmål? Ta{" "} diff --git a/lib/rss.test.ts b/lib/rss.test.ts index ff3b5d0..fead2fb 100644 --- a/lib/rss.test.ts +++ b/lib/rss.test.ts @@ -31,5 +31,5 @@ Deno.test("generated rss contains promo with link to donations page", () => { const feed = rss.assembleFeed(series); console.log(feed); - feed.includes("Vurder å støtte utviklingen via Vipps med valgfritt beløp"); + feed.includes("Vurder å støtte utviklingen via Vipps"); }); diff --git a/lib/rss.ts b/lib/rss.ts index 076b3a3..a678ca8 100644 --- a/lib/rss.ts +++ b/lib/rss.ts @@ -59,7 +59,7 @@ function assembleFeed(series: Series): string { function descriptionWithDonationPromotion(description: string): string { const promotion = - `Takk for at du bruker NRSS 🙏🌟 Vurder å støtte utviklingen via Vipps med valgfritt beløp. Se mer på ${getHostUrl()}.`; + `Takk for at du bruker NRSS 🙏🌟 Vurder å støtte utviklingen via Vipps med omtrent det samme som prisen på en kaffekopp. Se mer på ${getHostUrl()}.`; return ` --------------------------------\n diff --git a/lib/vipps/vipps.ts b/lib/vipps/vipps.ts index 2c4d42f..59db725 100644 --- a/lib/vipps/vipps.ts +++ b/lib/vipps/vipps.ts @@ -45,6 +45,7 @@ const getAccessToken = async function () { export const createAgreement = async function (email: string) { const token = await getAccessToken(); + const amount = 5000; // 50 NOK const response = await fetch(`${config.baseUrl}/recurring/v3/agreements/`, { method: "POST", // @ts-ignore @@ -58,10 +59,14 @@ export const createAgreement = async function (email: string) { "unit": "MONTH", "count": 1, }, + "initialCharge": { + "amount": amount, + "description": "Initial charge", + "transactionType": "DIRECT_CAPTURE", + }, "pricing": { - "suggestedMaxAmount": 5000, // 50,- NOK + "amount": amount, "currency": "NOK", - "type": "VARIABLE", }, // email is used to identify the user in the success page "merchantRedirectUrl": `${getHostUrl()}/donations-success?email=${email}`, diff --git a/routes/api/trigger-donation/vipps.ts b/routes/api/trigger-donation/vipps.ts index 7749504..76b44e4 100644 --- a/routes/api/trigger-donation/vipps.ts +++ b/routes/api/trigger-donation/vipps.ts @@ -18,7 +18,7 @@ export const handler = async function (req: Request): Promise { } const existingAgreement = await storage.readVippsAgreement({ id: email }); - if (existingAgreement) { + if (existingAgreement && existingAgreement.revokedAt === null) { console.error("Agreement already exists", email); return Response.redirect(errorPage); } diff --git a/routes/donations-cancel.tsx b/routes/donations-cancel.tsx index d8c46aa..9fea969 100644 --- a/routes/donations-cancel.tsx +++ b/routes/donations-cancel.tsx @@ -50,7 +50,7 @@ export default function ({ data }: PageProps) { className={"p-4 mx-auto max-w-screen-md text-center"} >

Avslutt støtte til NRSS

@@ -63,21 +63,22 @@ export default function ({ data }: PageProps) {

)} {data.cancelled && ( -

- Støtten er nå avsluttet. Tusen takk for at du har støttet NRSS 🙏🌟 +

+ Støtten er nå avsluttet.
+ Tusen takk for at du har støttet NRSS 🙏

)} {!data.cancelled && ( - + - + />