Skip to content

Commit

Permalink
adding URL back
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Jan 31, 2024
1 parent 94a9509 commit 336d0d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/api/[message]/checkout/route.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { getMessage } from "@/lib/messages";
import { AppConfig } from "@/app/AppConfig";

export async function POST(
export async function GET(
request: Request,
{ params }: { params: { message: string } }
) {
return new Response(`${AppConfig.siteUrl}/api/${params.message}/redirect`, {
const message = await getMessage(params.message);

return new Response(message.checkoutUrl, {
status: 302,
});
}
14 changes: 14 additions & 0 deletions src/lib/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
export const getMessage = async (id: string) => {
const paywallConfig = {
pessimistic: true,
locks: {
"0xb77030a7e47a5eb942a4748000125e70be598632": {
name: "Unlock Community",
network: 137,
},
},
metadataInputs: [{ name: "email", type: "email", required: true }],
};

return {
id,
body: `👏 You're in the secret! 🤫.
Expand All @@ -12,5 +23,8 @@ Also this supports [Markdown](https://www.markdownguide.org/), so you _can_ **st
contract: "0xb77030a7e47a5eb942a4748000125e70be598632",
network: 137,
},
checkoutUrl: `https://app.unlock-protocol.com/checkout?paywallConfig=${encodeURIComponent(
JSON.stringify(paywallConfig)
)}`,
};
};

0 comments on commit 336d0d1

Please sign in to comment.