Skip to content

Commit 98721e8

Browse files
committed
feat: link to easy invoice for client id generation
1 parent c8babce commit 98721e8

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ NEXT_PUBLIC_NPM_PACKAGE_URL="https://www.npmjs.com/package/@requestnetwork/payme
66
NEXT_PUBLIC_DEMO_URL="https://calendly.com/mariana-rn/request-network-intro"
77
NEXT_PUBLIC_INTEGRATION_URL="https://docs.request.network/building-blocks/templates/request-checkout"
88
NEXT_PUBLIC_RN_API_CLIENT_ID="rn_f6mr53l2yfcdv4sych5adq7gez3avurq"
9-
NEXT_PUBLIC_REQUEST_API_URL="https://api.stage.request.network"
9+
NEXT_PUBLIC_REQUEST_API_URL="https://api.stage.request.network"
10+
NEXT_PUBLIC_EASY_INVOICE_URL=https://easyinvoice.request.network

src/components/PaymentStep.tsx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import { useTicketStore } from "@/store/ticketStore";
44
import { useEffect, useState } from "react";
5-
import { useRouter } from "next/navigation";
65
import { PaymentWidget } from "./payment-widget/payment-widget";
6+
import { Input } from "./ui/input";
7+
import { Label } from "./ui/label";
8+
import { EASY_INVOICE_URL } from "@/lib/constants";
79

810
export function PaymentStep() {
911
const { tickets, clearTickets } = useTicketStore();
1012
const [total, setTotal] = useState(0);
11-
const router = useRouter();
13+
const [customClientId, setCustomClientId] = useState("");
1214

1315
useEffect(() => {
1416
const newTotal = Object.values(tickets).reduce(
@@ -33,9 +35,9 @@ export function PaymentStep() {
3335
total: total.toString(),
3436
totalUSD: total.toString(),
3537
};
36-
console.log("ma kaj mona", total, invoiceTotals)
3738

38-
const clientId = process.env.NEXT_PUBLIC_RN_API_CLIENT_ID;
39+
const defaultClientId = process.env.NEXT_PUBLIC_RN_API_CLIENT_ID;
40+
const clientId = customClientId || defaultClientId;
3941

4042
return (
4143
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
@@ -72,9 +74,31 @@ export function PaymentStep() {
7274
</div>
7375
</div>
7476

75-
{/* Payment Widget */}
7677
<div role="region" aria-label="Payment Widget">
7778
<h2 className="text-2xl font-semibold mb-6">Payment</h2>
79+
<div className="mb-6 space-y-2">
80+
<Label htmlFor="custom-client-id">Custom Client ID</Label>
81+
<Input
82+
id="custom-client-id"
83+
type="text"
84+
placeholder="Enter your custom client ID"
85+
value={customClientId}
86+
onChange={(e) => setCustomClientId(e.target.value)}
87+
className="w-full"
88+
/>
89+
<p className="text-sm text-gray-600">
90+
Get your Client ID on{" "}
91+
<a
92+
href={`${EASY_INVOICE_URL}/ecommerce/manage`}
93+
target="_blank"
94+
rel="noopener noreferrer"
95+
className="text-green hover:text-dark-green underline"
96+
>
97+
EasyInvoice
98+
</a>
99+
</p>
100+
</div>
101+
78102
{clientId && (
79103
<PaymentWidget
80104
amountInUsd={total.toString()}
@@ -126,15 +150,12 @@ export function PaymentStep() {
126150
}}
127151
onSuccess={() => {
128152
clearTickets();
129-
setTimeout(() => {
130-
router.push("/");
131-
}, 10000);
132153
}}
133154
onError={(error) => {
134155
console.error("Payment failed:", error);
135156
}}
136157
>
137-
<div className="px-8 py-2 bg-[#099C77] text-white rounded-lg hover:bg-[#087f63] transition-colors text-center">
158+
<div className="px-10 py-2 bg-[#099C77] text-white rounded-lg hover:bg-[#087f63] transition-colors text-center">
138159
Pay with crypto
139160
</div>
140161
</PaymentWidget>

src/components/Playground/blocks/customize.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PlaygroundFormData } from "@/lib/validation";
1111
import { Switch } from "../../ui/switch";
1212
import { useEffect } from "react";
1313
import { CurrencyCombobox } from "../../ui/combobox";
14+
import { EASY_INVOICE_URL } from "@/lib/constants";
1415

1516
export const CustomizeForm = () => {
1617
const {
@@ -126,6 +127,17 @@ export const CustomizeForm = () => {
126127
{errors.paymentConfig?.rnApiClientId?.message && (
127128
<Error>{errors.paymentConfig.rnApiClientId.message}</Error>
128129
)}
130+
<p className="text-sm text-gray-600">
131+
Get your Client ID on{" "}
132+
<a
133+
href={`${EASY_INVOICE_URL}/ecommerce/manage`}
134+
target="_blank"
135+
rel="noopener noreferrer"
136+
className="text-green hover:text-dark-green underline"
137+
>
138+
EasyInvoice
139+
</a>
140+
</p>
129141
</div>
130142

131143
<div className="flex flex-col gap-2">

src/lib/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ export const CURRENCY_ID = {
4040
FAU_SEPOLIA: "FAU-sepolia",
4141
"ETH-ZKSYNC_ZKSYNCERA": "ETH-zksync-zksyncera",
4242
"ETH-BASE_BASE": "ETH-base-base",
43-
} as const;
43+
} as const;
44+
export const EASY_INVOICE_URL = process.env.NEXT_PUBLIC_EASY_INVOICE_URL || "https://easyinvoice.request.network";

0 commit comments

Comments
 (0)