Developer forum

Forum » Development » Error in GatewayProvider

Error in GatewayProvider

Diogo Lino
Reply

Hello,

 

I'm trying to create a new GatewayProvider but I get an error when saving a configuration for it on the order payments eCommerce settings. I even removed all the parameters but it stays the same.

 

    [AddInName("Gateway PagSeguro v2.1")]
    [AddInDescription("Gateway PagSeguro")]
    [AddInActive(true)]
    public class PagSeguroGateway : GatewayProvider, IDropDownOptions
    {

        [AddInParameter("Script Url"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.TextParameterEditor), "")]
        public string ScriptUrlParameter { get; set; }

        [AddInParameter("Credential Email"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.TextParameterEditor), "")]
        public string CredentialEmailParameter { get; set; }

        [AddInParameter("Credential Token"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.TextParameterEditor), "")]
        public string CredentialTokenParameter { get; set; }

        [AddInParameter("Shipping Type"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.DropDownParameterEditor), "")]
        public string ShippingTypeParameter { get; set; }

        [AddInParameter("Payed Status Id"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.DropDownParameterEditor), "")]
        public string PayedStatusIdParameter { get; set; }

        [AddInParameter("Send Redir Request"), AddInParameterEditor(typeof(Dynamicweb.Extensibility.Editors.YesNoParameterEditor), "")]
        public bool SendRedirRequestParameter { get; set; }

        public Hashtable GetOptions(string optionName)
        {
            Hashtable htOptions = new Hashtable();

            switch (optionName)
            {
                case "Shipping Type":
                    htOptions.Add("1", "Encomenda normal (PAC)");
                    htOptions.Add("2", "SEDEX");
                    htOptions.Add("3", "Tipo de frete não especificado");
                    break;
                case "Payed Status Id":
                    foreach (OrderState orderState in OrderState.getAllOrderstates(1, true))
                    {
                        htOptions.Add(orderState.ID, orderState.Name);
                    }
                    break;
            }

            return htOptions;
        }
    }

You can see a screen print of the error that happens when saving in the backend.

 

Thanks,

Diogo

Capture.PNG

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Which version of Dynamicweb are running?

Try using SQL Server Profiler to see what query is submitted to save the gateway. Looks like a column is too small for the data you're providing for it.

 

Cheers,

 

Imar

 
Diogo Lino
Reply

We're running version 19.2.4.3, and with SQL Server Profiler I catch the command:
 

exec sp_executesql N'UPDATE [EcomPayments] SET [PaymentGatewayID] = @p1, [PaymentGatewayParameters] = @p2 WHERE (([PaymentID] = @p3) AND ([PaymentLanguageID] = @p4) AND ((@p5 = 1 AND [PaymentName] IS NULL) OR ([PaymentName] = @p6)) AND ((@p7 = 1 AND [PaymentIcon] IS NULL) OR ([PaymentIcon] = @p8)) AND ((@p9 = 1 AND [PaymentGatewayID] IS NULL) OR ([PaymentGatewayID] = @p10)) AND ((@p11 = 1 AND [PaymentGatewayTemplate] IS NULL) OR ([PaymentGatewayTemplate] = @p12)) AND ((@p13 = 1 AND [PaymentMerchantNum] IS NULL) OR ([PaymentMerchantNum] = @p14)) AND ((@p15 = 1 AND [PaymentTest] IS NULL) OR ([PaymentTest] = @p16)) AND ((@p17 = 1 AND [PaymentGatewayMD5Key] IS NULL) OR ([PaymentGatewayMD5Key] = @p18)) AND ((@p19 = 1 AND [PaymentCCITemplate] IS NULL) OR ([PaymentCCITemplate] = @p20)) AND ((@p21 = 1 AND [PaymentIconOrderList] IS NULL) OR ([PaymentIconOrderList] = @p22)))',
N'@p1 nvarchar(88),@p2 ntext,@p3 nvarchar(5),@p4 nvarchar(5),@p5 int,@p6 nvarchar(12),@p7 int,@p8 nvarchar(48),@p9 int,@p10 nvarchar(46),@p11 int,@p12 nvarchar(4000),@p13 int,@p14 nvarchar(4000),@p15 int,@p16 smallint,@p17 int,@p18 nvarchar(4000),@p19 int,@p20 nvarchar(4000),@p21 int,@p22 nvarchar(4000)',
@p1=N'GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway',
@p2=N'<?xml version="1.0" encoding="utf-8"?><Parameters><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Script Url" value="test" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Credential Email" value="test" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Credential Token" value="test" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Shipping Type" value="2" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Payed Status Id" value="OS112" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Send Redir Request" value="True" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Merchant" value="test" /><Parameter addin="GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway" name="Template" value="eCom/Gateway/PagSeguro.html" /></Parameters>',
@p3=N'PAY20',
@p4=N'LANG1',
@p5=0,
@p6=N'PagSeguro v2',
@p7=0,
@p8=N'/System/DeltaQ/LogosIpaper/ipaper_DeltaCafes.jpg',
@p9=0,
@p10=N'Dynamicweb.eCommerce.Orders.Gateways.QuickPay3',
@p11=1,
@p12=NULL,
@p13=1,
@p14=NULL,
@p15=1,
@p16=NULL,
@p17=1,
@p18=NULL,
@p19=1,
@p20=NULL,
@p21=0,
@p22=N''

