Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problems with PayPal in DNNProblems with PayPal in DNN
Previous
 
Next
New Post
7/13/2008 2:05 PM
 

I am needing to have a button to subscribe thru PayPal.com. Below is my .vb pagebehind. Currently it only refreshes the page without going to PayPal.


        Protected Sub Subscription_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Subscription.Click
            Response.Write(PayPalPostform0().ToString)
            End Sub
        Public Function PayPalPostform0() As String
            Dim PostUrl As String = "https://www.paypal.com/cgi-bin/webscr"
            Dim Cmd As String = "_xclick-subscriptions"
            Dim no_shipping As String = "1"
            Dim BusinessEmail As String = ___________@truvista.net"
            Dim Currency As String = "USD"
            Dim ItemName As String = school
            Dim a3 As String = subPrice
            Dim ret As String = "http://www._____________/desktopmodules/pgt/Payment_success.aspx"
            Dim cancel As String = "http://www.______________"
            Dim Note As String = "1"
            Dim p3 As String = subTerm1
            Dim t3 As String = subTerm2
            Dim bn As String = "PP-SubscriptionsBF"
            Dim lc As String = "US"
            Dim src As String = "1"
            Dim sra As String = "1"
            'Create the form to write to the page with PayPal parameters
            Dim ppform As New StringBuilder
            ppform.Append("<form name=" + """" + "frmPP" + """" + " id=" + """" + "frmPP" + """" + " action=" + """" + PostUrl + """" + " method=" + """" + "post" + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "cmd" + """" + " value=" + """" + Cmd + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "business" + """" + " value=" + """" + BusinessEmail + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "item_name" + """" + " value=" + """" + ItemName + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "no_shipping" + """" + " value=" + """" + no_shipping + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "return" + """" + " value=" + """" + ret + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "cancel_return" + """" + " value=" + """" + cancel + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "no_note" + """" + " value=" + """" + Note + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "currency_code" + """" + " value=" + """" + Currency + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "lc" + """" + " value=" + """" + lc + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "bn" + """" + " value=" + """" + bn + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "a3" + """" + " value=" + """" + a3 + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "p3" + """" + " value=" + """" + p3 + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "t3" + """" + " value=" + """" + t3 + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "src" + """" + " value=" + """" + src + """" + ">")
            ppform.Append("<input type=" + """" + "hidden" + """" + " name=" + """" + "sra" + """" + " value=" + """" + sra + """" + ">")
            Return ppform.ToString
            Me.PayPalPostScript(Page)

        End Function

        Private Sub PayPalPostScript(ByVal Page As System.Web.UI.Page)
            'This registers Javascript to the page which is used to post the PayPal form details
            Dim strScript As New StringBuilder()
            strScript.Append("<script language='javascript'>")
            strScript.Append("var ctlform = document.getElementById('frmPP');")
            strScript.Append("ctlform.submit();")
            strScript.Append("</script>")
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "PPSubmit", strScript.ToString)
        End Sub

 
New Post
7/14/2008 12:51 AM
 

Because of the way asp.net works its not really possible to inject a second form into a page - asp.net gets pretty funny about this sort of stuff.

There are some discussion threads on these forumns that discuss ways to do the submit with paypal ... there are some workaround tricks
 - I have got it working using  using GET and a URL redirect which is possibly the cleanest solution.

Basically build a URL string and call paypal with a Response.Redirect( strPayPalURL, True)

 

 

Have also seen some success with a IFRAME type solution but this does tend not to scale very well - you could also look possibly at an AJAX based approach.

Westa

 
New Post
7/14/2008 2:22 AM
 

Thank you Wes. I am very familiar with the forms issue in .net. The code I posted is actually from one of my other site and works fine in .net 2.0 however it is not working in my DNN Module. I was looking at some other posts and found a way of placing it in the .ascx which works fine (below) but I need to be able to have it in the pagebehing inorder to accomplish some other coding requirements.

Does anyone know how to get this to work in .vb pagebehind

 <input name="cmd" type="hidden" value="_xclick-subscriptions" />
            <input name="business" type="hidden" value="________@________ />
            <input name="item_name" type="hidden" value="school" />
            <input name="no_shipping" type="hidden" value="1" />
            <input name="return" type="hidden" value="http://www._______________/dnn/desktopmodules/pgtl/Payment_success.aspx" />
            <input name="no_note" type="hidden" value="1" />
            <input name="currency_code" type="hidden" value="USD" />
            <input name="lc" type="hidden" value="US" />
            <input name="bn" type="hidden" value="PP-SubscriptionsBF" />
            <input name="a3" type="hidden" value="99.99" />
            <input name="p3" type="hidden" value="6" />
            <input name="t3" type="hidden" value="M" />
            <input name="src" type="hidden" value="1" />
            <input name="sra" type="hidden" value="1" />
            <input align="absMiddle" alt="Subscribe" name="go" onclick="document.getElementById('form').action='https://www.paypal.com/cgi-bin/webscr';document.getElementById('form').target='_blank'"
                src="../images/football-subscribe.gif" type="image" value="Go" />

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Problems with PayPal in DNNProblems with PayPal in DNN


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out