PRONTO SDK Example Code for ASP.NET Developers
ProntoOpenNet Tuesday, March 03 2009
Install Instructions:
- Download the zip file by clicking on the link above
- Extract to your Desktop
- Open in Visual Studio 2005+
- Update Web.Config with your Pronto Account and Password (see web.config file for more information) provided by AlphaTrust Support
- Run application in Visual Studio
VB Example included in the project download above:
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'Create the Transaction Dim t As New AlphaTrust.Pronto.Transaction() t.Account.Name = ConfigurationManager.AppSettings("Pronto_Account") t.Account.Password = ConfigurationManager.AppSettings("Pronto_Password") t.Account.OutgoingEmailSignatureBlock = "John Hancock" 'Create the Document Dim doc As New AlphaTrust.Pronto.Document() doc.Source.Type = AlphaTrust.Pronto.Source.Types.Pdf_File_PageImage doc.Source.Data = Convert.ToBase64String(My.Computer.FileSystem.ReadAllBytes(Server.MapPath("Documents/Eula.pdf"))) 'Create a Signer Dim signer As New AlphaTrust.Pronto.Signer() signer.Name.FullName = "John Hancock" 'Create a Signature Dim sig As New AlphaTrust.Pronto.Signature() sig.Font.Bold = True sig.Font.Italic = True sig.ClientReturnUrl = "thanks.asp?a=4" 'Add the Signature to the signer signer.Signatures.Add(sig) 'Add the Signer to the Document doc.Signers.Add(signer) 'Add the Document to the transaction t.Documents.Add(doc) 'Set debug mode to active so we can see the result for testing 'Comment this line out (or set to false) for production t.Debug.Active = True 'Commit the Transaction to Post the Transaction to the PRONTO server t.Commit() 'Check for errors If t.Error = "" Then lblResult.Text = "Your transaction submitted successfully!" Else If t.Debug.Active = False Then lblResult.Text = t.ErrorFriendlyMessage End If End If 'in debug mode - response the test data for review If t.Debug.Active Then pnlDebugInfo.CssClass = "DebugPanel" pnlDebugInfo.Controls.Add(New LiteralControl(t.Debug.FormattedReturn)) End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>HTML Test</title> <style type="text/css"> .DebugPanel {border:solid 1px red; background-color:#FFFFCC;padding:13px;margin:13px;} </style> </head> <body> <form id="form1" runat="server"> <asp:Button ID="btnSubmit" runat="server" Text="Create Transaction" OnClick="btnSubmit_Click" /> <asp:Label ID="lblResult" runat="server" /> <asp:Panel ID="pnlDebugInfo" runat="server" /> </form> </body> </html>
C# Example included in the project download above:
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void btnSubmit_Click(object sender, System.EventArgs e) { //Create the Transaction AlphaTrust.Pronto.Transaction t = new AlphaTrust.Pronto.Transaction(); t.Account.Name = ConfigurationManager.AppSettings["Pronto_Account"]; t.Account.Password = ConfigurationManager.AppSettings["Pronto_Password"]; t.Account.OutgoingEmailSignatureBlock = "John Hancock"; //Create the Document AlphaTrust.Pronto.Document doc = new AlphaTrust.Pronto.Document(); doc.Source.Type = AlphaTrust.Pronto.Source.Types.Pdf_File_PageImage; doc.Source.Data = Convert.ToBase64String(System.IO.File.ReadAllBytes(Server.MapPath("Documents/Eula.pdf"))); //Create a Signer AlphaTrust.Pronto.Signer signer = new AlphaTrust.Pronto.Signer(); signer.Name.FullName = "John Hancock"; //Create a Signature AlphaTrust.Pronto.Signature sig = new AlphaTrust.Pronto.Signature(); sig.Font.Bold = true; sig.Font.Italic = true; sig.ClientReturnUrl = "thanks.asp?a=4"; //Add the Signature to the signer signer.Signatures.Add(sig); //Add the Signer to the Document doc.Signers.Add(signer); //Add the Document to the transaction t.Documents.Add(doc); //Set debug mode to active so we can see the result for testing //Comment this line out (or set to false) for production t.Debug.Active = true; //Commit the Transaction to Post the Transaction to the PRONTO server t.Commit(); //Check for errors if (string.IsNullOrEmpty(t.Error)) { lblResult.Text = "Your transaction submitted successfully!"; } else { if (t.Debug.Active == false) { lblResult.Text = t.ErrorFriendlyMessage; } } //in debug mode - response the test data for review if (t.Debug.Active) { pnlDebugInfo.CssClass = "DebugPanel"; pnlDebugInfo.Controls.Add(new LiteralControl(t.Debug.FormattedReturn)); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>HTML Test</title> <style type="text/css"> .DebugPanel {border:solid 1px red; background-color:#FFFFCC;padding:13px;margin:13px;} </style> </head> <body> <form id="form1" runat="server"> <asp:Button ID="btnSubmit" runat="server" Text="Create Transaction" OnClick="btnSubmit_Click" /> <asp:Label ID="lblResult" runat="server" /> <asp:Panel ID="pnlDebugInfo" runat="server" /> </form> </body> </html>
Web.Config Application Settings Example
... <configuration> <appSettings> <remove key="Pronto_Account"/> <remove key="Pronto_Password"/> <remove key="Pronto_HttpHost"/> <remove key="Pronto_AppErrorEmailAddress"/> <remove key="Pronto_TestEmail"/> <!-- THE ABOVE WILL REMOVE DEFAULT SETTINGS ON SERVER - DO NOT REMOVE --> <!-- YOUR PRONTO ACCOUNT INFORMATION --> <add key="Pronto_Account" value="YourAccountNameHere" /> <add key="Pronto_Password" value="YourPasswordHere" /> <!-- SWAP THESE FOR TESTING/PRODUCTION USE --> <add key="Pronto_HttpHost" value="https://test1.alphatrust.com/" /> <!--<add key="Pronto_HttpHost" value="https://pronto1.alphatrust.com/" />--> <!-- EMAIL ADDRESS TO SEND TRANSACTION ERRORS --> <add key="Pronto_AppErrorEmailAddress" value="Errors@YouDomain.com" /> <!-- EMAIL ADDRESS TO SEND DEBUG TESTING EMAILS --> <add key="Pronto_TestEmail" value="testing@YouDomain.com" /> </appSettings> </configuration> ...