The Microsoft Dynamics 365 Fraud Protection sample for Adobe Magento demonstrates how to integrate and call the Dynamics 365 Fraud Protection APIs for merchants using the Adobe Magento eCommerce platform.
It demonstrates the primary uses of the Dynamics 365 Fraud Protection APIs:
- Requesting a Dynamics 365 Fraud Protection risk recommendation for purchases and using the recommendation to decide whether to charge the customer.
- Managing users and their associated information in the Dynamics 365 Fraud Protection system (for example, basic info, payment methods, addresses, and so on).
- Reporting chargebacks and refunds.
Before running the solution, install these prerequisites:
- A PHP editor, such as Visual Studio Code.
- XAMPP 7.2.24 OR any compatible version supporting Magento ver 1.9.4.3.
- Ensure the SOAP PHP extension is installed/enabled.
- Ensure that /xampp/php/php.ini has properly set SSL bundle paths, if not already valid:
- curl.cainfo="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
- openssl.cafile="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
-
Download Magento ver 1.9.4.3 from https://magento.com/tech-resources/download
-
Create a folder magento under c:/xampp/htdocs and extract the downloaded zip file to the newly created magento folder.
-
Use the XAMPP Control Panel to ensure that Apache and MySQL are running.
-
Open phpMyAdmin - http://localhost/phpmyadmin - and create the magento database.
-
Complete Magento installation:
-
Read and accept the terms and condition.
-
Select appropriate Locale settings and click on Continue button.
-
Input the configuration values below and click Continue
- Host - localhost
- Database Name – magento (Same name as created in step 4)
- User Name – root, or create a new user in PhpMyAdmin for Magento.
- User Password – BLANK (NO value), or use the new user's password.
- Base URL - For local development, it's recommended to do HOSTS file mapping to create a local name to run Magento on. For instance, hosts map 'store' to 127.0.0.1 in your HOSTs file and then setup Magento at: http://store/magento. See https://magento.stackexchange.com/a/80377 for more. If Magento complains about an invalid URL, see https://stackoverflow.com/a/32132889 for more.
- Check Skip Base URL Validation Before the Next Step checkbox
-
Create Admin Account. This admin account will be used to log into Magento Admin application.
-
Please make a note of your encryption key. Click on Go to Frontend and Go to Backend buttons.
-
Clone or download this repo’s code.
-
Copy the 'src' folder’s contents into the xampp\htdocs\magento\app folder.
-
Log in to the Admin Panel http://127.0.0.1/magento/index.php/admin/ and configure Dynamics 365 Fraud Protection settings.
-
Navigate to System -> Cache management and Flush Magento Cache.
-
Logout of the admin account and log back in or you may receive an error when saving the configuration in the next step.
-
Navigate to System -> Configuration and configure Dynamics 365 Fraud Protection:
- Purchase Assessment Type – select Protect or Evaluate
- Client ID - Client ID created for authentication.
- Client Secret - Client secret value for authentication
- API Resource URI - https://api.dfp.dynamics-int.com or https://api.dfp.dynamics.com depending on environment.
- Base URL – "Merchant API Endpoint" from your Dynamics 365 Fraud Protection dashboard.
- Purchase – /v1.0/MerchantServices/events/Purchase
- Purchase Status – /v1.0/MerchantServices/events/PurchaseStatus
- Bank Event – /v1.0/MerchantServices/events/BankEvent
- Chargeback – /v1.0/MerchantServices/events/Chargeback
- Refund – /v1.0/MerchantServices/events/Refund
- Update Account - /v1.0/MerchantServices/events/UpdateAccount
-
-
Enable "Saved Credit Cards" payment method part 1:
-
Add the code below inside the xampp\htdocs\magento\app\code\core\Mage\Payment\etc\config.xml under the <default>/<payment> node:
<ccsave> <active>1</active> <cctypes>AE,VI,MC,DI</cctypes> <model>payment/method_ccsave</model> <order_status>pending</order_status> <title>Credit Card (saved)</title> <allowspecific>0</allowspecific> <group>offline</group> </ccsave>
-
Add the code below inside xampp\htdocs\magento\app\code\core\Mage\Payment\etc\system.xml under the <config>/<sections>/<payment>/<groups> node:
<ccsave translate="label"> <label>Saved CC</label> <frontend_type>text</frontend_type> <sort_order>27</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <active translate="label"> <label>Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </active> <cctypes translate="label"> <label>Credit Card Types</label> <frontend_type>multiselect</frontend_type> <source_model>adminhtml/system_config_source_payment_cctype</source_model> <sort_order>4</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <can_be_empty>1</can_be_empty> </cctypes> <order_status translate="label"> <label>New Order Status</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_order_status_new</source_model> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </order_status> <sort_order translate="label"> <label>Sort Order</label> <frontend_type>text</frontend_type> <sort_order>100</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <frontend_class>validate-number</frontend_class> </sort_order> <title translate="label"> <label>Title</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </title> <useccv translate="label"> <label>Request Card Security Code</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>5</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </useccv> <centinel translate="label"> <label>3D Secure Card Validation</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </centinel> <centinel_is_mode_strict translate="label comment"> <label>Severe 3D Secure Card Validation</label> <comment>Severe validation removes chargeback liability on merchant.</comment> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>25</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <depends> <centinel>1</centinel> </depends> </centinel_is_mode_strict> <centinel_api_url translate="label comment"> <label>Centinel API URL</label> <comment>A value is required for live mode. Refer to your CardinalCommerce agreement.</comment> <frontend_type>text</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>30</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <depends> <centinel>1</centinel> </depends> </centinel_api_url> <allowspecific translate="label"> <label>Payment from Applicable Countries</label> <frontend_type>allowspecific</frontend_type> <sort_order>50</sort_order> <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </allowspecific> <specificcountry translate="label"> <label>Payment from Specific Countries</label> <frontend_type>multiselect</frontend_type> <sort_order>51</sort_order> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <can_be_empty>1</can_be_empty> </specificcountry> <min_order_total translate="label"> <label>Minimum Order Total</label> <frontend_type>text</frontend_type> <sort_order>98</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </min_order_total> <max_order_total translate="label"> <label>Maximum Order Total</label> <frontend_type>text</frontend_type> <sort_order>99</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </max_order_total> <model> </model> </fields> </ccsave>
-
-
Enable logs. Navigate to System -> Configuration -> Developer -> Log Settings and set Enabled = Yes
- Logs for this module write to C:\xampp\htdocs\magento\var\log\MicrosoftDFP.log
-
Add New Order Statuses. Navigate to System -> Order Statuses and create the statuses below
Status Code Status Label Default Store View order_approved Order Approved Order Approved refunded Refunded Refunded chargeback Chargeback Chargeback -
Assign Order Status to State. Navigate to System -> Order Statuses and Assign Order Status to State as below,
Order Status State Order Approved New Refunded New Chargeback New Canceled New -
Add new Products. Navigate to Catalog -> Manage Products and add products as required. In addition to the required fields, ensure you update the inventory 'Qty' and 'Stock Availability' so that the product will be visible.
-
Add a new Sub-Category and assign products to it. Navigate to Catalog -> Manage Categories. Create a new Sub Category under the Default Category and assign products as needed.
-
Navigate to System -> Cache management and Flush Magento Cache again.
See Magento payment test credentials for more details.
Test Value | |
---|---|
Visa | 4111111111111111 |
MasterCard | 5555555555554444 |
American Express | 378282246310005 |
Expiration Date | Any future date |
CVV/CVC | 123 or 000 |
Read integrate real-time APIs for general information on configuring API access.
In addition to this API documentation, you can read the complimentary product documentation for Dynamics 365 Fraud Protection. It covers the broad set of Dynamics 365 Fraud Protection features such as the rules engine, reporting, and customer support. It also contains release notes and highlights planned, upcoming features.
Once properly configured, this sample site uses Microsoft device fingerprinting to send device telemetry to Microsoft for the purposes of demonstrating Dynamics 365 Fraud Protection. To disable device fingerprinting, remove code related to it rather than configuring it.
For additional information, see the Microsoft Open Source Code of Conduct.