Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

Submit Credit Card Transaction to PayPal

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Submits a credit card transaction to PayPal. The response parameters are displayed for both success and error responses.

This example communicates directly with PayPal's Payflow servers via HTTPS.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set req = Server.CreateObject("Chilkat_9_5_0.HttpRequest")
set http = Server.CreateObject("Chilkat_9_5_0.Http")

'  Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write http.LastErrorText & "<br>"

End If

'  These are obviously not real credentials...
username = "seller_1999999893_biz_api1.chilkatsoft.com"
password = "1992299958"
signature = "ALgNZbbbUgjlBaRnvTKJg8-C6AGpAepaaa1rysDXe1OnF7pJcaccccmN"
version = "3.2"

'  The PayPal NVP sandbox server for API Signature Security is:
'  https://api-3t.sandbox.paypal.com/nvp

'  Build an HTTPS POST Request:
req.UsePost 
req.Path = "/nvp"

'  The content-type should be text/namevalue
req.AddHeader "content-type","text/namevalue"

req.AddParam "METHOD","doDirectPayment"
req.AddParam "PAYMENTACTION","Sale"
req.AddParam "AMT","1.00"
req.AddParam "IPADDRESS","37.174.133.150"
'  Visa, Discover, Mastercard, or Amex
req.AddParam "CREDITCARDTYPE","Visa"
req.AddParam "ACCT","4397920706128982"
'  expiration date should be formatted MMYYYY
req.AddParam "EXPDATE","022010"
req.AddParam "CVV2","382"
req.AddParam "FIRSTNAME","Test"
req.AddParam "LASTNAME","User"
req.AddParam "STREET","1 Main St"
req.AddParam "CITY","San Jose"
req.AddParam "STATE","CA"
req.AddParam "ZIP","95131"
req.AddParam "COUNTRYCODE","US"
req.AddParam "CURRENCYCODE","USD"

'  Credentials and version:
req.AddParam "VERSION",version
req.AddParam "USER",username
req.AddParam "PWD",password
req.AddParam "SIGNATURE",signature

'  Send the HTTPS POST and get the response.  Note: This is a blocking call.
'  The method does not return until the full HTTP response is received.

domain = "api-3t.sandbox.paypal.com"
port = 443
ssl = 1

'  120-second non-activity timeout.
http.ReadTimeout = 15

Set resp = http.SynchronousRequest(domain,port,ssl,req)
If (resp Is Nothing ) Then
    Response.Write Server.HTMLEncode( http.LastErrorText) & "<br>"
Else

    '  The response body is in NVP format -- which is nothing more than URL-encoded name/value pairs.
    '  One easy way to parse it is to use the HttpRequest
    '  object in an unorthodox way.
    '  We'll create a fake URL that contains the name/value pairs
    '  found in the body of the response.
    '  Then we'll load it into a temporary HTTP request object.
    '  The HTTP request object does the parsing for us, and we
    '  can look at the params...

    fakeUrl = "http://www.test.com/abc.asp?" & resp.BodyStr

    '  We're only using this request object to parse the NVP-formatted response body.
    set req2 = Server.CreateObject("Chilkat_9_5_0.HttpRequest")
    req2.SetFromUrl fakeUrl

    '  The ACK param can have these values:
    '  Successful responses:
    '  Success
    '  SuccessWithWarning
    '  Error responses:
    '  Failure
    '  FailureWithWarning
    '  Warning
    Response.Write Server.HTMLEncode( "ACK: " _
         & req2.GetParam("ACK")) & "<br>"

    '  Assuming success, we'll have these params:
    Response.Write Server.HTMLEncode( "AMT: " _
         & req2.GetParam("AMT")) & "<br>"
    Response.Write Server.HTMLEncode( "CURRENCYCODE: " _
         & req2.GetParam("CURRENCYCODE")) & "<br>"
    Response.Write Server.HTMLEncode( "AVSCODE: " _
         & req2.GetParam("AVSCODE")) & "<br>"
    Response.Write Server.HTMLEncode( "CVV2MATCH: " _
         & req2.GetParam("CVV2MATCH")) & "<br>"
    Response.Write Server.HTMLEncode( "TRANSACTIONID: " _
         & req2.GetParam("TRANSACTIONID")) & "<br>"
    Response.Write Server.HTMLEncode( "TIMESTAMP: " _
         & req2.GetParam("TIMESTAMP")) & "<br>"
    Response.Write Server.HTMLEncode( "CORRELATIONID: " _
         & req2.GetParam("CORRELATIONID")) & "<br>"
    Response.Write Server.HTMLEncode( "VERSION: " _
         & req2.GetParam("VERSION")) & "<br>"
    Response.Write Server.HTMLEncode( "BUILD: " _
         & req2.GetParam("BUILD")) & "<br>"

    '  On failure, some of the above params will be set, but these
    '  params will also be present:
    Response.Write Server.HTMLEncode( "L_ERRORCODE0: " _
         & req2.GetParam("L_ERRORCODE0")) & "<br>"
    Response.Write Server.HTMLEncode( "L_SHORTMESSAGE0: " _
         & req2.GetParam("L_SHORTMESSAGE0")) & "<br>"
    Response.Write Server.HTMLEncode( "L_LONGMESSAGE0: " _
         & req2.GetParam("L_LONGMESSAGE0")) & "<br>"
    Response.Write Server.HTMLEncode( "L_SEVERITYCODE0: " _
         & req2.GetParam("L_SEVERITYCODE0")) & "<br>"

End If

%>
</body>
</html>

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.