Click here to Skip to main content
13,410,713 members (32,307 online)
Click here to Skip to main content

Stats

677.7K views
18K downloads
576 bookmarked
Posted 14 Jun 2007

Use of the PayPal payment system in ASP.NET

, 2 Jun 2008
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)

Share

About the Author

Alexandr Golovanov
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.

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180221.1 | Last Updated 3 Jun 2008
Article Copyright 2007 by Alexandr Golovanov
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid