From 6b40444639d8ecd2201a0b1dd041347c95c3ee72 Mon Sep 17 00:00:00 2001 From: "Ayris.Tech" Date: Sun, 1 Mar 2026 00:56:46 +0300 Subject: [PATCH] Implement automated custodial crypto sweep logic (%1 platform, %99 merchant) --- app/api/crypto-sweep/route.ts | 31 +++++ app/checkout/page.tsx | 124 +++++++++++++------ components/checkout/CryptoCheckout.tsx | 160 +++++++++++++++++++++++++ contracts/AyrisSplitter.sol | 67 +++++++++++ lib/crypto-engine.ts | 119 ++++++++++++++++++ package-lock.json | 128 +++++++++++++++++--- package.json | 1 + 7 files changed, 576 insertions(+), 54 deletions(-) create mode 100644 app/api/crypto-sweep/route.ts create mode 100644 components/checkout/CryptoCheckout.tsx create mode 100644 contracts/AyrisSplitter.sol create mode 100644 lib/crypto-engine.ts diff --git a/app/api/crypto-sweep/route.ts b/app/api/crypto-sweep/route.ts new file mode 100644 index 0000000..a1c247c --- /dev/null +++ b/app/api/crypto-sweep/route.ts @@ -0,0 +1,31 @@ +import { NextResponse } from 'next/server'; +import { CryptoEngine } from '@/lib/crypto-engine'; + +export async function POST(request: Request) { + try { + const body = await request.json(); + const { txId, merchantAddress } = body; + + // In a real app, you would fetch the private key for this txId from a secure DB/Vault + // For demo: We just simulate the result of a sweep + + console.log(`[API] Checking and Sweeping for Transaction: ${txId}`); + + // Mock success response + return NextResponse.json({ + success: true, + message: "Ödeme başarıyla doğrulandı ve dağıtıldı.", + split: { + platform: "1.00 USDT (%1)", + merchant: "99.00 USDT (%99)" + }, + hashes: { + platform: "0x" + Math.random().toString(16).slice(2, 66), + merchant: "0x" + Math.random().toString(16).slice(2, 66) + } + }); + + } catch (error: any) { + return NextResponse.json({ success: false, error: error.message }, { status: 500 }); + } +} diff --git a/app/checkout/page.tsx b/app/checkout/page.tsx index a555762..6ab538a 100644 --- a/app/checkout/page.tsx +++ b/app/checkout/page.tsx @@ -6,8 +6,9 @@ import { getStripe } from '@/lib/stripe-client'; import { useSearchParams } from 'next/navigation'; import CheckoutForm from '@/components/checkout/CheckoutForm'; import MockCheckoutForm from '@/components/checkout/MockCheckoutForm'; -import { Loader2, AlertCircle, ArrowLeft, UserCircle } from 'lucide-react'; -import Link from 'next/link'; // Added Link import +import CryptoCheckout from '@/components/checkout/CryptoCheckout'; +import { Loader2, AlertCircle, ArrowLeft, UserCircle, CreditCard, Coins } from 'lucide-react'; +import Link from 'next/link'; function CheckoutContent() { const searchParams = useSearchParams(); @@ -20,6 +21,7 @@ function CheckoutContent() { const [clientSecret, setClientSecret] = useState(null); const [paymentData, setPaymentData] = useState(null); const [error, setError] = useState(null); + const [paymentMethod, setPaymentMethod] = useState<'card' | 'crypto'>('card'); const isMock = process.env.NEXT_PUBLIC_USE_MOCK_PAYMENTS === 'true'; @@ -138,40 +140,71 @@ function CheckoutContent() {

Ödeme ekranı hazırlanıyor...

) : ( -
- {paymentData?.nextAction === 'redirect' ? ( -
-
- -
-
-

Ödeme Sayfasına Yönlendiriliyorsunuz

-

Lütfen tarayıcınızı kapatmayın

-
-

Sizi güvenli ödeme adımına aktarıyoruz. Bu işlem birkaç saniye sürebilir.

- -
- ) : isMock ? ( - - ) : paymentData?.provider === 'stripe' ? ( - - - +
+ {/* Payment Method Selector */} +
+ + +
+ + {paymentMethod === 'crypto' ? ( + { + setTimeout(() => { + window.location.href = `${callbackUrl}?status=success&tx_hash=${hash}`; + }, 2000); + }} + /> ) : ( -
- -

{paymentData?.provider.toUpperCase()} Entegrasyonu

-

Bu ödeme yöntemi geliştirme aşamasındadır.

+
+ {paymentData?.nextAction === 'redirect' ? ( +
+
+ +
+
+

Ödeme Sayfasına Yönlendiriliyorsunuz

+

Lütfen tarayıcınızı kapatmayın

+
+

Sizi güvenli ödeme adımına aktarıyoruz. Bu işlem birkaç saniye sürebilir.

+ +
+ ) : isMock ? ( + + ) : paymentData?.provider === 'stripe' ? ( + + + + ) : ( +
+ +

{paymentData?.provider.toUpperCase()} Entegrasyonu

+

Bu ödeme yöntemi geliştirme aşamasındadır.

+
+ )}
)} @@ -186,6 +219,27 @@ function CheckoutContent() {
+ {/* Footer */} +
+

+ © 2026 P2CGateway Inc. Tüm hakları saklıdır. +

+
+
+ ); +} + +
+ + + Mağazaya Dön + +
+ + )} + + + {/* Footer */}