HEX
Server: Apache
System: Linux server1.panigaletech.com 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/dev.captainschairit.com/wp-content/themes/captainschare/update-customer-profile.php
<?php
  require 'vendor/autoload.php';
  require_once 'constants/SampleCodeConstants.php';
  use net\authorize\api\contract\v1 as AnetAPI;
  use net\authorize\api\controller as AnetController;

  define("AUTHORIZENET_LOG_FILE", "phplog");
  
  function updateCustomerProfile($customerProfileId, $customerPaymentProfileId, $email, $customer_id)
{
    /* Create a merchantAuthenticationType object with authentication details
       retrieved from the constants file */
    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
    $merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
    
    // Set the transaction's refId
    $refId = 'ref' . time();
  
    // Get Current Profile
    $request = new AnetAPI\GetCustomerProfileRequest();
	  $request->setMerchantAuthentication($merchantAuthentication);
	  $request->setCustomerProfileId($customerProfileId);
	  $controller = new AnetController\GetCustomerProfileController($request);
// 	  $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
	  $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
    // echo '<pre>'; print_r($response->getProfile()->getMerchantCustomerId()); exit;
    // Update an existing customer profile
    
    $updatecustomerprofile = new AnetAPI\CustomerProfileExType();
    $updatecustomerprofile->setCustomerProfileId($customerProfileId);
    // $updatecustomerprofile->setDescription("Updated existing Profile Request");
    $updatecustomerprofile->setEmail($email);
    // $merchantCustomerId = 'M_'.time().rand(1,150);
    $updatecustomerprofile->setMerchantCustomerId($customer_id);
    // echo 'here'; exit;
    $paymentprofile = new AnetAPI\CustomerPaymentProfileType();

    $paymentprofile->setCustomerType('individual');
    // $paymentprofile->setBillTo($billto);
    // $paymentprofile->setPayment($paymentCreditCard);

    // $paymentprofiles[] = $paymentprofile;

    $request_profile = new AnetAPI\UpdateCustomerProfileRequest();
    $request_profile->setMerchantAuthentication($merchantAuthentication);
    $request_profile->setProfile($updatecustomerprofile);
      
    // $request = new AnetAPI\UpdateCustomerPaymentProfileRequest();
    
    // $request->setMerchantAuthentication($merchantAuthentication);
    
    // $request->setCustomerProfileId($customerProfileId);
    // $request->setPaymentProfile( $paymentprofile );
    // $request->setPaymentProfiles($paymentprofiles);
    // echo 'here'; exit;

    $controller = new AnetController\UpdateCustomerProfileController($request_profile);
//     $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
	  $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
    // echo '<pre>'; print_r($response); exit;
    if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
    {
      // echo "UpdateCustomerProfile SUCCESS : " .  "\n";
    // Validate the description and e-mail that was updated
        $request = new AnetAPI\GetCustomerProfileRequest();
        $request->setMerchantAuthentication($merchantAuthentication);
        $request->setCustomerProfileId($customerProfileId);
        $controller = new AnetController\GetCustomerProfileController($request);
        $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
// 		$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
        
    }
    else
    {
      // echo "ERROR :  UpdateCustomerProfile: Invalid response\n";
      $errorMessages = $response->getMessages()->getMessage();
      // echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
    }
    return $response;
  }
  // if(!defined('DONT_RUN_SAMPLES'))
  //   updateCustomerProfile();