private function generateUpdateAccountPayload()

in eCommerce platforms/Adobe Magento/src/code/local/Microsoft/Dfp/Model/Observer.php [157:226]


	private function generateUpdateAccountPayload($customer)
	{
		$_metadata = array(
			"trackingId"		=> $this->dfp->GUID(),
			"merchantTimeStamp"	=> date('c')
		);

		// Device FingerPrinting Details
		$deviceContext = array(
			"deviceContextId"	=> Mage::getSingleton('core/session')->getFptDfpSessionId(),
			"ipAddress"			=> getenv('HTTP_CLIENT_IP') ?? getenv('HTTP_X_FORWARDED_FOR') ?? getenv('HTTP_X_FORWARDED') ?? getenv('HTTP_FORWARDED_FOR') ?? getenv('HTTP_FORWARDED') ?? getenv('REMOTE_ADDR'),
			"provider"			=> Microsoft_Dfp_Helper_Data::DEVICE_CONTEXT_PROVIDER_DFP
		);

		//Address details
		$addressList = array();
		$billingAddress = $customer->getDefaultBillingAddress();
		$billingAddressStreet = $billingAddress->getStreet();
		$addressList[] = array(
			"type"		=> 	Microsoft_Dfp_Helper_Data::ADDRESS_TYPE_BILLING,
			"firstName"	=>	$billingAddress["firstname"],
			"lastName"	=>	$billingAddress["lastname"],
			"street1"	=>	$billingAddressStreet[0],
			"street2"	=>	count($billingAddressStreet) > 1 ? $billingAddressStreet[1] : null,
			"city"		=>	$billingAddress["city"],
			"state"		=>	$billingAddress["region"],
			"zipCode"	=>	$billingAddress["postcode"],
			"country"	=>	$billingAddress["country_id"]
		);

		$shippingAddress = $customer->getDefaultShippingAddress();
		$shippingAddressStreet = $shippingAddress->getStreet();
		$addressList[] = array(
			"type"		=> 	Microsoft_Dfp_Helper_Data::ADDRESS_TYPE_SHIPPING,
			"firstName"	=>	$shippingAddress["firstname"],
			"lastName"	=>	$shippingAddress["lastname"],
			"street1"	=>	$shippingAddressStreet[0],
			"street2"	=>	count($shippingAddressStreet) > 1 ? $shippingAddressStreet[1] : null,
			"city"		=>	$shippingAddress["city"],
			"state"		=>	$shippingAddress["region"],
			"zipCode"	=>	$shippingAddress["postcode"],
			"country"	=>	$shippingAddress["country_id"]
		);

		foreach ($customer->getAdditionalAddresses() as $item) {
			$addressList[] = array(
				"type"		=> 	Microsoft_Dfp_Helper_Data::ADDRESS_TYPE_SHIPPING,
				"firstName"	=>	$item["firstname"],
				"lastName"	=>	$item["lastname"],
				"street1"	=>	$item["street"],
				"city"		=>	$item["city"],
				"state"		=>	$item["region"],
				"zipCode"	=>	$item["postcode"],
				"country"	=>	$item["country_id"],
			);
		}

		return array(
			'userId'       	         => $customer->getEmail(),
			'firstName'       	     => $customer->getFirstname(),
			'lastName'       	     => $customer->getLastname(),
			'email'       	         => $customer->getEmail(),
			'profileType'       	 => Microsoft_Dfp_Helper_Data::USER_PROFILE_TYPE_CONSUMER,
			'isEmailValidated'       => false,
			'isPhoneNumberValidated' => false,
			'addressList'            => $addressList,
			'deviceContext'          => $deviceContext,
			'_metadata'     		 => $_metadata
		);
	}