Click here to Skip to main content
15,881,600 members
Articles / Web Development / ASP.NET

Use of the PayPal payment system in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.86/5 (164 votes)
2 Jun 2008CPOL22 min read 841K   19.3K   578  
This article covers aspects of using the PayPal payment system in ASP.NET
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'  File:           PayPal.aspx.vb
'
'  Facility:       The unit contains the PayPal class
'
'  Abstract:       This class is intended for interacting with PayPal with the
'                  help of the form of the payment request this class creates.
'
'  Environment:    VC 8.0
'
'  Author:         KB_Soft Group Ltd.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Imports System.Configuration.ConfigurationManager

Partial Class PayPal
    Inherits System.Web.UI.Page
    Protected cmd As String = "_xclick"
    Protected business As String = AppSettings("BusinessEmail")
    Protected item_name As String = "Payment for goods"
    Protected amount As String
    Protected return_url As String = AppSettings("ReturnUrl")
    Protected notify_url As String = AppSettings("NotifyUrl")
    Protected cancel_url As String = AppSettings("CancelPurchaseUrl")
    Protected currency_code As String = AppSettings("CurrencyCode")
    Protected no_shipping As String = "1"
    Protected URL As String
    Protected request_id As String
    Protected rm As String

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load

        ' determining the URL to work with depending on whether sandbox or a real PayPal account should be used
        If AppSettings("UseSandbox").ToString = "true" Then
            URL = "https://www.sandbox.paypal.com/cgi-bin/webscr"
        Else
            URL = "https://www.paypal.com/cgi-bin/webscr"
        End If

        'This parameter determines the was information about successfull transaction will be passed to the script
        ' specified in the return_url parameter.
        ' "1" - no parameters will be passed.
        ' "2" - the POST method will be used.
        ' "0" - the GET method will be used. 
        ' The parameter is "0" by deault.
        If AppSettings("SendToReturnURL").ToString = "true" Then
            rm = "2"
        Else
            rm = "1"
        End If

        ' the total cost of the cart
        amount = Session("Amount")
        ' the identifier of the payment request
        request_id = Session("request_id")

    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Russian Federation Russian Federation
Alexandr Golovanov is a .NET developer at KB_Soft Group, an offshore software development company located in Russia, Novosibirsk. Here he has worked
on various .NET projects.

Comments and Discussions