diff --git a/app/Http/Controllers/NorthCheckoutController.php b/app/Http/Controllers/NorthCheckoutController.php index c2fb1dc..23446b7 100644 --- a/app/Http/Controllers/NorthCheckoutController.php +++ b/app/Http/Controllers/NorthCheckoutController.php @@ -37,9 +37,17 @@ class NorthCheckoutController extends Controller public function createSession(Request $request, $bidder_id) { $bidder = Bidders::findOrFail($bidder_id); - $winnings = WinningBids::where('winning_bidder_num', $bidder->idbidders)->get(); + $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'); @@ -56,6 +64,7 @@ class NorthCheckoutController extends Controller 'checkoutId' => $checkoutId, 'profileId' => $profileId, 'amount' => (float)$total_cost, + 'products' => $products, ]); if ($response->failed()) { diff --git a/resources/views/north_checkout.blade.php b/resources/views/north_checkout.blade.php index 0084baa..9d83388 100644 --- a/resources/views/north_checkout.blade.php +++ b/resources/views/north_checkout.blade.php @@ -1,6 +1,19 @@ @extends('layouts.app') @section('content') +