Sample code for 30+ languages & platforms
SQL Server

PayPal PayFlowPro - Send Transaction to Server

See more HTTP Misc Examples

Sends a simple transaction to the Gateway server.

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Implements the following CURL command:

    -- curl https://pilot-payflowpro.paypal.com -d PARTNER=PayPal -d VENDOR=zzz -d USER=zzz -d PWD=zzzzz -d TRXTYPE=S -d AMT=40 -d CREATESECURETOKEN=Y -d SECURETOKENID=XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX

    -- Use the following online tool to generate HTTP code from a CURL command
    -- Convert a cURL Command to HTTP Source Code

    DECLARE @req int
    EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @req OUT

    EXEC sp_OASetProperty @req, 'HttpVerb', 'POST'
    EXEC sp_OASetProperty @req, 'Path', '/'
    EXEC sp_OASetProperty @req, 'ContentType', 'application/x-www-form-urlencoded'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'PARTNER', 'PayPal'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'VENDOR', 'zzz'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'USER', 'zzz'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'PWD', 'zzzzz'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'TRXTYPE', 'S'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'AMT', '40'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'CREATESECURETOKEN', 'Y'
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'SECURETOKENID', 'XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX'

    DECLARE @resp int
    EXEC @hr = sp_OACreate 'Chilkat.HttpResponse', @resp OUT

    EXEC sp_OAMethod @http, 'HttpReq', @success OUT, 'https://pilot-payflowpro.paypal.com', @req, @resp
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @req
        EXEC @hr = sp_OADestroy @resp
        RETURN
      END


    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT 'Status code: ' + @iTmp0

    PRINT 'Response body:'
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @req
    EXEC @hr = sp_OADestroy @resp


END
GO