| Install | |
|---|---|
composer require nmdigitalhub/payment-gateway |
|
| Latest Version: | v1.1.4 |
| PHP: | ^8.2 |
חבילת שער תשלום מתקדמת ל-Laravel עם אינטגרציה מלאה לCardCom, Maya Mobile ו-ResellerClub - מבוססת על מערכת eSIM מאוחדת עם Slug routing ו-Frontend מלא
# הוספת החבילה דרך Composer
composer require nmdigitalhub/payment-gateway
# התקנה אוטומטית מלאה
php artisan payment-gateway:install --demo --optimize
# או התקנה ידנית צעד אחר צעד
php artisan payment-gateway:install --verbose
# התקנה בכוח (עריפת הגדרות קיימות)
php artisan payment-gateway:install --force
# התקנה עם נתוני דמו
php artisan payment-gateway:install --demo
# התקנה ללא migrations
php artisan payment-gateway:install --skip-migrations
# התקנה עם אופטימיזציה
php artisan payment-gateway:install --optimize
# פרטי התקנה מלאים
php artisan payment-gateway:install --verbose
# CardCom Configuration
CARDCOM_TERMINAL_NUMBER=172204
CARDCOM_API_NAME=your_api_name
CARDCOM_API_PASSWORD=your_api_password
CARDCOM_TEST_MODE=false
# Payment Gateway
PAYMENT_GATEWAY_ENABLED=true
PAYMENT_GATEWAY_DEFAULT=cardcom
# URL לקבלת webhooks מ-CardCom
https://your-domain.com/webhooks/cardcom
use NMDigitalHub\PaymentGateway\Facades\Payment;
// יצירת תשלום בסיסי
$payment = Payment::amount(100)
->currency('ILS')
->customerEmail('customer@example.com')
->customerName('יוסי כהן')
->description('תשלום עבור מוצר')
->create();
// תוצאה: URL לדף התשלום של CardCom
return redirect($payment->checkout_url);
use NMDigitalHub\PaymentGateway\Facades\Payment;
$payment = Payment::amount(250.50)
->currency('ILS')
->customerEmail('customer@example.com')
->customerName('רחל לוי')
->customerPhone('0501234567')
->description('חידוש מנוי שנתי')
->savePaymentMethod() // שמירת כרטיס לעתיד
->successUrl('https://mysite.com/payment/success')
->failedUrl('https://mysite.com/payment/failed')
->webhookUrl('https://mysite.com/webhooks/cardcom')
->metadata(['order_id' => 123, 'user_id' => 456])
->create();
// קבלת טוכנים שמורים של המשתמש
$tokens = auth()->user()->paymentTokens()->active()->get();
// תשלום עם טוכן
$payment = Payment::useToken($tokenId)
->amount(99.99)
->cvv('123') // נדרש לאימות 3D
->description('תשלום חוזר')
->create();
// תוצאה: תשלום מיידי או הפנייה ל-3D Secure
if ($payment->requires_3ds) {
return redirect($payment->three_ds_url);
}
use NMDigitalHub\PaymentGateway\Models\PaymentPage;
$page = PaymentPage::create([
'title' => 'תשלום עבור קורס',
'slug' => 'course-payment',
'description' => 'תשלום מאובטח עבור הקורס שלנו',
'type' => 'checkout',
'status' => 'published',
'is_public' => true,
'language' => 'he',
'content' => [
[
'type' => 'heading',
'data' => ['content' => 'תשלום מאובטח', 'level' => 'h1']
],
[
'type' => 'payment_form',
'data' => ['allowed_methods' => ['cardcom']]
]
]
]);
// URL לעמוד התשלום: /payment/course-payment
// routes/web.php
use NMDigitalHub\PaymentGateway\Http\Controllers\CheckoutController;
Route::get('/payment/{slug}', [CheckoutController::class, 'showPaymentPage']);
Route::post('/payment/{slug}', [CheckoutController::class, 'processPayment']);
/admin/payment-transactions/client/payment-tokens# בדיקת חיבור לספקים
php artisan payment-gateway:health-check
# סנכרון קטלוגים
php artisan payment-gateway:sync
# בדיקת ספק
php artisan payment-gateway:test cardcom
# יצירת עמוד תשלום
php artisan payment-gateway:create-page
# ניקוי טוכנים שפגו
php artisan payment-gateway:cleanup-tokens
# ייצוא עסקאות לדוח
php artisan payment-gateway:export --from="2024-01-01" --to="2024-12-31"
# גיבוי נתוני תשלום
php artisan payment-gateway:backup
use NMDigitalHub\PaymentGateway\Services\CardComLowProfileService;
Route::post('/webhooks/cardcom', function (Request $request) {
$service = app(CardComLowProfileService::class);
$transaction = $service->handleWebhook($request->all());
if ($transaction && $transaction->status === 'success') {
// עיבוד הזמנה מוצלחת
$order = Order::where('reference', $transaction->reference)->first();
$order->markAsCompleted();
// שליחת מייל אישור
Mail::to($transaction->customerEmail)
->send(new PaymentConfirmationMail($transaction));
}
return response('OK', 200);
});
use NMDigitalHub\PaymentGateway\Models\PaymentTransaction;
// קבלת עסקאות לפי משתמש
$transactions = PaymentTransaction::where('customer_email', 'user@example.com')
->whereIn('status', ['success', 'completed'])
->orderBy('created_at', 'desc')
->get();
// קבלת עסקה לפי מזהה
$transaction = PaymentTransaction::where('transaction_id', 'PAY-123')->first();
// סטטיסטיקות תשלומים
$stats = PaymentTransaction::selectRaw('
COUNT(*) as total_transactions,
SUM(CASE WHEN status = "success" THEN amount ELSE 0 END) as total_amount,
AVG(amount) as average_amount
')->where('created_at', '>=', now()->subMonth())->first();
use App\Models\PaymentToken;
// קבלת טוכנים פעילים של משתמש
$tokens = PaymentToken::where('user_id', auth()->id())
->active()
->notExpired()
->get();
// הגדרת טוכן כברירת מחדל
$token->setAsDefault();
// ביטול טוכן
$token->deactivate();
// config/payment-gateway.php
return [
'security' => [
'encryption_key' => env('PAYMENT_GATEWAY_ENCRYPTION_KEY'),
'hmac_secret' => env('PAYMENT_GATEWAY_HMAC_SECRET'),
'session_timeout' => 1800, // 30 דקות
'max_attempts' => 3,
'lockout_duration' => 900, // 15 דקות
],
'logging' => [
'enabled' => true,
'include_sensitive' => false, // לא לכלול נתונים רגישים
'retention_days' => 30,
],
];
// שימוש ב-cache עבור שאילתות כבדות
$providers = Cache::remember('active_payment_providers', 3600, function () {
return ServiceProvider::active()->get();
});
// אינדקסים מומלצים במאגר הנתונים
Schema::table('payment_transactions', function (Blueprint $table) {
$table->index(['customer_email', 'status']);
$table->index(['status', 'created_at']);
$table->index(['provider', 'status']);
});
# בדיקת פרטי החיבור
php artisan payment-gateway:test cardcom
# בדיקת הגדרות
php artisan config:cache
php artisan config:clear
# בדיקת URL פנוי
curl -X POST https://your-domain.com/webhooks/cardcom
# בדיקת הגדרות HMAC
php artisan tinker
>>> config('payment-gateway.security.hmac_secret')
# ניקוי cache של Filament
php artisan filament:cache-components
php artisan filament:optimize
# מידע על החבילה
php artisan payment-gateway:info
# רשימת פקודות זמינות
php artisan payment-gateway:help
# בדיקת תקינות המערכת
php artisan payment-gateway:doctor
החבילה מופצת תחת רישיון MIT. ראה LICENSE לפרטים נוספים.
פותחה בידי NM Digital Hub עם ❤️
/payment-gateway/checkout/{package-slug} עם תמיכה דינמית