AccountDataDictionary

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
anglicool
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Thu Aug 06, 2009 3:28 pm

AccountDataDictionary

Post by anglicool » Mon Aug 24, 2009 5:35 pm

so i have:
protected PaymentCollection getPaymentInfo(int orderId)
{
Order order = OrderDataSource.Load(orderId);
return order.Payments;
}
which shows me the credit card holders info for each order.
I need it to go one more step, how do I apply AccountDataDictionry to the above code?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AccountDataDictionary

Post by mazhar » Tue Aug 25, 2009 2:54 am

It would be something like

Code: Select all

Order order = OrderDataSource.Load(orderId);
        PaymentCollection payments = order.Payments;
        foreach (Payment payment in payments)
        {
            AccountDataDictionary add = new AccountDataDictionary(payment.AccountData);
            //use account data dictionary here
        }

anglicool
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Thu Aug 06, 2009 3:28 pm

Re: AccountDataDictionary

Post by anglicool » Tue Aug 25, 2009 9:06 am

what am I missing?
I know I am still very new to C# and ASP.NET

protected PaymentCollection payInfo(int orderId)
{
Order order = OrderDataSource.Load(orderId);
PaymentCollection payments = order.Payments;
foreach (Payment payment in payments)
{
AccountDataDictionary accDict = new AccountDataDictionary(payment.AccountData);
}
return payments;
}

_______________________________________________________________________

<asp:formview runat="server" HorizontalAlign="left" id="Formview1"
DataSource='<%#payInfo(Convert.ToInt32(Eval("OrderId")))%>' >
<ItemTemplate>
<asp:Label ID="PaymentMethodLabel" runat="server" Text="Payment Info 002:" SkinID="FieldHeader"></asp:Label><br />
<asp:Label ID="lbl_PaymentType" runat="server" Text='<%#Eval("EncryptedAccountData")%>'></asp:Label>
</ItemTemplate>
</asp:formview>

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AccountDataDictionary

Post by mazhar » Wed Aug 26, 2009 1:10 am

try following

Code: Select all

<%@ Control Language="C#" ClassName="Sample" %>

<script runat="server">

    protected PaymentCollection payInfo(int orderId)
    {
        Order order = OrderDataSource.Load(orderId);
        return order.payments;
    }
</script>


_______________________________________________________________________

<asp:formview runat="server" HorizontalAlign="left" id="Formview1"
DataSource='<%#payInfo(Convert.ToInt32(Eval("OrderId")))%>' >
<ItemTemplate>
<asp:Label ID="PaymentMethodLabel" runat="server" Text="Payment Info 002:" SkinID="FieldHeader"></asp:Label><br />
<asp:Label ID="lbl_PaymentType" runat="server" Text='<%#Eval("EncryptedAccountData")%>'></asp:Label>
</ItemTemplate>
</asp:formview>

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AccountDataDictionary

Post by mazhar » Wed Aug 26, 2009 6:33 pm

In order to format it nicely you need to output it by formatting through some dynamic HTML code for example see the GetAccountData function below where a line break is appended

Code: Select all

<script runat="server">

    protected PaymentCollection payInfo(int orderId)
    {
        Order order = OrderDataSource.Load(orderId);
        return order.payments;
    }

    public string GetAccountData(string data) 
    {
        AccountDataDictionary accountData = new AccountDataDictionary(data);
        StringBuilder sb = new StringBuilder();
        foreach (string key in accountData.Keys)
        {
            sb.Append(key + ":" + accountData[key]);
            sb.Append("<br />"); // New Line
        }
        return sb.ToString();
    }
    
</script>


_______________________________________________________________________

<asp:formview runat="server" HorizontalAlign="left" id="Formview1"
DataSource='<%#payInfo(Convert.ToInt32(Eval("OrderId")))%>' >
<ItemTemplate>
<asp:Label ID="PaymentMethodLabel" runat="server" Text="Payment Info 002:" SkinID="FieldHeader"></asp:Label><br />
<asp:Label ID="lbl_PaymentType" runat="server" Text='<%#GetAccountData(Eval("EncryptedAccountData"))%>'></asp:Label>
</ItemTemplate>
</asp:formview>

anglicool
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Thu Aug 06, 2009 3:28 pm

Re: AccountDataDictionary

Post by anglicool » Thu Aug 27, 2009 10:11 am

Getting an error:

GetAccountData(string)' has some invalid arguments

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AccountDataDictionary

Post by mazhar » Thu Aug 27, 2009 6:19 pm

Sorry was a small mistake in code, fixed code is here

Code: Select all

<script runat="server">

    protected PaymentCollection payInfo(int orderId)
    {
        Order order = OrderDataSource.Load(orderId);
        return order.payments;
    }

    public string GetAccountData(Object data)
    {
        AccountDataDictionary accountData = new AccountDataDictionary((string)data);[list=][/list]
        StringBuilder sb = new StringBuilder();
        foreach (string key in accountData.Keys)
        {
            sb.Append(key + ":" + accountData[key]);
            sb.Append("<br />"); // New Line
        }
        return sb.ToString();
    }
   
</script>




<asp:formview runat="server" HorizontalAlign="left" id="Formview1"
DataSource='<%#payInfo(Convert.ToInt32(Eval("OrderId")))%>' >
<ItemTemplate>
<asp:Label ID="PaymentMethodLabel" runat="server" Text="Payment Info 002:" SkinID="FieldHeader"></asp:Label><br />
<asp:Label ID="lbl_PaymentType" runat="server" Text='<%#GetAccountData(Eval("EncryptedAccountData"))%>'></asp:Label>
</ItemTemplate>
</asp:formview>

Post Reply