Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 58450a1262 | |||
| 878236ae2f | |||
| 05ab1c6014 | |||
| 9065dcd911 | |||
| dcd08ae530 | |||
| d468991bd1 | |||
| 7d1ec59dea | |||
| 24d1eda717 | |||
| 9d981f3a34 | |||
| b9c018a4a6 | |||
| 23b0b30434 | |||
| 4b9220c89e | |||
| 298f3fa22b | |||
| 98be7131f4 | |||
| 999c1dfc58 | |||
| a3fd278536 | |||
| 290498c728 | |||
| aca21ae115 | |||
| 982efbf2bd | |||
| 3953a6f4c8 | |||
| fbb10a01d4 | |||
| 6ccb754e0c | |||
| 50826c8c20 | |||
| 68f75ac2fc | |||
| 9587c44657 | |||
| 06de3c0145 | |||
| d2d53e961b | |||
| b0816231d6 |
@@ -39,3 +39,7 @@ OIDC_CLIENT_ID=
|
|||||||
OIDC_CLIENT_SECRET=
|
OIDC_CLIENT_SECRET=
|
||||||
OIDC_REDIRECT_URI="${APP_URL}/auth/social/oidc/callback"
|
OIDC_REDIRECT_URI="${APP_URL}/auth/social/oidc/callback"
|
||||||
|
|
||||||
|
NORTH_CHECKOUT_ID=
|
||||||
|
NORTH_PROFILE_ID=
|
||||||
|
NORTH_PRIVATE_API_KEY=
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
name: Deploy to Remote Server
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Deploy and optimize
|
|
||||||
uses: appleboy/ssh-action@master
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.SSH_HOST }}
|
|
||||||
username: ${{ secrets.SSH_USER }}
|
|
||||||
key: ${{ secrets.SSH_KEY }}
|
|
||||||
port: ${{ secrets.SSH_PORT || 22 }}
|
|
||||||
script: |
|
|
||||||
cd ${{ secrets.DEPLOY_PATH }}
|
|
||||||
git pull origin master
|
|
||||||
composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
||||||
npm install
|
|
||||||
npm run prod
|
|
||||||
php artisan migrate --force
|
|
||||||
php artisan optimize:clear
|
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Bidders;
|
||||||
|
use App\Models\Checkout;
|
||||||
|
use App\Models\WinningBids;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class NorthCheckoutController extends Controller
|
||||||
|
{
|
||||||
|
public function checkout(Request $request, $bidder_id)
|
||||||
|
{
|
||||||
|
$bidder = Bidders::where('idbidders', $bidder_id)->firstOrFail();
|
||||||
|
|
||||||
|
// Check if already checked out
|
||||||
|
if (Checkout::where('bidder_num', $bidder->idbidders)->exists()) {
|
||||||
|
return redirect('/mywinnings?bidder_number=' . $bidder->bidder_assigned_number)->with('error', 'Bidder has already checked out.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$winnings = WinningBids::where('winning_bidder_num', $bidder->idbidders)->get();
|
||||||
|
$total_cost = $winnings->sum('winning_cost');
|
||||||
|
|
||||||
|
if ($total_cost <= 0) {
|
||||||
|
return redirect('/mywinnings?bidder_number=' . $bidder->bidder_assigned_number)->with('error', 'No winnings found for this bidder.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('north_checkout', [
|
||||||
|
'bidder' => $bidder,
|
||||||
|
'total_cost' => $total_cost,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createSession(Request $request, $bidder_id)
|
||||||
|
{
|
||||||
|
$bidder = Bidders::findOrFail($bidder_id);
|
||||||
|
$winnings = WinningBids::with('items')->where('winning_bidder_num', $bidder->idbidders)->get();
|
||||||
|
$total_cost = $winnings->sum('winning_cost');
|
||||||
|
|
||||||
|
$products = $winnings->map(function($winning) {
|
||||||
|
return [
|
||||||
|
'name' => $winning->items->item_desc ?? 'Auction Item',
|
||||||
|
'price' => (float)$winning->winning_cost,
|
||||||
|
'quantity' => 1
|
||||||
|
];
|
||||||
|
})->toArray();
|
||||||
|
|
||||||
|
$apiKey = config('services.north.private_api_key');
|
||||||
|
$checkoutId = config('services.north.checkout_id');
|
||||||
|
$profileId = config('services.north.profile_id');
|
||||||
|
|
||||||
|
if (!$apiKey || !$checkoutId || !$profileId) {
|
||||||
|
return response()->json(['error' => 'North configuration missing.'], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $apiKey,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
])->post('https://checkout.north.com/api/sessions', [
|
||||||
|
'checkoutId' => $checkoutId,
|
||||||
|
'profileId' => $profileId,
|
||||||
|
'amount' => (float)$total_cost,
|
||||||
|
'products' => $products,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
Log::error('North Session Creation Failed: ' . $response->status() . ' ' . $response->body());
|
||||||
|
return response()->json([
|
||||||
|
'error' => 'Failed to create checkout session: ' . ($response->json('message') ?? 'Unknown error'),
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->body()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
// If json() is null but body is not empty, it might be a parsing error
|
||||||
|
if (is_null($data) && !empty($response->body())) {
|
||||||
|
Log::error('North Session Response is not JSON: ' . $response->body());
|
||||||
|
return response()->json([
|
||||||
|
'error' => 'Response from North is not valid JSON.',
|
||||||
|
'raw_body' => $response->body()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $data['token'] ??
|
||||||
|
$data['sessionToken'] ??
|
||||||
|
$data['id'] ??
|
||||||
|
$data['session_id'] ??
|
||||||
|
($data['session']['id'] ?? null);
|
||||||
|
|
||||||
|
if (!$token) {
|
||||||
|
Log::error('North Session Token Missing in Response: ' . json_encode($data));
|
||||||
|
return response()->json([
|
||||||
|
'error' => 'Session token not found in API response.',
|
||||||
|
'debug_response' => $data,
|
||||||
|
'raw_body' => $response->body()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['sessionToken' => $token]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verify(Request $request, $bidder_id)
|
||||||
|
{
|
||||||
|
$bidder = Bidders::findOrFail($bidder_id);
|
||||||
|
$sessionToken = $request->query('sessionToken');
|
||||||
|
if (!$sessionToken) {
|
||||||
|
return redirect('/mywinnings?bidder_number=' . $bidder->bidder_assigned_number)->with('error', 'Missing session token.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$apiKey = config('services.north.private_api_key');
|
||||||
|
$checkoutId = config('services.north.checkout_id');
|
||||||
|
$profileId = config('services.north.profile_id');
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $apiKey,
|
||||||
|
'SessionToken' => $sessionToken,
|
||||||
|
'CheckoutId' => $checkoutId,
|
||||||
|
'ProfileId' => $profileId,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
])->get('https://checkout.north.com/api/sessions/status');
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
Log::error('North Session Verification Failed: ' . $response->status() . ' ' . $response->body());
|
||||||
|
return redirect('/mywinnings?bidder_number=' . $bidder->bidder_assigned_number)->with('error', 'Failed to verify payment status. Status: ' . $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = $response->json();
|
||||||
|
$currentStatus = $status['status'] ?? '';
|
||||||
|
|
||||||
|
// The North API status check might return Approved, completed, success, authorized, or captured.
|
||||||
|
$successStatuses = ['approved', 'completed', 'success', 'authorized', 'captured'];
|
||||||
|
|
||||||
|
if (in_array(strtolower($currentStatus), $successStatuses)) {
|
||||||
|
// Check if already checked out to avoid duplicates
|
||||||
|
$existingCheckout = Checkout::where('bidder_num', $bidder->idbidders)->first();
|
||||||
|
|
||||||
|
if (!$existingCheckout) {
|
||||||
|
// According to docs, when status is Approved, transaction details are in 'body'
|
||||||
|
// Digital wallets might have these at the top level
|
||||||
|
$body = $status['body'] ?? [];
|
||||||
|
$winnertotal = $status['amount'] ??
|
||||||
|
($body['amount'] ??
|
||||||
|
($status['amount_total'] ??
|
||||||
|
WinningBids::where('winning_bidder_num', $bidder->idbidders)->sum('winning_cost')));
|
||||||
|
|
||||||
|
$payment_method = 3; // Credit Card
|
||||||
|
$cc_transaction = $body['auth_guid'] ??
|
||||||
|
($status['transaction_id'] ??
|
||||||
|
($status['transactionId'] ??
|
||||||
|
($status['id'] ?? 'NORTH_EC')));
|
||||||
|
|
||||||
|
$cc_amount = $winnertotal;
|
||||||
|
$check_number = null;
|
||||||
|
|
||||||
|
$checkout_id = DB::table('checkout')->insertGetID(
|
||||||
|
[
|
||||||
|
'bidder_num' => $bidder->idbidders,
|
||||||
|
'winnertotal' => $winnertotal,
|
||||||
|
'payment_method' => $payment_method,
|
||||||
|
'check_number' => $check_number,
|
||||||
|
'cc_transaction' => $cc_transaction,
|
||||||
|
'cc_amount' => $cc_amount,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$checkout_id = $existingCheckout->checkout_id;
|
||||||
|
$payment_method = $existingCheckout->payment_method;
|
||||||
|
$cc_transaction = $existingCheckout->cc_transaction;
|
||||||
|
$check_number = $existingCheckout->check_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replicate the data for checkout_complete view
|
||||||
|
$checkout_list_results = DB::select("SELECT
|
||||||
|
*, items.item_assigned_num, items.item_desc
|
||||||
|
FROM winning_bids
|
||||||
|
INNER JOIN items AS items
|
||||||
|
ON winning_bids.winning_item_num=items.iditems
|
||||||
|
WHERE winning_bidder_num = $bidder->idbidders
|
||||||
|
");
|
||||||
|
|
||||||
|
$checkout_info_results = DB::select("SELECT
|
||||||
|
winning_bids.*,
|
||||||
|
bidders.*,
|
||||||
|
sum(winning_cost) AS total_cost
|
||||||
|
FROM winning_bids
|
||||||
|
INNER JOIN bidders AS bidders
|
||||||
|
ON winning_bids.winning_bidder_num=bidders.idbidders
|
||||||
|
WHERE winning_bidder_num = $bidder->idbidders
|
||||||
|
GROUP BY winning_bids.winning_bidder_num
|
||||||
|
");
|
||||||
|
|
||||||
|
return view('checkout_complete', [
|
||||||
|
'checkout_result' => $checkout_id,
|
||||||
|
'checkout_list_results' => $checkout_list_results,
|
||||||
|
'checkout_info_results' => $checkout_info_results,
|
||||||
|
'payment_method' => $payment_method,
|
||||||
|
'check_number' => $check_number,
|
||||||
|
'cc_transaction' => $cc_transaction
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/mywinnings?bidder_number=' . $bidder->bidder_assigned_number)->with('error', 'Payment not completed. Status: ' . ($status['status'] ?? 'unknown'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use View;
|
use View;
|
||||||
use App\helpers;
|
use App\helpers;
|
||||||
use PDF;
|
use Spatie\LaravelPdf\Facades\Pdf;
|
||||||
use App\Models\Bidders;
|
use App\Models\Bidders;
|
||||||
use App\Models\Items;
|
use App\Models\Items;
|
||||||
use App\Models\Checkout;
|
use App\Models\Checkout;
|
||||||
@@ -19,7 +19,7 @@ use App\Models\CarShowCategory;
|
|||||||
use App\Models\Types;
|
use App\Models\Types;
|
||||||
use App\Models\Vehicles;
|
use App\Models\Vehicles;
|
||||||
use App\Models\VehicleScores;
|
use App\Models\VehicleScores;
|
||||||
|
use Dompdf\Dompdf;
|
||||||
class PagesController extends Controller
|
class PagesController extends Controller
|
||||||
{
|
{
|
||||||
public function home()
|
public function home()
|
||||||
@@ -250,6 +250,49 @@ class PagesController extends Controller
|
|||||||
return view('receiptpdf', $checkout_data);
|
return view('receiptpdf', $checkout_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadReceiptPdf(Request $request)
|
||||||
|
{
|
||||||
|
$checkoutid = $request->checkout_id;
|
||||||
|
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)->first();
|
||||||
|
if (!$checkout_final_results) {
|
||||||
|
return redirect('/mywinnings')->with('error', 'Checkout record not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bidder_num = $checkout_final_results->bidder_num;
|
||||||
|
$checkout_list_results = DB::select("SELECT
|
||||||
|
*, items.item_assigned_num, items.item_desc
|
||||||
|
FROM winning_bids
|
||||||
|
INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems
|
||||||
|
WHERE winning_bidder_num = $bidder_num
|
||||||
|
");
|
||||||
|
$checkout_info_results = DB::select("SELECT
|
||||||
|
winning_bids.*,
|
||||||
|
bidders.*,
|
||||||
|
sum(winning_cost) AS total_cost
|
||||||
|
FROM winning_bids
|
||||||
|
INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders
|
||||||
|
WHERE winning_bidder_num = $bidder_num
|
||||||
|
GROUP BY winning_bids.winning_bidder_num
|
||||||
|
");
|
||||||
|
|
||||||
|
$options = new \Dompdf\Options();
|
||||||
|
$options->set('isHtml5ParserEnabled', true);
|
||||||
|
$options->set('isRemoteEnabled', true);
|
||||||
|
$dompdf = new Dompdf($options);
|
||||||
|
|
||||||
|
$html = view('receiptpdf', [
|
||||||
|
'checkout_final_results' => $checkout_final_results,
|
||||||
|
'checkout_list_results' => $checkout_list_results,
|
||||||
|
'checkout_info_results' => $checkout_info_results
|
||||||
|
])->render();
|
||||||
|
|
||||||
|
$dompdf->loadHtml($html);
|
||||||
|
$dompdf->setPaper('letter', 'portrait');
|
||||||
|
$dompdf->render();
|
||||||
|
|
||||||
|
return $dompdf->stream('receipt-'.$checkoutid.'.pdf');
|
||||||
|
}
|
||||||
|
|
||||||
public function reprintReceipt(Request $reprint_receipt_req)
|
public function reprintReceipt(Request $reprint_receipt_req)
|
||||||
{
|
{
|
||||||
if (!$reprint_receipt_req->reprintbiddernum) {
|
if (!$reprint_receipt_req->reprintbiddernum) {
|
||||||
@@ -535,10 +578,13 @@ class PagesController extends Controller
|
|||||||
|
|
||||||
$total_cost = $winnings->sum('winning_cost');
|
$total_cost = $winnings->sum('winning_cost');
|
||||||
|
|
||||||
|
$is_checked_out = \App\Models\Checkout::where('bidder_num', $bidder->idbidders)->exists();
|
||||||
|
|
||||||
return view('mywinnings_results', [
|
return view('mywinnings_results', [
|
||||||
'bidder' => $bidder,
|
'bidder' => $bidder,
|
||||||
'winnings' => $winnings,
|
'winnings' => $winnings,
|
||||||
'total_cost' => $total_cost
|
'total_cost' => $total_cost,
|
||||||
|
'is_checked_out' => $is_checked_out
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -5,16 +5,18 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.3",
|
||||||
"barryvdh/laravel-snappy": "^1.0",
|
"barryvdh/laravel-snappy": "^1.0",
|
||||||
"carlos-meneses/laravel-mpdf": "^2.1",
|
"carlos-meneses/laravel-mpdf": "^2.1",
|
||||||
|
"dompdf/dompdf": "^3.1",
|
||||||
"filament/filament": "^5.0",
|
"filament/filament": "^5.0",
|
||||||
"kovah/laravel-socialite-oidc": "^0.7.0",
|
"kovah/laravel-socialite-oidc": "^0.7.0",
|
||||||
"laravel/framework": "^11.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/socialite": "^5.26",
|
"laravel/socialite": "^5.26",
|
||||||
"laravel/tinker": "^2.9",
|
"laravel/tinker": "^2.9",
|
||||||
"laravel/ui": "^4.2",
|
"laravel/ui": "^4.2",
|
||||||
"socialiteproviders/manager": "^4.9"
|
"socialiteproviders/manager": "^4.9",
|
||||||
|
"spatie/laravel-pdf": "^2.8"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.8",
|
"barryvdh/laravel-debugbar": "^3.8",
|
||||||
@@ -69,5 +71,7 @@
|
|||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"optimize-autoloader": true
|
"optimize-autoloader": true
|
||||||
}
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+813
-127
File diff suppressed because it is too large
Load Diff
@@ -42,4 +42,10 @@ return [
|
|||||||
'redirect' => env('OIDC_REDIRECT_URI'),
|
'redirect' => env('OIDC_REDIRECT_URI'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'north' => [
|
||||||
|
'checkout_id' => env('NORTH_CHECKOUT_ID'),
|
||||||
|
'profile_id' => env('NORTH_PROFILE_ID'),
|
||||||
|
'private_api_key' => env('NORTH_PRIVATE_API_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -14,21 +14,24 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<h4>
|
<h4>
|
||||||
St. John Catholic Church
|
North Hackathon
|
||||||
<br>
|
<br>
|
||||||
Car Show Silent Auction
|
Car Show Silent Auction
|
||||||
<br>
|
<br>
|
||||||
2099 N. Hacker Rd.
|
250 Stephenson Hwy
|
||||||
<br>
|
<br>
|
||||||
Howell, MI 48855
|
Troy, MI 48083
|
||||||
</h4>
|
</h4>
|
||||||
</th>
|
</th>
|
||||||
<th align='right'>
|
<th align='right'>
|
||||||
<h2>
|
<div class="btn-group">
|
||||||
<a class="btn btn-primary" target=_blank href="receiptpdf?checkout_id={{$checkout_result }}" role="button">
|
<a class="btn btn-primary" target=_blank href="{{ route('receiptpdf', ['checkout_id' => $checkout_result]) }}" role="button">
|
||||||
Print Receipt
|
Print Receipt
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
<a class="btn btn-success" href="{{ route('download_receipt', ['checkout_id' => $checkout_result]) }}" role="button">
|
||||||
|
Save Receipt PDF
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -8,6 +8,24 @@
|
|||||||
<div class="panel-heading">Winnings for Bidder #{{ $bidder->bidder_assigned_number }} - {{ $bidder->bidder_fname }} {{ $bidder->bidder_lname }}</div>
|
<div class="panel-heading">Winnings for Bidder #{{ $bidder->bidder_assigned_number }} - {{ $bidder->bidder_fname }} {{ $bidder->bidder_lname }}</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@if (isset($error))
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ $error }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div class="alert alert-success">
|
||||||
|
{{ session('success') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if($winnings->count() > 0)
|
@if($winnings->count() > 0)
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -33,6 +51,16 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@if(!$is_checked_out)
|
||||||
|
<div class="text-right">
|
||||||
|
<a href="{{ route('north.checkout', ['bidder_id' => $bidder->idbidders]) }}" class="btn btn-success btn-lg">Pay Now with Credit Card</a>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="alert alert-success text-center">
|
||||||
|
<strong>Checked Out!</strong> Your payment has been processed.
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
<p>No winning bids found for this bidder number.</p>
|
<p>No winning bids found for this bidder number.</p>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 col-md-offset-0">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Checkout for Bidder #{{ $bidder->bidder_assigned_number }}</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<h4>Total Amount Due: ${{ number_format($total_cost, 2) }}</h4>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div id="checkout-container" style="height: 100vh; overflow: hidden;">
|
||||||
|
<div class="text-center">
|
||||||
|
<p>Loading secure checkout...</p>
|
||||||
|
<div class="spinner-border" role="status">
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<div class="text-center">
|
||||||
|
<a href="/mywinnings?bidder_number={{ $bidder->bidder_assigned_number }}" class="btn btn-default">Cancel and Return</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://checkout.north.com/checkout.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
const bidderId = "{{ $bidder->idbidders }}";
|
||||||
|
const csrfToken = "{{ csrf_token() }}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create a checkout session
|
||||||
|
const response = await fetch(`/north/session/${bidderId}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': csrfToken
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
console.log('North Session Response:', data);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
document.getElementById('checkout-container').innerHTML = `<div class="alert alert-danger">${data.error}</div>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sessionToken = data.sessionToken;
|
||||||
|
if (!sessionToken) {
|
||||||
|
document.getElementById('checkout-container').innerHTML = `<div class="alert alert-danger">Invalid session token received from server.</div>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize North Checkout
|
||||||
|
// The global 'checkout' object is provided by checkout.js
|
||||||
|
console.log('Mounting checkout with token:', sessionToken);
|
||||||
|
await checkout.mount(sessionToken, 'checkout-container');
|
||||||
|
|
||||||
|
const handleCompletion = (result) => {
|
||||||
|
console.log('Payment complete event received:', result);
|
||||||
|
// Redirect to verify the payment on the server
|
||||||
|
window.location.href = `/north/verify/${bidderId}?sessionToken=${sessionToken}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle completion
|
||||||
|
checkout.onPaymentComplete(handleCompletion);
|
||||||
|
|
||||||
|
// Support for possible variations in event names
|
||||||
|
if (typeof checkout.onPaymentSuccess === 'function') {
|
||||||
|
checkout.onPaymentSuccess(handleCompletion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle errors
|
||||||
|
if (typeof checkout.onPaymentError === 'function') {
|
||||||
|
checkout.onPaymentError((error) => {
|
||||||
|
console.error('Payment Error:', error);
|
||||||
|
// Don't clear the container, just prepend the error
|
||||||
|
const errorDiv = document.createElement('div');
|
||||||
|
errorDiv.className = 'alert alert-danger';
|
||||||
|
errorDiv.innerHTML = `<strong>Payment Error:</strong> ${error.message || 'An error occurred during payment.'}`;
|
||||||
|
document.querySelector('.panel-body').prepend(errorDiv);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show a fallback button after a short delay to allow for manual verification if the redirect fails
|
||||||
|
setTimeout(() => {
|
||||||
|
const fallbackDiv = document.createElement('div');
|
||||||
|
fallbackDiv.className = 'text-center';
|
||||||
|
fallbackDiv.style.marginTop = '20px';
|
||||||
|
fallbackDiv.innerHTML = `
|
||||||
|
<p class="text-muted">Already completed your payment but still on this page?</p>
|
||||||
|
<a href="/north/verify/${bidderId}?sessionToken=${sessionToken}" class="btn btn-info">Verify Payment Status</a>
|
||||||
|
`;
|
||||||
|
document.querySelector('.panel-body').appendChild(fallbackDiv);
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Checkout Error:', error);
|
||||||
|
document.getElementById('checkout-container').innerHTML = '<div class="alert alert-danger">An error occurred while initializing checkout. Please try again.</div>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -10,13 +10,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<h4>
|
<h4>
|
||||||
St. John Catholic Church
|
North Hackathon
|
||||||
<br>
|
<br>
|
||||||
Car Show Silent Auction
|
Car Show Silent Auction
|
||||||
<br>
|
<br>
|
||||||
2099 N. Hacker Rd.
|
250 Stephenson Hwy
|
||||||
<br>
|
<br>
|
||||||
Howell, MI 48855
|
Troy, MI 48083
|
||||||
</h4>
|
</h4>
|
||||||
</th>
|
</th>
|
||||||
<th align='right'>
|
<th align='right'>
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<h4>
|
<h4>
|
||||||
St. John Catholic Church
|
North Hackathon
|
||||||
<br>
|
<br>
|
||||||
Car Show Silent Auction
|
Car Show Silent Auction
|
||||||
<br>
|
<br>
|
||||||
2099 N. Hacker Rd.
|
250 Stephenson Hwy
|
||||||
<br>
|
<br>
|
||||||
Howell, MI 48855
|
Troy, MI 48083
|
||||||
</h4>
|
</h4>
|
||||||
</th>
|
</th>
|
||||||
<th align='right'>
|
<th align='right'>
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ Route::get('showscoresbycar', [ 'uses' => 'PagesController@showscoresbycar']);
|
|||||||
Route::get('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
Route::get('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
||||||
Route::post('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
Route::post('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
||||||
|
|
||||||
|
// North Embedded Checkout
|
||||||
|
Route::get('north/checkout/{bidder_id}', [ 'uses' => 'NorthCheckoutController@checkout' ])->name('north.checkout');
|
||||||
|
Route::post('north/session/{bidder_id}', [ 'uses' => 'NorthCheckoutController@createSession' ])->name('north.session');
|
||||||
|
Route::get('north/verify/{bidder_id}', [ 'uses' => 'NorthCheckoutController@verify' ])->name('north.verify');
|
||||||
|
|
||||||
Route::group(['middleware' => 'auth'], function() {
|
Route::group(['middleware' => 'auth'], function() {
|
||||||
Route::get('bidders', [ 'uses' => 'PagesController@bidders']);
|
Route::get('bidders', [ 'uses' => 'PagesController@bidders']);
|
||||||
Route::post('bidders', [ 'uses' => 'PagesController@bidders']);
|
Route::post('bidders', [ 'uses' => 'PagesController@bidders']);
|
||||||
@@ -45,6 +50,7 @@ Route::group(['middleware' => 'auth'], function() {
|
|||||||
Route::get('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
|
Route::get('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
|
||||||
Route::post('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
|
Route::post('reprint_receipt', ['uses' => 'PagesController@reprintReceipt']);
|
||||||
Route::get('receiptpdf', ['uses' => 'PagesController@receiptpdf'])->name('receiptpdf');
|
Route::get('receiptpdf', ['uses' => 'PagesController@receiptpdf'])->name('receiptpdf');
|
||||||
|
Route::get('download_receipt', ['uses' => 'PagesController@downloadReceiptPdf'])->name('download_receipt');
|
||||||
Route::get('winners', [ 'uses' => 'PagesController@winners']);
|
Route::get('winners', [ 'uses' => 'PagesController@winners']);
|
||||||
Route::post('winners', [ 'uses' => 'PagesController@winners']);
|
Route::post('winners', [ 'uses' => 'PagesController@winners']);
|
||||||
Route::get('winnerlist', [ 'uses' => 'PagesController@winnerlist']);
|
Route::get('winnerlist', [ 'uses' => 'PagesController@winnerlist']);
|
||||||
|
|||||||
Reference in New Issue
Block a user