Page 1 of 1
AccountDataDictionary
Posted: Mon Aug 24, 2009 5:35 pm
by anglicool
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?
Re: AccountDataDictionary
Posted: Tue Aug 25, 2009 2:54 am
by mazhar
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
}
Re: AccountDataDictionary
Posted: Tue Aug 25, 2009 9:06 am
by anglicool
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>
Re: AccountDataDictionary
Posted: Wed Aug 26, 2009 1:10 am
by mazhar
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>
Re: AccountDataDictionary
Posted: Wed Aug 26, 2009 6:33 pm
by mazhar
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>
Re: AccountDataDictionary
Posted: Thu Aug 27, 2009 10:11 am
by anglicool
Getting an error:
GetAccountData(string)' has some invalid arguments
Re: AccountDataDictionary
Posted: Thu Aug 27, 2009 6:19 pm
by mazhar
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>