File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/App_Code/ERPApps/Ecommerce/ERPPayPalProvider.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.EcommerceProvider;
using CMS.GlobalHelper;
using CMS.Helpers;
/// <summary>
/// Summary description for ERPPayPalProvider
/// </summary>
public class ERPPayPalProvider : CMSPayPalProvider
{
public override void ProcessPayment()
{
if ( this.ShoppingCartInfoObj != null )
{
string paymentGatewayUrl = this.GetPaymentGatewayUrl();
if ( paymentGatewayUrl != "" )
{
Hashtable requestParams = new Hashtable();
this.ErrorMessage = this.InitializePaymentRequest(requestParams);
requestParams[(object) "custom"] = (object) this.ShoppingCartInfoObj.ShoppingCartCulture;
if ( !(this.ErrorMessage == "") )
return;
// pux modification
//this.ShoppingCartControl.CleanUpShoppingCart();
try
{
this.ShoppingCartControl.ButtonNext.Enabled = false;
var kentico6RedirectScriptFormat = "\r\n<script type=\"text/javascript\">\r\n //<![CDATA[\n\r\nfunction NewWindow(url, name, width, height) {\r\n var oWindow = null;\r\n oWindow = window.open(url, name, 'height=' + height + ',width=' + width + ',toolbar=no,directories=no,menubar=no,dependent=yes,resizable=yes');\r\n oWindow.opener = this;\r\n oWindow.focus();\r\n}\n//]]>\r\n</script>\r\n<script type=\"text/javascript\">\r\n //<![CDATA[\n\r\nif ((parent != null) && (parent != window) && (parent.IsCMSDesk)) {\r\n NewWindow('{0}', 'NewWindow', 500, 500); }\r\nelse {\r\n document.location.replace('www.google.com');\r\n}\n//]]>\r\n</script>";
ScriptHelper.RegisterClientScriptBlock(this.ShoppingCartControl.Page, typeof(string), "RedirectScript", string.Format(kentico6RedirectScriptFormat, this.GetFullPaymentGatewayUrl(URLHelper.ResolveUrl(paymentGatewayUrl), requestParams), true));
}
catch
{
this.ErrorMessage = ResHelper.GetString("PaymentGatewayProvider.ConnectionFailed");
this.ShoppingCartControl.ButtonNext.Enabled = true;
}
}
else
this.ErrorMessage = ResHelper.GetString("PaymentGatewayProvider.UrlNotDefined");
}
else
{
this.ErrorMessage = ResHelper.GetString("paymentgatewayprovider.paymentdatanotfound");
}
}
private string GetFullPaymentGatewayUrl(string url, Hashtable requestParams)
{
foreach ( DictionaryEntry dictionaryEntry in requestParams )
url = URLHelper.AddParameterToUrl(url, Convert.ToString(dictionaryEntry.Key), HttpUtility.UrlEncode(Convert.ToString(dictionaryEntry.Value)));
return url;
}
}