<?php

if ( ! defined( 'ABSPATH' ) ) exit;

function minicomerce_save_order_id($paypalId, $id){  
 try {
         global $wpdb;
         $minicomerce_customers = $wpdb->prefix . MINICOMERCE_REPORTS;
          
            $data         = array( 'id_salePaypal' => $paypalId );
            $where        = array( 'id' => intval($id) );
            $format       = array( '%s' );
            $where_format = array( '%d' );
         

           $result = $wpdb->update(
              $minicomerce_customers,
              $data,
              $where,
              $format,
              $where_format
              );

           if ($result === 0) {
               return array("status" => 404 , "message" => "Error: " . $wpdb->last_error);
           }   

           return array("status" => 200 , "message" => "Success" ); 

         } 
         catch (Exception $e) {
            return array("status" => 404 , "message" => "Error: " . $e->getMessage());
        }
         
  }