Skip to content

Commit

Permalink
Add demo app id
Browse files Browse the repository at this point in the history
  • Loading branch information
timuric committed Aug 21, 2024
1 parent cd7b059 commit 71b55d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app/api/demo-payment/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const removeWhiteSpace = (str: string): string => {
};

const url = `https://${process.env.VERCEL_BRANCH_URL}`;
export const DEMO_PAYMENT_GATEWAY = `storefront.demo-payment`;

export async function GET() {
return Response.json({
id: "storefront.demo-payment",
id: DEMO_PAYMENT_GATEWAY,
version: "1.0.0",
requiredSaleorVersion: "^3.20",
name: "Demo Payment App",
Expand Down
3 changes: 2 additions & 1 deletion src/checkout/sections/PaymentSection/Demo/PaymentOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useCheckoutCompleteMutation, useTransactionInitializeMutation } from "@
import { useCheckout } from "@/checkout/hooks/useCheckout";
import { replaceUrl } from "@/checkout/lib/utils/url";
import { Button } from "@/checkout/components";
import { DEMO_PAYMENT_GATEWAY } from "@/app/api/demo-payment/route";

export const DemoPayment = () => {
const { checkout } = useCheckout();
Expand All @@ -23,7 +24,7 @@ export const DemoPayment = () => {
await mutation({
checkoutId: checkout.id,
paymentGateway: {
id: process.env.NEXT_PUBLIC_PAYMENT_GATEWAY as string,
id: DEMO_PAYMENT_GATEWAY,
data: {
details: "valid-details",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCheckout } from "@/checkout/hooks/useCheckout";
import { useSubmit } from "@/checkout/hooks/useSubmit";
import { type MightNotExist } from "@/checkout/lib/globalTypes";
import { type ParsedPaymentGateways } from "@/checkout/sections/PaymentSection/types";
import { DEMO_PAYMENT_GATEWAY } from "@/app/api/demo-payment/route";

export const usePaymentGatewaysInitialize = () => {
const {
Expand All @@ -30,7 +31,7 @@ export const usePaymentGatewaysInitialize = () => {
parse: () => ({
checkoutId,
paymentGateways: availablePaymentGateways
.filter((x) => x.id === process.env.NEXT_PUBLIC_PAYMENT_GATEWAY)
.filter((x) => x.id === DEMO_PAYMENT_GATEWAY)
.map(({ config, id }) => ({
id,
data: config,
Expand Down

0 comments on commit 71b55d2

Please sign in to comment.