...that returns the "Msg 8152, Level 16, State 13, Line 1. String or binary data would be truncated. The statement has been terminated." error on trying to set a new gateway.
 

 

Catching a successful save action, the Update command is:

exec sp_executesql N'UPDATE [EcomPayments] SET [PaymentGatewayID] = @p1, [PaymentGatewayParameters] = @p2 WHERE (([PaymentID] = @p3) AND ([PaymentLanguageID] = @p4) AND ((@p5 = 1 AND [PaymentName] IS NULL) OR ([PaymentName] = @p6)) AND ((@p7 = 1 AND [PaymentIcon] IS NULL) OR ([PaymentIcon] = @p8)) AND ((@p9 = 1 AND [PaymentGatewayID] IS NULL) OR ([PaymentGatewayID] = @p10)) AND ((@p11 = 1 AND [PaymentGatewayTemplate] IS NULL) OR ([PaymentGatewayTemplate] = @p12)) AND ((@p13 = 1 AND [PaymentMerchantNum] IS NULL) OR ([PaymentMerchantNum] = @p14)) AND ((@p15 = 1 AND [PaymentTest] IS NULL) OR ([PaymentTest] = @p16)) AND ((@p17 = 1 AND [PaymentGatewayMD5Key] IS NULL) OR ([PaymentGatewayMD5Key] = @p18)) AND ((@p19 = 1 AND [PaymentCCITemplate] IS NULL) OR ([PaymentCCITemplate] = @p20)) AND ((@p21 = 1 AND [PaymentIconOrderList] IS NULL) OR ([PaymentIconOrderList] = @p22)))',
N'@p1 nvarchar(18),@p2 ntext,@p3 nvarchar(5),@p4 nvarchar(5),@p5 int,@p6 nvarchar(23),@p7 int,@p8 nvarchar(37),@p9 int,@p10 nvarchar(42),@p11 int,@p12 nvarchar(4000),@p13 int,@p14 nvarchar(4000),@p15 int,@p16 smallint,@p17 int,@p18 nvarchar(4000),@p19 int,@p20 nvarchar(4000),@p21 int,@p22 nvarchar(4000)',
@p1=N'Amex.Gateways.Amex',
@p2=N'<?xml version="1.0" encoding="utf-8"?><Parameters><Parameter addin="Amex.Gateways.Amex" name="Virtual TPA Number" value="test" /><Parameter addin="Amex.Gateways.Amex" name="Supervisor Number" value="test" /><Parameter addin="Amex.Gateways.Amex" name="Certificate Number" value="test" /><Parameter addin="Amex.Gateways.Amex" name="Payed Status ID" value="test" /><Parameter addin="Amex.Gateways.Amex" name="" value="Preencher com o StatusID &lt;b&gt;&lt;u&gt;&lt;a href=''http://gatewaypagseguro.local.dynamicweb.pt/Amex/AmexPaymentPage.aspx?show=1'' target=''_blank''&gt; (clique aqui)&lt;/a&gt;&lt;/b&gt;&lt;/u&gt;, com que pretende que fique a encomenda, no caso de pagamento com sucesso.&lt;br&gt;Vazio, se não pretende utilizar esta funcionalidade." /><Parameter addin="Amex.Gateways.Amex" name="Demo Mode" value="True" /><Parameter addin="Amex.Gateways.Amex" name="Template" value="eCom/Gateway/PayPal.html" /></Parameters>',
@p3=N'PAY16',
@p4=N'LANG1',
@p5=0,
@p6=N'Redunicre (Delta Q) 3.1',

@p7=0,
@p8=N'/Billeder/DeltaQ_v2/Blends/Blend4.png',
@p9=0,
@p10=N'Dynamicweb.eCommerce.Orders.Gateways.Ogone',
@p11=1,
@p12=NULL,
@p13=1,
@p14=NULL,
@p15=1,
@p16=NULL,
@p17=1,
@p18=NULL,
@p19=1,
@p20=NULL,
@p21=0,
@p22=N''

...that is almost identical to the one with the error.

 

Is there any example of a C# development of a GatewayProvider? Based on the available VB examples it is not working.

 

Thanks,

Diogo

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Hi Diogo,

 

I think the problem is with your PaymentGatewayID. In the database, this field is only 50 characters. However, because of your long namespace, the value you're submitting is over 90 characters:

 

'GatewayPagSeguro.CustomDevelopment.GatewayPagSeguro.Model.Extensibility.PagSeguroGateway'

 

Try shortening your namespace as that should fix the problem.

 

Cheers,

 

Imar

Votes for this answer: 1
 
Diogo Lino
Reply

That's it. The PaymentGatewayID only supports 50 characters, and the namespace+class was too long.

 

Thanks,

Diogo

 

You must be logged in to post in the forum