Skip to content

Commit

Permalink
Feat/lfg (#182)
Browse files Browse the repository at this point in the history
* fix pixel type + pwa

* start init stripe checkout + pay

* fix stripe test

* add preserveSymLinks + undo stripe mobile issue react native version

* delete nostr afk package atm

* delete preserveSimLink

* add global png + change resources to public

* add resources pixel in pwa

* add resource in pixel src too

* fix pwa + package

* clean assets

* add argent mobile connection

* add GA pwa and landing

* fix lint

* check window + global ts

* lint fix

* fix typo
  • Loading branch information
MSghais authored Oct 14, 2024
1 parent 0b31fc3 commit c668050
Show file tree
Hide file tree
Showing 100 changed files with 1,955 additions and 1,294 deletions.
3 changes: 2 additions & 1 deletion apps/data-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ APP_URL_WEB="http://localhost:8081"

FUNKIT_API_KEY=

JWT_SECRET=
JWT_SECRET=
STRIPE_SERVER_API_KEY=
4 changes: 4 additions & 0 deletions apps/data-backend/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import allTransactionsRoute from "./routes/indexer/all-transactions";
import createFunkitStripeCheckout from "./routes/funkit/create_funkit_stripe_checkout";
import getFunkitStripeCheckoutQuote from "./routes/funkit/get_funkit_stripe_checkout_quote";
import getFunkitStripeCheckoutStatus from "./routes/funkit/get_funkit_stripe_checkout_status";
import createPaymentIntent from "./routes/stripe/createPaymentIntent";
import paymentSheet from "./routes/stripe/paymentSheet";
// import getOtp from "./routes/otp/getOtp";
// import verifyOtp from "./routes/otp/verifyOtp";
// import type { Account } from 'starknet'
Expand All @@ -32,6 +34,8 @@ function declareRoutes(
fastify.register(createFunkitStripeCheckout);
fastify.register(getFunkitStripeCheckoutQuote);
fastify.register(getFunkitStripeCheckoutStatus);
fastify.register(createPaymentIntent);
fastify.register(paymentSheet);
// fastify.register(getOtp, twilio_services?.verifications);
// fastify.register(verifyOtp, deployer, twilio_services?.verificationChecks);
// fastify.register(verifyOtp, [deployer, twilio_services?.verificationChecks]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import type { FastifyInstance, RouteOptions } from "fastify";
import { getChecksumAddress } from "starknet";
import {
Expand Down
56 changes: 56 additions & 0 deletions apps/data-backend/src/routes/stripe/createPaymentIntent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { FastifyInstance } from "fastify";
import { prisma } from "@prisma/client";
import dotenv from "dotenv"
dotenv.config()
const stripe = require('stripe')(process.env.STRIPE_SERVER_API_KEY);

interface CreatePaymentIntent {
currency: string;
amount:number;
}

async function createPaymentIntent(
fastify: FastifyInstance,
) {
fastify.post<{ Body: CreatePaymentIntent }>(
"/create-payment-intent",

{
schema: {
body: {
type: "object",
required: ["currency", "amount"],
properties: {
currency: { type: "string", pattern: "^\\+[1-9]\\d{1,14}$" },
amount:{type:"number"}
},
},
},
},

async (request, reply) => {


try {
const { currency } = request.body;

const paymentIntent = await stripe.paymentIntents.create({
amount: 1000, // Example amount in smallest currency unit (cents)
currency: currency,
payment_method_types: ['card'],
});

reply.send({
clientSecret: paymentIntent.client_secret,
});

return reply.code(200).send({ ok: true });
} catch (error) {
fastify.log.error(error);
return reply.code(500).send({ message: "Internal Server Error" });
}
}
);
}

export default createPaymentIntent;
73 changes: 73 additions & 0 deletions apps/data-backend/src/routes/stripe/paymentSheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import type { FastifyInstance } from "fastify";
import { prisma } from "@prisma/client";
import dotenv from "dotenv"
dotenv.config()
const stripe = require('stripe')(process.env.STRIPE_SERVER_API_KEY);

interface CreatePaymentSheet {
currency: string;
amount: number;
}

async function paymentSheet(
fastify: FastifyInstance,
) {
fastify.post<{ Body: CreatePaymentSheet }>(
"/payment-sheet",

{
schema: {
body: {
type: "object",
required: ["currency", "amount"],
properties: {
currency: { type: "string", pattern: "^\\+[1-9]\\d{1,14}$" },
amount: { type: "number" }
},
},
},
},

async (request, reply) => {


try {
const { currency } = request.body;


// Create a customer
const customer = await stripe.customers.create();

// Create an ephemeral key for the customer
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customer.id },
{ apiVersion: '2022-11-15' } // Ensure to use the latest API version
);


const paymentIntent = await stripe.paymentIntents.create({
amount: 1000, // Example amount in smallest currency unit (cents)
currency: currency,
payment_method_types: ['card'],
});

// reply.send({
// clientSecret: paymentIntent.client_secret,
// });

return reply.code(200).send({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customer.id,
});

// return reply.code(200).send({ ok: true });
} catch (error) {
fastify.log.error(error);
return reply.code(500).send({ message: "Internal Server Error" });
}
}
);
}

export default paymentSheet;
7 changes: 7 additions & 0 deletions apps/mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@
"microphonePermissionText": "$(PRODUCT_NAME) needs access to your Microphone.",
"enableCodeScanner": true
}
],
[
"@stripe/stripe-react-native",
{
"merchantIdentifier": "",
"enableGooglePay": true
}
]
],
"sdkVersion": "51.0.0",
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
"text-encoding": "^0.7.0",
"viem": "2.x",
"wagmi": "^2.12.8",
"zustand": "^4.5.2"
"zustand": "^4.5.2",
"@stripe/stripe-react-native":"0.38.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
Binary file added apps/mobile/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/mobile/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/mobile/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/mobile/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
{"name":"AFK Aligned Fam Kernel","short_name":"AFK","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
4 changes: 2 additions & 2 deletions apps/mobile/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import {useCallback, useEffect, useState} from 'react';
import {View, Platform} from 'react-native';
import { useNavigationContainerRef } from '@react-navigation/native';
import {useNavigationContainerRef} from '@react-navigation/native';
import {useTips} from '../hooks';
import {useDialog, useToast} from '../hooks/modals';
import {Router} from './Router';
import { initGoogleAnalytics } from '../utils/analytics';
import {initGoogleAnalytics} from '../utils/analytics';

SplashScreen.preventAutoHideAsync();

Expand Down
Loading

0 comments on commit c668050

Please sign in to comment.