locked
Integrating a Paypal Button RRS feed

  • Question

  • User1784825535 posted

    Does anyone have any thoughts on how to interrupt the process of the below code so I can

    insert a simple Paypal button with IPN without the process automatically finishing? Ideally

    I'd like to replace the "Finish" button with the Paypal button.........

    Thanks in Advance

    Old Dave

    <legend>For how long should this Ad be listed?</legend>
                                    <asp:DropDownList ID="NumDaysList" Runat="server">
                                        <asp:ListItem Value="2">2 days</asp:ListItem>
                                        <asp:ListItem Value="7" Selected="True">7 days</asp:ListItem>
                                        <asp:ListItem Value="14">14 days</asp:ListItem>
                                        <asp:ListItem Value="21">21 days</asp:ListItem>
                                        <asp:ListItem Value="28">28 days</asp:ListItem>
                                    </asp:DropDownList>
                                </fieldset>
                            </div>
                                                </asp:WizardStep>
                        <asp:WizardStep ID="WizardStep2" Runat="server" StepType="Complete" Title="Done">
                            <h2 class="section">
                                Done!</h2>
                            <div class="content_right">
                                <p>
                                    Your Ad was successfully submitted. </p>
                                <p style="text-align: center">
                                    <asp:HyperLink Runat="server" ID="UploadImagesLink" Font-Bold="True" NavigateUrl="ManagePhotos.aspx?id=">Upload Photos for your Ad now</asp:HyperLink>
                                    <br />
                                        <asp:HyperLink Runat="server" ID="MyAdsLink" Font-Bold="True" NavigateUrl="~/MyAds.aspx">Go to My Ads page</asp:HyperLink>
                                </p>
                            </div>
                        </asp:WizardStep>
                    </WizardSteps>
                    <StepStyle CssClass="wizard-step" />
                    <NavigationStyle HorizontalAlign="Left" />
                </asp:Wizard>
            </div>
        </div>
    <script type="text/javascript">
        function textCounter(elem, maxLimit)
         {
            if (elem.value.length > maxLimit)
             {
                elem.value = elem.value.substring(0, maxLimit);
            }
        } 
    
    </script>          
    </asp:Content>


     

     

     

     

     

     

    Thursday, April 8, 2010 10:59 AM

Answers

  • User-122480877 posted

    Is there a special ASP command to automatically Enable Activating the Ad or is it done another way?...I am trying to visualize how I'd do it and I can't quite see it...

    The Answer to That is yes and no. (Sorry I did not click that you are a newbie)

    The functionality to Enable an ad is very easy and yes the code exists how ever setting up Pay Pal send and receive commands can be a pain!

    To activate the ad on successful payment all you need to do is trigger this function

    AdsDB.UpdateAdStatus(adId, AdStatus.Activated);
    


    If I get time i will try get a working sample made.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 10, 2010 7:26 PM
  • User-1136540166 posted

    (I am newbie also)

    You have

    Dim adId As Integer =

    there, so at first glance why the "adID not declared" was curious...    the  Dim adId as integer=   is inside a If/then/else. 
    Look at the flow through that subroutine.  Looks to me like it might be that to get to your statement:

    AdsDB.UpdateAdStatus(adId, AdStatus.Activated)

    Is outside of the if/then/else so it is not declared.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 31, 2010 11:08 AM

