feat: integrate North Embedded Checkout for bidder payments #1

Merged
rlong merged 26 commits from feature/north-embedded-checkout into master 2026-05-01 10:20:22 -04:00
Showing only changes of commit 982efbf2bd - Show all commits
@@ -131,18 +131,22 @@ class NorthCheckoutController extends Controller
}
$status = $response->json();
$currentStatus = $status['status'] ?? '';
// The North API status check might return success/completed.
// Based on docs, we should check status.
if (isset($status['status']) && ($status['status'] === 'completed' || $status['status'] === 'success')) {
// The North API status check might return Approved, completed, or success.
$successStatuses = ['approved', 'completed', 'success'];
if (in_array(strtolower($currentStatus), $successStatuses)) {
// Check if already checked out to avoid duplicates
$existingCheckout = Checkout::where('bidder_num', $bidder->idbidders)->first();
if (!$existingCheckout) {
$winnertotal = $status['amount'] ?? WinningBids::where('winning_bidder_num', $bidder->idbidders)->sum('winning_cost');
// According to docs, when status is Approved, transaction details are in 'body'
$body = $status['body'] ?? [];
$winnertotal = $status['amount'] ?? ($body['amount'] ?? WinningBids::where('winning_bidder_num', $bidder->idbidders)->sum('winning_cost'));
$payment_method = 3; // Credit Card
$cc_transaction = $status['transactionId'] ?? 'NORTH_EC';
$cc_amount = $status['amount'] ?? $winnertotal;
$cc_transaction = $body['auth_guid'] ?? ($status['transactionId'] ?? 'NORTH_EC');
$cc_amount = $winnertotal;
$check_number = null;
$checkout_id = DB::table('checkout')->insertGetID(