<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Magento 2 &amp;amp; Cybersource payment invalid field for duplicated product categories in cybersource APIs</title>
    <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Magento-2-amp-Cybersource-payment-invalid-field-for-duplicated/m-p/85325#M713</link>
    <description>&lt;P&gt;I'm using cybersource Payment gateway for my Magento 2 install, the gateway require some Merchant Data fields to be populated with the oeder, one of the fields is the product category, currently i'm using the below method:&lt;/P&gt;&lt;PRE&gt;   $name = $categories = [];
            foreach ($order-&amp;gt;getAllVisibleItems() as $_item) {                    
                array_push($name, $_item-&amp;gt;getName());
                $product = $this-&amp;gt;productModel-&amp;gt;load($_item-&amp;gt;getProductId());
                $cats = $product-&amp;gt;getCategoryIds();
                foreach($cats as $cat){
                    $category = $this-&amp;gt;categoryModel-&amp;gt;load($cat);
                    array_push($categories, $category-&amp;gt;getName());
                }
                                   
            }&lt;/PRE&gt;&lt;P&gt;Then i'm calling the category using&lt;/P&gt;&lt;PRE&gt;                'product_category' =&amp;gt; implode(',', $categories),

&lt;/PRE&gt;&lt;P&gt;but the issue is, when i'm creating an order with more than one product from the same category lets say 3 products from the same category, it show in the response the categories 3 times, and in this way i receive an error in cybersource that the product category fields has an invalid value.&lt;/P&gt;&lt;P&gt;how to show only the product category only one time?&lt;/P&gt;</description>
    <pubDate>Mon, 26 Dec 2022 13:18:15 GMT</pubDate>
    <dc:creator>olansgz</dc:creator>
    <dc:date>2022-12-26T13:18:15Z</dc:date>
    <item>
      <title>Magento 2 &amp; Cybersource payment invalid field for duplicated product categories</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Magento-2-amp-Cybersource-payment-invalid-field-for-duplicated/m-p/85325#M713</link>
      <description>&lt;P&gt;I'm using cybersource Payment gateway for my Magento 2 install, the gateway require some Merchant Data fields to be populated with the oeder, one of the fields is the product category, currently i'm using the below method:&lt;/P&gt;&lt;PRE&gt;   $name = $categories = [];
            foreach ($order-&amp;gt;getAllVisibleItems() as $_item) {                    
                array_push($name, $_item-&amp;gt;getName());
                $product = $this-&amp;gt;productModel-&amp;gt;load($_item-&amp;gt;getProductId());
                $cats = $product-&amp;gt;getCategoryIds();
                foreach($cats as $cat){
                    $category = $this-&amp;gt;categoryModel-&amp;gt;load($cat);
                    array_push($categories, $category-&amp;gt;getName());
                }
                                   
            }&lt;/PRE&gt;&lt;P&gt;Then i'm calling the category using&lt;/P&gt;&lt;PRE&gt;                'product_category' =&amp;gt; implode(',', $categories),

&lt;/PRE&gt;&lt;P&gt;but the issue is, when i'm creating an order with more than one product from the same category lets say 3 products from the same category, it show in the response the categories 3 times, and in this way i receive an error in cybersource that the product category fields has an invalid value.&lt;/P&gt;&lt;P&gt;how to show only the product category only one time?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2022 13:18:15 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Magento-2-amp-Cybersource-payment-invalid-field-for-duplicated/m-p/85325#M713</guid>
      <dc:creator>olansgz</dc:creator>
      <dc:date>2022-12-26T13:18:15Z</dc:date>
    </item>
  </channel>
</rss>