All replies

  • User-706703781 posted

    So basically you want to have the user pay using paypal after they have input the ad info and before the ad is actually posted? 

    Sunday, May 2, 2010 1:37 PM
  • User1784825535 posted

    Yes! Exactly!  How do I do it? 

    Sunday, May 2, 2010 3:58 PM
  • User-122480877 posted

    There are many ways you could do this and depending on what you want to achieve in the long there are many answers I could reply with.

    My advice would be to implement an account system on your site where people can credit you money (via PayPal) and can then list items on your site until there money has run out. At this point I would advise having a lock out with a message of low credit before this happens.

    The reason to why I say it like this is what if I wanted to list 100 items? Would I have to go to PayPal 100 times?

    100 items a week x 52 weeks in a year is 5,200 visits to PayPal.

    Not very user friendly at all.

    I am looking at implementing an Account System (with PayPal option for credit) for Trading Center but until I can find a way to create it as a plug-in I could not tell you when it will be done.

    There is project on codeplex you could check out http://paypal.codeplex.com/

    Sunday, May 9, 2010 6:30 AM
  • User1784825535 posted

    Thanks very much for the thoughts!  My business would usually be a once per year service entailing one visit to PayPal per customer per year.  I'm more concerned with security so I want everything financial to happen behind PayPal's much more powerful security software.  I'm currently trying to figure out how to store my data before sending the customer to PayPal - PayPal's pass-through option isn't the answer for me as there's too much info on my end.  I can get them to PayPal no problem but lose their form-inputed information when they do.....

     

    You're Idea would be much better for clients with many items listed or who reoccur more frequently.

    Sunday, May 9, 2010 8:35 AM
  • User-122480877 posted

    I would capture the data from the page just as it is now but have it set in administration settings "Ads Require Approval". The option is all ready there if you have not seen the settings page.

    Insert your Payment option on the completed step of the wizard.

    The user completes payment and PayPal sends back data verifying the payment was successfull or not.

    If it is then all you need now is to Enable the Ad in your code :-)

    Sunday, May 9, 2010 10:29 AM
  • User1784825535 posted

    So, if I'm understanding this correctly (I went and clicked "Ads Require Activation" in the admin settings) then I can Enable the Ad automatically in the code after receiving verification from PayPal?

     

    Is there a special ASP command to automatically Enable Activating the Ad or is it done another way?...I am trying to visualize how I'd do it and I can't quite see it...

     

     This would indeed be the solution since I'm expecting (hoping for, really)  a large number of ads and doubt it would be possible to manually OK them all....

     

     

    Thanks for your help so far already!

    Monday, May 10, 2010 5:43 PM
  • User-122480877 posted

    Is there a special ASP command to automatically Enable Activating the Ad or is it done another way?...I am trying to visualize how I'd do it and I can't quite see it...

    The Answer to That is yes and no. (Sorry I did not click that you are a newbie)

    The functionality to Enable an ad is very easy and yes the code exists how ever setting up Pay Pal send and receive commands can be a pain!

    To activate the ad on successful payment all you need to do is trigger this function

    AdsDB.UpdateAdStatus(adId, AdStatus.Activated);
    


    If I get time i will try get a working sample made.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 10, 2010 7:26 PM
  • User1784825535 posted

    Thanks Spider Master!  I'm recycled... :-) My son is trying to get his website working and he used a package.  I used to program in Basic, C and Pascal back in the day but ASP is new to me.  Lots of very useful specialized functions....sort of like Matlab (I once wrote 300 lines of code in C for what Matlab did in a single command....... ).  Learning ASP is fun but there is a lot to know.

    I'm just using a PayPal button and it seems to work to get there but we'd lose all the form's info when we left the site so this suspension until activation seems an ideal solution.  I think the PayPal payment verification process seems a tad tricky (but necessary) I'll admit.

    Thanks for the info on the AdStatus.Activated command!!!!!!!!!!!

     

     

    Monday, May 10, 2010 9:50 PM
  • User-122480877 posted

    Basic C and Pascal?? Actually no I do not even want to know lol

    Dont get to confused ASP (classic ASP) is no longer supported.

    ASP.NET is what your learning [:D] soon you will click to domain of this site lol asp.net instead of asp.com.

    Any way I have never actually integrated a PayPal option apart from a straight forward donation button for a friend a while ago so I am progressing with the "Buy Now" button with a return method for activating listings on my site too and will be sure to let you know how that goes in the next few days.

    I do have a question so I know what code to give you, Are you using C# (.cs) or VB (.vb) for your code behind (server scripts)?

    Tuesday, May 11, 2010 10:00 AM
  • User1784825535 posted

    I've noticed when playing with some very simple constructs that ASP.NET is king...seems like a nice package though: very powerful IF you get it right Cool

     

    Using VB(.vb) for the code - I'm glad because for my son it is easier to read if you're not used to C....

    Looking forward to seeing how your project works out!  If I make any headway myself I'll post it here.

    Tuesday, May 11, 2010 2:13 PM
  • User1784825535 posted

    OK, just a quick question on this.  Been a busy week so I've only been able to apply snatches of time to this, but I assume you put the above line of code at the end of :

    Protected Sub PostAdWizard_FinishButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)

    in PostAd.aspx.vb just before the final End Sub.

    (The thinking being that if PayPal approves the payment you'll return to click the Finish Button and then you'll be automatically activated.)

    I can't get it to work.  Am I in the wrong playing field altogether? (I first looked under the Admin files but this seemed more logical).  The code after I slip in the line looks like:

     

    Else
                    Dim adId As Integer = AdsDB.InsertAd(memberId, categoryId, title, description, url, price, location, numDays, AdLevel.Unspecified, AdStatus.Unspecified, adType)

                    Dim s As SiteSettings = SiteSettings.GetSharedSettings()
                    UploadImagesLink.Visible = s.AllowImageUploads
                    UploadImagesLink.NavigateUrl = "~/ManagePhotos.aspx?id=" + adId.ToString()
                End If

            Else
                e.Cancel = True
            End If
            AdsDB.UpdateAdStatus(adId, AdStatus.Activated) 
        End Sub

     

     The debugger error message is: "adID" is not declared.  It may be inaccessabe due to its protection level.

    Saturday, May 22, 2010 1:04 PM
  • User-1136540166 posted

    (I am newbie also)

    You have

    Dim adId As Integer =

    there, so at first glance why the "adID not declared" was curious...    the  Dim adId as integer=   is inside a If/then/else. 
    Look at the flow through that subroutine.  Looks to me like it might be that to get to your statement:

    AdsDB.UpdateAdStatus(adId, AdStatus.Activated)

    Is outside of the if/then/else so it is not declared.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 31, 2010 11:08 AM
  • User1784825535 posted

    Yessss!!!!!!!

     

    Simply by putting the line

     AdsDB.UpdateAdStatus(adId, AdStatus.Activated)

    back up inside the if/then/else like so:

     

    If IsPreviousAd Then
                    AdsDB.RelistAd(PreviousAdId, categoryId, title, description, url, price, location, numDays, AdLevel.Unspecified, AdStatus.Unspecified, adType)

                    Response.Redirect("~/MyAds.aspx", True)

                Else
                    Dim adId As Integer = AdsDB.InsertAd(memberId, categoryId, title, description, url, price, location, numDays, AdLevel.Unspecified, AdStatus.Unspecified, adType)

                    Dim s As SiteSettings = SiteSettings.GetSharedSettings()
                    UploadImagesLink.Visible = s.AllowImageUploads
                    UploadImagesLink.NavigateUrl = "~/ManagePhotos.aspx?id=" + adId.ToString()
                    AdsDB.UpdateAdStatus(adId, AdStatus.Activated)

                End If

            Else
                e.Cancel = True
            End If
        End Sub

     

    It all works!  Thanks so much for noticing that, racer184! 

    David

    Monday, May 31, 2010 6:30 PM