Blog posts by Viet Anh2019-01-08T08:01:37.0000000Z/blogs/viet-anh/Optimizely WorldDIBS payment provider supports SHA-256/blogs/viet-anh/dates/2019/1/dibs-payment-provider-supports-sha-256/2019-01-08T08:01:37.0000000Z<p>In CommercePaymentGateways source code <a href="https://github.com/episerver/CommercePaymentGateways/releases/tag/v12.15.1">version 12.15.1</a> , we made changes in DIBS payment gateway. </p>
<p>In previous versions, DIBS payment uses <a href="https://tech.dibspayment.com/D2/API/MD5">MD5 keys</a> to secure the communication between the Commerce website and the DIBS server. However, it's less secure. </p>
<p>DIBS also support sha-256 encryption, using <a href="https://tech.dibspayment.com/batch/d2integratedpwapi">HMAC key</a>. From version 12.15.1, our DIBS payment gateway uses HMAC key for encryption. The entire payment request is encrypted and verified at DIBS server. In case the payment data (for example the total amount, or currency) doesn't match the encrypted value, then the transaction is rejected. </p>
<p>The new API supports almost payment functions, comparing to the old API. Except the methods for split auth and split capture. And the merchant account need to contact DIBS support to enable the HMAC key. But overall, it's good and ensure the safety of transactions.</p>
<p>In case you still want the old API (with MD5 keys), then simply get the old package of CommercePaymentGateways. Then follow the <a href="/link/69f5b4c0f96049c79d3a15fd9f3beb95.aspx">DIBS installation guide</a> here. We updated the steps for both old and new versions.</p>
<p>Hope this helps.</p>Customizing catalog export contents to Episerver Campaign/blogs/viet-anh/dates/2018/6/Customizing-catalog-export-contents-to-EPiServer-Campaign/2018-10-01T13:06:04.0000000Z<p>My first blog post on EPiServer World :)</p>
<p>At the end of Sept 2018, we introduced new package named EPiServer.Campaign.Commerce, that supports exporting catalog content to EPiServer Campaign.</p>
<p>The developer guide document for this new feature can be found <a href="/link/ad6ccf64abd84d389ea64c5a3c81b40f.aspx">here</a>. This blog focuses on how to customize the data to be exported.</p>
<ul>
<li>IProductLoader
<ul>
<li>GetEntries: Gets the entries need to export to campaign. By default, this collects all variants and packages under selected catalog and market language.<br />Note: Since the catalog data is exported to Campaign system for marketing purpose. Then the core service only use items with price. The ones without price won't be processed.<br /><br />For example, you want to export variant under catalog, but not packages. Then your customization can be something like this:<br /><br />
<pre class="language-csharp"><code> [ServiceConfiguration(ServiceType = typeof(IProductLoader), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomProductLoader : IProductLoader
{
private readonly IContentLoader _contentLoader;
private readonly ReferenceConverter _referenceConverter;
public CustomProductLoader(IContentLoader contentLoader, ReferenceConverter referenceConverter)
{
_contentLoader = contentLoader;
_referenceConverter = referenceConverter;
}
public IEnumerable<EntryContentBase> GetEntries(IEnumerable<string> catalogNames, IMarket market)
{
var catalogs = catalogNames.Any()
? _contentLoader.GetChildren<CatalogContent>(_referenceConverter.GetRootLink()).Where(x => catalogNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))
: _contentLoader.GetChildren<CatalogContent>(_referenceConverter.GetRootLink());
foreach (var catalog in catalogs)
{
foreach (var variant in _contentLoader.GetChildren<VariationContent>(catalog.ContentLink, market.DefaultLanguage))
{
yield return variant;
}
}
}
}</code></pre>
<br /><br /></li>
</ul>
</li>
<li>IProductFieldsHandler
<ul>
<li>PopulateCategoryFields: Gets the category hierarchy of a product. The category levels are separated by "#". Note that Campaign system can process up to 10 levels of category.</li>
<li>PopulateTextFields: Populates the fields Text1-Text10<br />For example:<br /><br />
<pre class="language-csharp"><code> public void PopulateTextFields(ProductModel model, EntryContentBase entry, IPriceValue price, IEnumerable<DiscountPrice> discountedPrices)
{
var fashion = entry as FashionVariant;
model.Text1 = fashion.Size;
model.Text2 = fashion.Color;
model.Text3 = fashion.MinQuantity.ToString();
model.Text4 = fashion.MaxQuantity.ToString();
model.Text5 = fashion.Weight.ToString();
model.Text6 = discountedPrices?.FirstOrDefault()?.Price.ToString() ?? string.Empty;
model.Text7 = price.UnitPrice.ToString();
}</code></pre>
<br /><br /></li>
<li>PopulateImageFields: Populates the fields Image1-Image6<br /><span>For example:</span><br /><br />
<pre class="language-html"><code> public void PopulateImageFields(ProductModel model, EntryContentBase entry)
{
model.Image1 = new ProductImageModel
{
ImageUrl = "http://LinkToImage1.com",
ImageLink = "http://Image1HrefLink.com"
};
model.Image2 = new ProductImageModel
{
ImageUrl = "http://LinkToImage2.com",
ImageLink = "http://Image2HrefLink.com"
};
model.Image3 = new ProductImageModel
{
ImageUrl = "http://LinkToImage3.com",
ImageLink = "http://Image3HrefLink.com"
};
}</code></pre>
<br /><br /><br /></li>
<li>PopulateLinkFields: Populates the fields Link1-Link3<br /><span>For example:</span><br /><br />
<pre class="language-csharp"><code> public void PopulateLinkFields(ProductModel model, EntryContentBase entry)
{
model.Link1 = new ProductLinkModel()
{
Text = "Link 1",
Url = "http://LinkToProduct1.com"
};
model.Link2 = new ProductLinkModel()
{
Text = "Link 2",
Url = "http://LinkToProduct2.com"
};
model.Link3 = new ProductLinkModel()
{
Text = "Link 3",
Url = "http://LinkToProduct3.com"
};
}</code></pre>
<br /><br /></li>
<li>PopulateAdditionalDataFields: Populates the fields AdditionalData1-AdditionalData20</li>
</ul>
</li>
</ul>
<p>In default implementation, EPiServer set default value for texts, images, links, additional data and category in corresponding methods. Then if you only override some of those methods, be sure to override correct data in correct method. For example, overriding for <span>PopulateTextFields should only set model.Text[x]. Otherwise, your custom value may be reset somewhere else by the default implementations.</span></p>
<p>Hope this helps.</p>