Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Hashing user data that is sent to Facebook via conversion API
Browse files Browse the repository at this point in the history
Summary: We are currently not hashing user data that is being sent to the conversion API

Reviewed By: zlik

Differential Revision: D31057307

fbshipit-source-id: 1ba38560
  • Loading branch information
fbisaso authored and facebook-github-bot committed Sep 23, 2021
1 parent 012db68 commit e1d4306
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions Helper/MagentoDataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,24 +410,26 @@ public function getUserDataFromOrder()
$userData = [];

$userData[AAMSettingsFields::EXTERNAL_ID] = $order->getCustomerId();
$userData[AAMSettingsFields::EMAIL] = $order->getCustomerEmail();
$userData[AAMSettingsFields::FIRST_NAME] = $order->getCustomerFirstname();
$userData[AAMSettingsFields::LAST_NAME] = $order->getCustomerLastname();
$userData[AAMSettingsFields::DATE_OF_BIRTH] = $order->getCustomerDob();
$userData[AAMSettingsFields::EMAIL] = $this->hashValue($order->getCustomerEmail());
$userData[AAMSettingsFields::FIRST_NAME] = $this->hashValue($order->getCustomerFirstname());
$userData[AAMSettingsFields::LAST_NAME] = $this->hashValue($order->getCustomerLastname());
$userData[AAMSettingsFields::DATE_OF_BIRTH] = $this->hashValue($order->getCustomerDob());
if ($order->getCustomerGender()) {
$genderId = $order->getCustomerGender();
$userData[AAMSettingsFields::GENDER] =
$this->customerMetadata->getAttributeMetadata('gender')
->getOptions()[$genderId]->getLabel();
$this->hashValue(
$this->customerMetadata->getAttributeMetadata('gender')
->getOptions()[$genderId]->getLabel()
);
}

$billingAddress = $order->getBillingAddress();
if ($billingAddress) {
$userData[AAMSettingsFields::ZIP_CODE] = $billingAddress->getPostcode();
$userData[AAMSettingsFields::CITY] = $billingAddress->getCity();
$userData[AAMSettingsFields::PHONE] = $billingAddress->getTelephone();
$userData[AAMSettingsFields::STATE] = $billingAddress->getRegionCode();
$userData[AAMSettingsFields::COUNTRY] = $billingAddress->getCountryId();
$userData[AAMSettingsFields::ZIP_CODE] = $this->hashValue($billingAddress->getPostcode());
$userData[AAMSettingsFields::CITY] = $this->hashValue($billingAddress->getCity());
$userData[AAMSettingsFields::PHONE] = $this->hashValue($billingAddress->getTelephone());
$userData[AAMSettingsFields::STATE] = $this->hashValue($billingAddress->getRegionCode());
$userData[AAMSettingsFields::COUNTRY] = $this->hashValue($billingAddress->getCountryId());
}

return array_filter($userData);
Expand All @@ -450,28 +452,34 @@ public function getUserDataFromSession()
$userData = [];

$userData[AAMSettingsFields::EXTERNAL_ID] = $customer->getId();
$userData[AAMSettingsFields::EMAIL] = $customer->getEmail();
$userData[AAMSettingsFields::FIRST_NAME] = $customer->getFirstname();
$userData[AAMSettingsFields::LAST_NAME] = $customer->getLastname();
$userData[AAMSettingsFields::DATE_OF_BIRTH] = $customer->getDob();
$userData[AAMSettingsFields::EMAIL] = $this->hashValue($customer->getEmail());
$userData[AAMSettingsFields::FIRST_NAME] = $this->hashValue($customer->getFirstname());
$userData[AAMSettingsFields::LAST_NAME] = $this->hashValue($customer->getLastname());
$userData[AAMSettingsFields::DATE_OF_BIRTH] = $this->hashValue($customer->getDob());
if ($customer->getGender()) {
$genderId = $customer->getGender();
$userData[AAMSettingsFields::GENDER] =
$this->customerMetadata->getAttributeMetadata('gender')
->getOptions()[$genderId]->getLabel();
$this->hashValue(
$this->customerMetadata->getAttributeMetadata('gender')
->getOptions()[$genderId]->getLabel()
);
}

$billingAddress = $this->getCustomerAddress($customer);
if ($billingAddress) {
$userData[AAMSettingsFields::ZIP_CODE] = $billingAddress->getPostcode();
$userData[AAMSettingsFields::CITY] = $billingAddress->getCity();
$userData[AAMSettingsFields::PHONE] = $billingAddress->getTelephone();
$userData[AAMSettingsFields::STATE] = $billingAddress->getRegionCode();
$userData[AAMSettingsFields::COUNTRY] = $billingAddress->getCountryId();
$userData[AAMSettingsFields::ZIP_CODE] = $this->hashValue($billingAddress->getPostcode());
$userData[AAMSettingsFields::CITY] = $this->hashValue($billingAddress->getCity());
$userData[AAMSettingsFields::PHONE] = $this->hashValue($billingAddress->getTelephone());
$userData[AAMSettingsFields::STATE] = $this->hashValue($billingAddress->getRegionCode());
$userData[AAMSettingsFields::COUNTRY] = $this->hashValue($billingAddress->getCountryId());
}

return array_filter($userData);
}

private function hashValue($string){
return hash('sha256', strtolower($string));
}

// TODO Remaining user/custom data methods that can be obtained using Magento.
}

0 comments on commit e1d4306

Please sign in to comment.