Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Submit Credit Card Transaction to PayPalSubmits 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. LOCAL loReq LOCAL loHttp LOCAL lnSuccess LOCAL lcUsername LOCAL lcPassword LOCAL lcSignature LOCAL lcVersion LOCAL lcDomain LOCAL lnPort LOCAL lnSsl LOCAL loResp LOCAL lcFakeUrl LOCAL loReq2 loReq = CreateObject('Chilkat.HttpRequest') loHttp = CreateObject('Chilkat.Http') * Any string unlocks the component for the 1st 30-days. lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loHttp.LastErrorText) QUIT ENDIF * These are obviously not real credentials... lcUsername = "seller_1999999893_biz_api1.chilkatsoft.com" lcPassword = "1992299958" lcSignature = "ALgNZbbbUgjlBaRnvTKJg8-C6AGpAepaaa1rysDXe1OnF7pJcaccccmN" lcVersion = "3.2" * The PayPal NVP sandbox server for API Signature Security is: * https://api-3t.sandbox.paypal.com/nvp * Build an HTTPS POST Request: loReq.UsePost() loReq.Path = "/nvp" * The content-type should be text/namevalue loReq.AddHeader("content-type","text/namevalue") loReq.AddParam("METHOD","doDirectPayment") loReq.AddParam("PAYMENTACTION","Sale") loReq.AddParam("AMT","1.00") loReq.AddParam("IPADDRESS","37.174.133.150") * Visa, Discover, Mastercard, or Amex loReq.AddParam("CREDITCARDTYPE","Visa") loReq.AddParam("ACCT","4397920706128982") * expiration date should be formatted MMYYYY loReq.AddParam("EXPDATE","022010") loReq.AddParam("CVV2","382") loReq.AddParam("FIRSTNAME","Test") loReq.AddParam("LASTNAME","User") loReq.AddParam("STREET","1 Main St") loReq.AddParam("CITY","San Jose") loReq.AddParam("STATE","CA") loReq.AddParam("ZIP","95131") loReq.AddParam("COUNTRYCODE","US") loReq.AddParam("CURRENCYCODE","USD") * Credentials and version: loReq.AddParam("VERSION",lcVersion) loReq.AddParam("USER",lcUsername) loReq.AddParam("PWD",lcPassword) loReq.AddParam("SIGNATURE",lcSignature) * 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. lcDomain = "api-3t.sandbox.paypal.com" lnPort = 443 lnSsl = 1 * 120-second non-activity timeout. loHttp.ReadTimeout = 15 loResp = loHttp.SynchronousRequest(lcDomain,lnPort,lnSsl,loReq) IF (loResp = NULL ) THEN ? loHttp.LastErrorText 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... lcFakeUrl = "http://www.test.com/abc.asp?" + loResp.BodyStr * We're only using this request object to parse the NVP-formatted response body. loReq2 = CreateObject('Chilkat.HttpRequest') loReq2.SetFromUrl(lcFakeUrl) * The ACK param can have these values: * Successful responses: * Success * SuccessWithWarning * Error responses: * Failure * FailureWithWarning * Warning ? "ACK: " + loReq2.GetParam("ACK") * Assuming success, we'll have these params: ? "AMT: " + loReq2.GetParam("AMT") ? "CURRENCYCODE: " + loReq2.GetParam("CURRENCYCODE") ? "AVSCODE: " + loReq2.GetParam("AVSCODE") ? "CVV2MATCH: " + loReq2.GetParam("CVV2MATCH") ? "TRANSACTIONID: " + loReq2.GetParam("TRANSACTIONID") ? "TIMESTAMP: " + loReq2.GetParam("TIMESTAMP") ? "CORRELATIONID: " + loReq2.GetParam("CORRELATIONID") ? "VERSION: " + loReq2.GetParam("VERSION") ? "BUILD: " + loReq2.GetParam("BUILD") * On failure, some of the above params will be set, but these * params will also be present: ? "L_ERRORCODE0: " + loReq2.GetParam("L_ERRORCODE0") ? "L_SHORTMESSAGE0: " + loReq2.GetParam("L_SHORTMESSAGE0") ? "L_LONGMESSAGE0: " + loReq2.GetParam("L_LONGMESSAGE0") ? "L_SEVERITYCODE0: " + loReq2.GetParam("L_SEVERITYCODE0") ENDIF |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser