I guess there was interest after all. Sorry for the slow response.
We got the original code from CyberSource via the Hosted Order Page Security page with the keys and other info already embedded in the code. This code is necessary for CyberSource to validate your transaction.
Configure the CyberSource Hosted Order Page Settings Receipt Page and Decline Page settings to point to the URL of your receipt.aspx page.
The checkout.aspx page is hosted in an iFrame within DNN. Configure DNN to pass the current UserID and PortalID values as query string parameters to checkout page.
In the code behind for the checkout page, method named insertSignature3, create a custom field (See the Hosted Order Page User Guide, Chapter3, Custom Fields) containing the PortalID and the UserID separated by a delimiter. I used a comma. This value will be passed to CyberSource and returned in the response page. The values are integers passed as plain text in a hidden field. Pick a very generic name for the field and the values should be safe.
When the order transaction is completed, the custom field is returned in the HttpRequest object and is used by the verifyTransactionSignature method in the code behind.
Be sure to validate the Reason Code returned from CyberSource to determine if the transaction is valid.
Use PortalID value and the name of the role you want to assign to call the RoleController.GetRoleByName method
Use the RoleID returned from the GetRoleByName method along with the PortalID and UserID to call the RollController.AddUserRole method.
Here is the code to do all this:
Private m_Role As RoleInfo
Private m_PortalID As Integer
Private m_UserID As Integer
insertSignature3 Method:
sb.Append("'><input type='hidden' name='mycustomfield' value='")
sb.Append(String.format("{0},{1}", Request.QueryString("PortalID"), Request.QueryString("UserID")))
verifyTransactionSignature Method:
'Retrieve the Portal ID and User ID from the Custom field passed to CyberSource from the Checkout process. format is <PortalID>,<UserID>
Dim parm() As String = Split(map.form.Get("mycustomfield"), ",")
m_PortalID = CInt(parm(0))
m_UserID = CInt(parm(1))
'Add the subscriber role to the user making the payment.
Dim objRoles As New RoleController
'Get the Role object for the DNN Role named XXX
m_Role = objRoles.GetRoleByName(m_PortalID, "XXX")
'Add the User to the XXX role, Effective date is today, Expiry date is 365 days from today.
objRoles.AddUserRole(m_Role.PortalID, m_UserID, m_Role.RoleID, Date.Now, DateAdd(DateInterval.Day, 365, Date.Now))
I hope this helps