Integrate with PayPal's 
Website Payment Pro 
Using VB and ASP In Minutes! 
Home Features Support Licensing Contact Us Order Now

Sample ASP Code

In this sample ASP code for the DoDirectPayment method, you can see just how quickly and easily PayPal DLL can be integrated with your ASP solution. This code will process a credit card through the PayPal system.

Sample Code

dim ppDLL
set ppDLL = createObject("PayPalDLL.DoDirectPayment")
with ppDLL
 
    .currencyID = "USD" ' currency code, 3 letter
    .TimeoutInSec = 60 ' seconds
    .ApplyKey "info_api1.domain.com", true, "LICENSE_KEY"
        ' your PayPal api username or account name usually of the form name.domain.com,
        ' a boolean value indicating whether to connect to the 
        ' live server (true) or sandbox server (false),
        ' your license key (licensed users only) 
        ' unlicensed users are restricted to connecting to the sandbox server
    .password = "password" ' your PayPal api password
    .certpath = "LOCAL_MACHINE\MY\info_api1.domain.com" ' path in the Windows Certificate Store
        'to your PayPal certificate, usually LOCAL_MACHINE\MY\ your username
        
        ' as an alternate to using the certificate and a signature hash can be used
    .useSignature "YOUR_SIGNATURE_HASH" ' the signature 128-bit hash generated by PayPal
    'The above useSignature method is optional, and if used 
    'the certPath property does not need to be set
    'To obtain this signature: 
	'a. Log into your PayPal account at www.paypal.com
        'b. Click PROFILE
	'c. Click API ACCESS under Account Information
        'd. Click REQUEST API CREDENTIALS
	'e. If you already have an API Certificate, you must REMOVE it
        'f. Select API SIGNATURE, check the I AGREE box and then click the SUBMIT button.
        
    ' ***** PLEASE NOTE your username and password are NOT your PayPal login username and password
    ' your certificate/signature for the PayPal sandbox (liveServer = false), is NOT the same as the 
    ' certificate/signature for the live PayPal API server (liveServer = true).
                    
    .ItemTotal = cdbl(itemTotal) ' the total of the items in your website's cart
    .ShippingTotal = cdbl(shippingTotal) ' shipping total in your currency
    .TaxTotal = cdbl(taxTotal) ' tax total in your currency
    .OrderTotal = cdbl(orderTotal) 'the total order cost from the sum of the above 3
                    
    .CardOwnerEmail = "test@test.org"
    .CardOwnerFirstName = "Tom"
    .CardOwnerLastName = "Tester"
    .CardOwnerAddressStreet1 = "12 Main Street"
    .CardOwnerAddressStreet2 = ""
    .CardOwnerAddressCityName = "Anytown"
    .CardOwnerAddressStateOrProvince = "CA"
    .CardOwnerAddressPostalCode = "92024"
    
    .CardOwnerAddressCountry = "US" ' 2 character country code
    
    .CardOwnerAddressPhone = "800-555-5555"
                    
    .CreditCardType = "visa"
    .CreditCardNumber = "4111111111111111"
    .ExpMonth = 1
    .ExpYear = 2010
    .CVV2 = "111"
                    
    .IPAddress = Request.ServerVariables("REMOTE_ADDR")
    .MerchantSessionId = Session.SessionID
                    
    SOAPreturnCode = .DoDirectPayment
                    
    if (SOAPreturnCode = 1 or SOAPreturnCode = -2) and _
        Len(.returnTransactionID) > 0 and .returnAmount > 0 then
        Response.Write "Payment successfully processed."
    else
        if len(.Errors) = 0 then
            Response.Write "Unknown error. We apologize for the inconvenience."
        else
            Response.Write "Error while trying to process your credit card: " & .Errors
        end if
    end if
end with
set ppDLL = nothing


The DLL makes it simple. No SOAP formatting to worry about. No namespaces to get right, simply specify all the parameters to the DLL and let it take care of the work.



Powered by
This website and CTdeveloping are in no way endorsed by or authorized by PayPal, its affilates, or its parent companies.
PayPal and the PayPal Logo is a registered trademark of PayPal, an eBay Company
Privacy Policy