|
524 | 524 | $contact_extension = preg_replace("/[^0-9]/", '',$row['contact_extension']); |
525 | 525 | $contact_mobile = sanitizeInput(formatPhoneNumber($row['contact_mobile'], $row['contact_mobile_country_code'])); |
526 | 526 |
|
527 | | - // Check to make sure saved payment method belongs to logged in client |
528 | | - if ($client_id !== $session_client_id) { |
529 | | - flash_alert("Saved Payment method does not belong to you!", 'danger'); |
530 | | - redirect(); |
531 | | - } |
532 | | - |
533 | 527 | // Get ITFlow company details |
534 | 528 | $sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1"); |
535 | 529 | $row = mysqli_fetch_assoc($sql); |
|
548 | 542 | $config_invoice_from_email = sanitizeInput($config_invoice_from_email); |
549 | 543 |
|
550 | 544 | // Get Client Payment Details |
551 | | - $sql = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods LEFT JOIN payment_providers ON saved_payment_provider_id = payment_provider_id LEFT JOIN client_payment_provider ON saved_payment_client_id = client_id WHERE saved_payment_id = $saved_payment_id LIMIT 1"); |
| 545 | + $sql = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods LEFT JOIN payment_providers ON saved_payment_provider_id = payment_provider_id LEFT JOIN client_payment_provider ON saved_payment_client_id = client_id WHERE saved_payment_id = $saved_payment_id AND saved_payment_client_id = $session_client_id LIMIT 1"); |
552 | 546 | $row = mysqli_fetch_assoc($sql); |
553 | 547 |
|
554 | 548 | $public_key = sanitizeInput($row['payment_provider_public_key']); |
|
561 | 555 | $payment_provider_client = sanitizeInput($row['payment_provider_client']); |
562 | 556 | $saved_payment_method = sanitizeInput($row['saved_payment_provider_method']); |
563 | 557 | $saved_payment_description = sanitizeInput($row['saved_payment_description']); |
| 558 | + $payment_client_id = intval($row['saved_payment_client_id']); |
564 | 559 |
|
565 | 560 | // Sanity checks |
566 | | - if (!$payment_provider_client || !$saved_payment_method) { |
| 561 | + // Check to make invoice belongs to logged in client |
| 562 | + if ($client_id !== $session_client_id) { |
| 563 | + flash_alert("Invoice does not belong to you!", 'danger'); |
| 564 | + redirect(); |
| 565 | + } elseif ($payment_client_id !== $session_client_id) { |
| 566 | + flash_alert("Saved Payment method does not belong to you!", 'danger'); |
| 567 | + redirect(); |
| 568 | + } elseif (!$payment_provider_client || !$saved_payment_method) { |
567 | 569 | flash_alert("Stripe not enabled or no client card saved", 'error'); |
568 | 570 | redirect(); |
569 | 571 | } elseif ($invoice_status !== 'Sent' && $invoice_status !== 'Viewed') { |
|
0 commit comments