Posted on 15/07/2022 08:41:03
Hi Tomas,
the problem is that this request is not implemented in the Live integration by default so you will need to implement its handling by yourself using the Integration customer center
Live integration notification subscriber.
For triggering the pdf request from the Live integration it is needed to call the page with the url like that:
http://yourSiteName/Admin/public/CustomerCenter/RequestExternalPdf.aspx?customerID=123&startdate=&enddate=&shopid=SHOP1&generateCustomerStatement=true
Then in the custom implemented "Live integration" project you need to subscribe to:
DynamicwebLiveIntegration.Notifications.IntegrationCustomerCenter.OnAfterGenerateRetrievePdfXml
and override the Document xml with yours one when there is a "generateCustomerStatement=true" parameter in the Request,
so you do not broke the standard Integration customer center pdf functionality.
Then in your subscriber you need to override/update the Document xml so it suits the needed request xml for the GetCustomerStatementPDF request,
read the values from the Request query string: customerID, dates and produce the xml like this:
<GetCustomerStatementPDF customerID="20000" startDate="2009-12-30" endDate="2020-12-30"></GetCustomerStatementPDF>
Then you should be able to get the pdf file after visiting this url.
Also you can include the query string parameter: "&forceDownload=true" to directly download the file from the browser (instead of displaying it)
Here is a sample code:
using Dynamicweb.Extensibility.Notifications;
namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.Notifications.IntegrationCustomerCenter
{
/// <summary>
/// Class RetrievePdfAfterGenerateXmlSubscriber.
/// </summary>
/// <seealso cref="NotificationSubscriber" />
[Subscribe(DynamicwebLiveIntegration.Notifications.IntegrationCustomerCenter.OnAfterGenerateRetrievePdfXml)]
public class RetrievePdfAfterGenerateXmlSubscriber : NotificationSubscriber
{
/// <summary>
/// Call to invoke observer.
/// </summary>
/// <param name="notification">The notification.</param>
/// <param name="args">The args.</param>
public override void OnNotify(string notification, NotificationArgs args)
{
var myArgs = (DynamicwebLiveIntegration.Notifications.IntegrationCustomerCenter.OnAfterGenerateRetrievePdfXmlArgs)args;
// TODO: Add code here
if (myArgs?.Document != null && Core.Converter.ToBoolean(Dynamicweb.Context.Current?.Request["generateCustomerStatement"]))
{
var newDoc = new System.Xml.XmlDocument();
//Update the xml with your values from the Dynamicweb.Context.Current.Request:
newDoc.LoadXml("<GetCustomerStatementPDF customerID=\"20000\" startDate=\"2009-12-30\" endDate=\"2020-12-30\"></GetCustomerStatementPDF>");
myArgs.Document.InnerXml = newDoc.InnerXml;
}
}
}
}
BR, Dmitrij