Created
May 3, 2012 20:59
-
-
Save t2-support-gists/2589458 to your computer and use it in GitHub Desktop.
Notary Vb app1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AT&T API Samples - Notary app 1 | |
| ------------------------------ | |
| This file describes how to set up, configure and run the VB Applications of the AT&T RESTFul sample applications. | |
| It covers all steps required to register the application on DevConnect and, based on the generated API keys and secrets, | |
| create and run one's own full-fledged sample applications. | |
| 1. Configuration | |
| 2. Installation | |
| 3. Parameters | |
| 4. Running the application | |
| 1. Configuration | |
| Configuration consists of a few steps necessary to get an application registered on DevConnect with the proper services and | |
| endpoints, depending on the type of client-side application (autonomous/non-autonomous). | |
| To register an application, go to https://devconnect-api.att.com/ and login with your valid username and password. | |
| Next, choose "My Apps" from the bar at the top of the page and click the "Setup a New Application" button. | |
| Fill in the form, in particular all fields marked as "required". | |
| Be careful while filling in the "OAuth Redirect URL" field. It should contain the URL that the oAuth provider will redirect | |
| users to when he/she successfully authenticates and authorizes your application. | |
| NOTE: You MUST select PAYMENT in the list of services under field 'Services' in order to use this sample application code. | |
| Having your application registered, you will get back an important pair of data: an API key and Secret key. They are | |
| necessary to get your applications working with the AT&T HTML5 APIs. See 'Adjusting parameters' below to learn how to use | |
| these keys. | |
| Initially your newly registered application is restricted to the "Sandbox" environment only. To move it to production, | |
| you may promote it by clicking the "Promote to production" button. Notice that you will get a different API key and secret, | |
| so these values in your application should be adjusted accordingly. | |
| Depending on the kind of authentication used, an application may be based on either the Autonomous Client or the Web-Server | |
| Client OAuth flow (see https://devconnect-api.att.com/docs/oauth-v1/client-credentials-grant-type or | |
| https://devconnect-api.att.com/docs/oauth-v1/authorization-code-grant-type respectively). | |
| 2. Installation | |
| ** Requirements | |
| 1. To run the this sample application you need an IIS Server. | |
| 2. Change the value of "href" at the following line in Default.aspx to point to the location of the "common.css" of "style" folder: | |
| <link rel="stylesheet" type="text/css" href="../../style/common.css"/> | |
| 3. Change the value of the "url" at the following line in common.css to point to the location of the "att.gif" of "images" folder. | |
| div#header { background:url(../images/att.gif) left center no-repeat; margin: 10px 5px} | |
| 3. Parameters | |
| Each sample application contains a config.web file. It holds configurable parameters described in an easy to read format. | |
| Please populate the following parameters in config.web as specified below: | |
| 1) api_key : {set the value as per your registered application 'API key' field value} | |
| 2) secret_key : {set the value as per your registered application 'Secret key' field value} | |
| 3) FQDN : https://api.att.com | |
| 4) scope : PAYMENT | |
| 5) paymentType : {set the value to "subscription" or "transaction"} | |
| 6) Amount : {set the value to decimal value} | |
| 7) Category : {set the value to 1,3,4 or 5} | |
| 8) Channel : {set the value to MOBILE_WEB} | |
| 9) MerchantPaymentRedirectUrl : {set the value to the notary applicatoin link} | |
| 10) IsPurchaseOnNoActiveSubscription : {set the value to false} | |
| 11) SubscriptionRecurringNumber" : {set the value to 9999} | |
| 12) SubscriptionRecurringPeriod : {set the value to MONTHLY} | |
| 13) SubscriptionRecurringPeriodAmount : {set the value to 1} | |
| 4. Running the application | |
| Suppose you copied the sample app files in your IIS server webroot/notary/app1/ folder, In order to run the sample application, type in'http://IIS_HOSTNAME/notary/app1/Default.aspx' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
| <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head> | |
| <title>AT&T Sample Notary Application - Sign Payload Application</title> | |
| <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> | |
| <link rel="stylesheet" type="text/css" href="../../style/common.css"/ > | |
| </script> | |
| <body> | |
| <div id="container"> | |
| <!-- open HEADER --><div id="header"> | |
| <div> | |
| <div id="hcRight"> | |
| <asp:Label runat="server" Text="Label" ID="serverTimeLabel"></asp:Label> | |
| </div> | |
| <div id="hcLeft">Server Time:</div> | |
| </div> | |
| <div> | |
| <div id="hcRight"><script language="JavaScript" type="text/javascript"> | |
| var myDate = new Date(); | |
| document.write(myDate); | |
| </script></div> | |
| <div id="hcLeft">Client Time:</div> | |
| </div> | |
| <div> | |
| <div id="hcRight"><script language="JavaScript" type="text/javascript"> | |
| document.write("" + navigator.userAgent); | |
| </script></div> | |
| <div id="hcLeft">User Agent:</div> | |
| </div> | |
| <br clear="all" /> | |
| </div><!-- close HEADER --> | |
| <div id="wrapper"> | |
| <div id="content"> | |
| <h1>A&T Sample Notary Application - Sign Payload Application</h1> | |
| </div> | |
| </div> | |
| <div id="wrapper"> | |
| <div id="content"> | |
| <h2><br /> | |
| Feature 1: Sign Payload</h2> | |
| <br/> | |
| </div> | |
| </div> | |
| <form id="form1" runat="server"> | |
| <div id="navigation"> | |
| <table border="0" width="950px"> | |
| <tbody> | |
| <tr> | |
| <td valign="top" class="label">Request:</td> | |
| <td class="cell" > | |
| <asp:TextBox runat="server" ID="requestText" Height="223px" | |
| Width="400px" TextMode="MultiLine"></asp:TextBox> | |
| <td width="50px"></td> | |
| <td valign="top" class="label">Signed Payload:</td> | |
| <td class="cell" width="400px"> | |
| <asp:TextBox runat="server" Height="223px" | |
| Width="400px" TextMode="MultiLine" | |
| ID="SignedPayLoadTextBox"></asp:TextBox> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td></td> | |
| <td></td> | |
| <td width="50px"></td> | |
| <td valign="top" class="label">Signature:</td> | |
| <td class="cell"> | |
| <asp:TextBox ID="SignatureTextBox" runat="server" Height="73px" Width="400px" | |
| TextMode="MultiLine"></asp:TextBox> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td></td> | |
| <td class="cell" align="right"> | |
| <asp:Button runat="server" Text="Sign Payload" ID="signPayLoadButton" | |
| onclick="signPayLoadButton_Click" /></td> | |
| </tr> | |
| </tbody></table> | |
| </div> | |
| <br clear="all" /> | |
| <div align="center"> | |
| <asp:Panel runat="server" ID="notaryPanel"> | |
| </asp:Panel></div> | |
| </form> | |
| <div id="footer"> | |
| <div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&T Virtual Mobile</div> | |
| <p>© 2011 AT&T Intellectual Property. All rights reserved. <a href="http://developer.att.com/" target="_blank">http://developer.att.com</a> | |
| <br> | |
| The Application hosted on this site are working examples intended to be used for reference in creating products to consume AT&T Services and not meant to be used as part of your product. The data in these pages is for test purposes only and intended only for use as a reference in how the services perform. | |
| <br> | |
| For download of tools and documentation, please go to <a href="https://devconnect-api.att.com/" target="_blank">https://devconnect-api.att.com</a> | |
| <br> | |
| For more information contact <a href="mailto:[email protected]">[email protected]</a> | |
| </div> | |
| </div> | |
| </body></html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Imports System.Collections.Generic | |
| Imports System.Linq | |
| Imports System.Web | |
| Imports System.Web.UI | |
| Imports System.Web.UI.WebControls | |
| Imports System.Net | |
| Imports System.IO | |
| Imports System.Web.Services | |
| Imports System.Text | |
| Imports System.Configuration | |
| Imports System.Web.Script.Serialization | |
| Imports System.Drawing | |
| Imports System.Net.Security | |
| Imports System.Security.Cryptography.X509Certificates | |
| Partial Public Class _Default | |
| Inherits System.Web.UI.Page | |
| Private shortCode As String, FQDN As String, oauthFlow As String | |
| Private api_key As String, secret_key As String, auth_code As String, access_token As String, authorize_redirect_uri As String, scope As String, _ | |
| expiryMilliSeconds As String, refresh_token As String, lastTokenTakenTime As String, refreshTokenExpiryTime As String | |
| Private successTable As Table, failureTable As Table | |
| Private amount As String | |
| Private category As Int32 | |
| Private channel As String, description As String, merchantTransactionId As String, merchantProductId As String, merchantApplicationId As String | |
| Private merchantRedirectURI As Uri | |
| Private paymentType As String | |
| Private signedPayLoad As String, signature As String, goBackURL As String | |
| Private MerchantSubscriptionIdList As String, SubscriptionRecurringPeriod As String | |
| Private SubscriptionRecurringNumber As Int32, SubscriptionRecurringPeriodAmount As Int32 | |
| Private IsPurchaseOnNoActiveSubscription As String | |
| Private transactionTime As DateTime | |
| Private transactionTimeString As String | |
| Private payLoadStringFromRequest As String | |
| Public Shared Sub BypassCertificateError() | |
| ServicePointManager.ServerCertificateValidationCallback = DirectCast([Delegate].Combine(ServicePointManager.ServerCertificateValidationCallback, Function(sender1 As [Object], certificate As X509Certificate, chain As X509Chain, sslPolicyErrors As SslPolicyErrors) True), RemoteCertificateValidationCallback) | |
| End Sub | |
| Private Sub readTransactionParametersFromConfigurationFile() | |
| transactionTime = DateTime.UtcNow | |
| transactionTimeString = [String].Format("{0:ddd-MMM-dd-yyyy-HH-mm-ss}", transactionTime) | |
| If ConfigurationManager.AppSettings("Amount") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "Amount is not defined in configuration file") | |
| Return | |
| End If | |
| amount = ConfigurationManager.AppSettings("Amount") | |
| requestText.Text = "Amount: " & amount & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("Category") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "Category is not defined in configuration file") | |
| Return | |
| End If | |
| category = Convert.ToInt32(ConfigurationManager.AppSettings("Category")) | |
| requestText.Text = requestText.Text + "Category: " & category & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("Channel") Is Nothing Then | |
| channel = "MOBILE_WEB" | |
| Else | |
| channel = ConfigurationManager.AppSettings("Channel") | |
| End If | |
| requestText.Text = requestText.Text + "Channel: " & channel & vbCr & vbLf | |
| description = "TrDesc" & transactionTimeString | |
| requestText.Text = requestText.Text + "Description: " & description & vbCr & vbLf | |
| merchantTransactionId = "TrId" & transactionTimeString | |
| requestText.Text = requestText.Text + "MerchantTransactionId: " & merchantTransactionId & vbCr & vbLf | |
| merchantProductId = "ProdId" & transactionTimeString | |
| requestText.Text = requestText.Text + "MerchantProductId: " & merchantProductId & vbCr & vbLf | |
| merchantApplicationId = "MerAppId" & transactionTimeString | |
| requestText.Text = requestText.Text + "MerchantApplicationId: " & merchantApplicationId & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("MerchantPaymentRedirectUrl") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "MerchantPaymentRedirectUrl is not defined in configuration file") | |
| Return | |
| End If | |
| merchantRedirectURI = New Uri(ConfigurationManager.AppSettings("MerchantPaymentRedirectUrl")) | |
| requestText.Text = requestText.Text + "MerchantPaymentRedirectUrl: " & Convert.ToString(merchantRedirectURI) | |
| End Sub | |
| Private Sub readSubscriptionParametersFromConfigurationFile() | |
| If ConfigurationManager.AppSettings("MerchantSubscriptionIdList") Is Nothing Then | |
| MerchantSubscriptionIdList = "merSubIdList" & transactionTimeString | |
| Else | |
| MerchantSubscriptionIdList = ConfigurationManager.AppSettings("MerchantSubscriptionIdList") | |
| End If | |
| requestText.Text = requestText.Text + vbCr & vbLf & "MerchantSubscriptionIdList: " & MerchantSubscriptionIdList & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("SubscriptionRecurringPeriod") Is Nothing Then | |
| SubscriptionRecurringPeriod = "MONTHLY" | |
| Else | |
| SubscriptionRecurringPeriod = ConfigurationManager.AppSettings("SubscriptionRecurringPeriod") | |
| End If | |
| requestText.Text = requestText.Text + "SubscriptionRecurringPeriod: " & SubscriptionRecurringPeriod & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("SubscriptionRecurringNumber") Is Nothing Then | |
| SubscriptionRecurringNumber = Convert.ToInt32("9999") | |
| Else | |
| SubscriptionRecurringNumber = Convert.ToInt32(ConfigurationManager.AppSettings("SubscriptionRecurringNumber")) | |
| End If | |
| requestText.Text = requestText.Text + "SubscriptionRecurringNumber: " & SubscriptionRecurringNumber & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("SubscriptionRecurringPeriodAmount") Is Nothing Then | |
| SubscriptionRecurringPeriodAmount = Convert.ToInt32("1") | |
| Else | |
| SubscriptionRecurringPeriodAmount = Convert.ToInt32(ConfigurationManager.AppSettings("SubscriptionRecurringPeriodAmount")) | |
| End If | |
| requestText.Text = requestText.Text + "SubscriptionRecurringPeriodAmount: " & SubscriptionRecurringPeriodAmount & vbCr & vbLf | |
| If ConfigurationManager.AppSettings("IsPurchaseOnNoActiveSubscription") Is Nothing Then | |
| IsPurchaseOnNoActiveSubscription = "false" | |
| Else | |
| IsPurchaseOnNoActiveSubscription = ConfigurationManager.AppSettings("IsPurchaseOnNoActiveSubscription") | |
| End If | |
| requestText.Text = requestText.Text + "IsPurchaseOnNoActiveSubscription: " & IsPurchaseOnNoActiveSubscription | |
| End Sub | |
| Protected Sub Page_Load(sender As Object, e As EventArgs) | |
| 'BypassCertificateError() | |
| Dim currentServerTime As DateTime = DateTime.UtcNow | |
| serverTimeLabel.Text = [String].Format("{0:ddd, MMM dd, yyyy HH:mm:ss}", currentServerTime) & " UTC" | |
| FQDN = ConfigurationManager.AppSettings("FQDN").ToString() | |
| If ConfigurationManager.AppSettings("FQDN") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "FQDN is not defined in configuration file") | |
| Return | |
| End If | |
| FQDN = ConfigurationManager.AppSettings("FQDN").ToString() | |
| If ConfigurationManager.AppSettings("api_key") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "api_key is not defined in configuration file") | |
| Return | |
| End If | |
| api_key = ConfigurationManager.AppSettings("api_key").ToString() | |
| If ConfigurationManager.AppSettings("secret_key") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "secret_key is not defined in configuration file") | |
| Return | |
| End If | |
| secret_key = ConfigurationManager.AppSettings("secret_key").ToString() | |
| If ConfigurationManager.AppSettings("scope") Is Nothing Then | |
| scope = "PAYMENT" | |
| Else | |
| scope = ConfigurationManager.AppSettings("scope").ToString() | |
| End If | |
| If (Request("signed_payload") IsNot Nothing) AndAlso (Request("signed_signature") IsNot Nothing) AndAlso (Request("goBackURL") IsNot Nothing) AndAlso (Request("signed_request") IsNot Nothing) Then | |
| signPayLoadButton.Text = "Back" | |
| requestText.Text = Request("signed_request").ToString() | |
| SignedPayLoadTextBox.Text = Request("signed_payload").ToString() | |
| SignatureTextBox.Text = Request("signed_signature").ToString() | |
| goBackURL = Request("goBackURL").ToString() | |
| Else | |
| If (Request("request_to_sign") IsNot Nothing) AndAlso (Request("goBackURL") IsNot Nothing) AndAlso (Request("api_key") IsNot Nothing) AndAlso (Request("secret_key") IsNot Nothing) Then | |
| payLoadStringFromRequest = Request("request_to_sign").ToString() | |
| goBackURL = Request("goBackURL").ToString() | |
| SignedPayLoadTextBox.Text = payLoadStringFromRequest.ToString() | |
| api_key = Request("api_key").ToString() | |
| secret_key = Request("secret_key").ToString() | |
| executeSignedPayloadFromRequest() | |
| Else | |
| If ConfigurationManager.AppSettings("paymentType") Is Nothing Then | |
| drawPanelForFailure(notaryPanel, "paymentType is not defined in configuration file") | |
| Return | |
| End If | |
| paymentType = ConfigurationManager.AppSettings("paymentType") | |
| If paymentType.Equals("Transaction", StringComparison.OrdinalIgnoreCase) Then | |
| readTransactionParametersFromConfigurationFile() | |
| ElseIf paymentType.Equals("Subscription", StringComparison.OrdinalIgnoreCase) Then | |
| readTransactionParametersFromConfigurationFile() | |
| readSubscriptionParametersFromConfigurationFile() | |
| Else | |
| drawPanelForFailure(notaryPanel, "paymentType is defined with invalid value in configuration file. Valid values are Transaction or Subscription.") | |
| Return | |
| End If | |
| Dim payLoadString As String = "{'Amount':'" & amount.ToString() & "','Category':'" & category.ToString() & "','Channel':'" & channel.ToString() & "','Description':'" & description.ToString() & "','MerchantTransactionId':'" & merchantTransactionId.ToString() & "','MerchantProductId':'" & merchantProductId.ToString() & "','MerchantApplicaitonId':'" & merchantApplicationId.ToString() & "','MerchantPaymentRedirectUrl':'" & merchantRedirectURI.ToString() & "','MerchantSubscriptionIdList':'" & MerchantSubscriptionIdList.ToString() & "','IsPurchaseOnNoActiveSubscription':'" & IsPurchaseOnNoActiveSubscription.ToString() & "','SubscriptionRecurringNumber':'" & SubscriptionRecurringNumber.ToString() & "','SubscriptionRecurringPeriod':'" & SubscriptionRecurringPeriod.ToString() & "','SubscriptionRecurringPeriodAmount':'" & SubscriptionRecurringPeriodAmount.ToString() | |
| requestText.Text = payLoadString.ToString() | |
| End If | |
| End If | |
| End Sub | |
| Public Sub executeSignedPayloadFromRequest() | |
| Try | |
| Dim sendingData As String = payLoadStringFromRequest.ToString() | |
| Dim newTransactionResponseData As [String] | |
| Dim notaryAddress As String | |
| notaryAddress = "" & FQDN & "/Security/Notary/Rest/1/SignedPayload" | |
| 'WebRequest newTransactionRequestObject = (WebRequest)System.Net.WebRequest.Create("" + FQDN + "/Security/Notary/Rest/1/SignedPayload?client_id=" + api_key.ToString() + "&client_secret=" + secret_key.ToString()); | |
| Dim newTransactionRequestObject As WebRequest = DirectCast(System.Net.WebRequest.Create(notaryAddress), WebRequest) | |
| newTransactionRequestObject.Headers.Add("client_id", api_key.ToString()) | |
| newTransactionRequestObject.Headers.Add("client_secret", secret_key.ToString()) | |
| newTransactionRequestObject.Method = "POST" | |
| newTransactionRequestObject.ContentType = "application/json" | |
| Dim encoding As New UTF8Encoding() | |
| Dim postBytes As Byte() = encoding.GetBytes(sendingData) | |
| newTransactionRequestObject.ContentLength = postBytes.Length | |
| Dim postStream As Stream = newTransactionRequestObject.GetRequestStream() | |
| postStream.Write(postBytes, 0, postBytes.Length) | |
| postStream.Close() | |
| Dim newTransactionResponseObject As WebResponse = DirectCast(newTransactionRequestObject.GetResponse(), HttpWebResponse) | |
| Using newTransactionResponseStream As New StreamReader(newTransactionResponseObject.GetResponseStream()) | |
| newTransactionResponseData = newTransactionResponseStream.ReadToEnd() | |
| Dim deserializeJsonObject As New JavaScriptSerializer() | |
| Dim deserializedJsonObj As TransactionResponse = DirectCast(deserializeJsonObject.Deserialize(newTransactionResponseData, GetType(TransactionResponse)), TransactionResponse) | |
| newTransactionResponseStream.Close() | |
| 'SignedPayLoadTextBox.Text = deserializedJsonObj.SignedDocument.ToString(); | |
| 'SignatureTextBox.Text = deserializedJsonObj.Signature.ToString(); | |
| Response.Redirect(goBackURL.ToString() & "?ret_signed_payload=" & deserializedJsonObj.SignedDocument.ToString() & "&ret_signature=" & deserializedJsonObj.Signature.ToString()) | |
| End Using | |
| 'SignatureTextBox.Text = ex.ToString(); | |
| 'Response.Redirect(goBackURL.ToString() + "?ret_signed_payload_failed=true"); | |
| Catch ex As Exception | |
| End Try | |
| End Sub | |
| Public Function executeSignedPayload() As Boolean | |
| Try | |
| Dim newTransactionResponseData As [String] | |
| Dim notaryAddress As String | |
| notaryAddress = "" & FQDN & "/Security/Notary/Rest/1/SignedPayload" | |
| 'WebRequest newTransactionRequestObject = (WebRequest)System.Net.WebRequest.Create("" + FQDN + "/Security/Notary/Rest/1/SignedPayload?client_id=" + api_key.ToString() + "&client_secret=" + secret_key.ToString()); | |
| Dim newTransactionRequestObject As WebRequest = DirectCast(System.Net.WebRequest.Create(notaryAddress), WebRequest) | |
| newTransactionRequestObject.Headers.Add("client_id", api_key.ToString()) | |
| newTransactionRequestObject.Headers.Add("client_secret", secret_key.ToString()) | |
| Dim payLoadString As String = "{'Amount':'" & amount.ToString() & "','Category':'" & category.ToString() & "','Channel':'" & channel.ToString() & "','Description':'" & description.ToString() & "','MerchantTransactionId':'" & merchantTransactionId.ToString() & "','MerchantProductId':'" & merchantProductId.ToString() & "','MerchantApplicaitonId':'" & merchantApplicationId.ToString() & "','MerchantPaymentRedirectUrl':'" & merchantRedirectURI.ToString() & "','MerchantSubscriptionIdList':'" & MerchantSubscriptionIdList.ToString() & "','IsPurchaseOnNoActiveSubscription':'" & IsPurchaseOnNoActiveSubscription.ToString() & "','SubscriptionRecurringNumber':'" & SubscriptionRecurringNumber.ToString() & "','SubscriptionRecurringPeriod':'" & SubscriptionRecurringPeriod.ToString() & "','SubscriptionRecurringPeriodAmount':'" & SubscriptionRecurringPeriodAmount.ToString() & "'}" | |
| newTransactionRequestObject.Method = "POST" | |
| newTransactionRequestObject.ContentType = "application/json" | |
| Dim encoding As New UTF8Encoding() | |
| Dim postBytes As Byte() = encoding.GetBytes(payLoadString) | |
| newTransactionRequestObject.ContentLength = postBytes.Length | |
| Dim postStream As Stream = newTransactionRequestObject.GetRequestStream() | |
| postStream.Write(postBytes, 0, postBytes.Length) | |
| postStream.Close() | |
| Dim newTransactionResponseObject As WebResponse = DirectCast(newTransactionRequestObject.GetResponse(), HttpWebResponse) | |
| Using newTransactionResponseStream As New StreamReader(newTransactionResponseObject.GetResponseStream()) | |
| newTransactionResponseData = newTransactionResponseStream.ReadToEnd() | |
| Dim deserializeJsonObject As New JavaScriptSerializer() | |
| Dim deserializedJsonObj As TransactionResponse = DirectCast(deserializeJsonObject.Deserialize(newTransactionResponseData, GetType(TransactionResponse)), TransactionResponse) | |
| SignedPayLoadTextBox.Text = deserializedJsonObj.SignedDocument.ToString() | |
| SignatureTextBox.Text = deserializedJsonObj.Signature.ToString() | |
| 'Response.Redirect(redirectUrl.ToString()); | |
| newTransactionResponseStream.Close() | |
| Return True | |
| End Using | |
| Catch ex As Exception | |
| Return False | |
| End Try | |
| End Function | |
| Protected Sub signPayLoadButton_Click(sender As Object, e As EventArgs) | |
| If signPayLoadButton.Text.Equals("Back", StringComparison.CurrentCultureIgnoreCase) Then | |
| Try | |
| Response.Redirect(goBackURL.ToString() & "?shown_notary=true") | |
| Catch ex As Exception | |
| drawPanelForFailure(notaryPanel, ex.ToString()) | |
| End Try | |
| Else | |
| Dim result As Boolean = executeSignedPayload() | |
| End If | |
| End Sub | |
| Private Sub drawPanelForFailure(panelParam As Panel, message As String) | |
| failureTable = New Table() | |
| failureTable.Font.Name = "Sans-serif" | |
| failureTable.Font.Size = 9 | |
| failureTable.BorderStyle = BorderStyle.Outset | |
| failureTable.Width = Unit.Pixel(650) | |
| Dim rowOne As New TableRow() | |
| Dim rowOneCellOne As New TableCell() | |
| rowOneCellOne.Font.Bold = True | |
| rowOneCellOne.Text = "ERROR:" | |
| rowOne.Controls.Add(rowOneCellOne) | |
| 'rowOneCellOne.BorderWidth = 1; | |
| failureTable.Controls.Add(rowOne) | |
| Dim rowTwo As New TableRow() | |
| Dim rowTwoCellOne As New TableCell() | |
| 'rowTwoCellOne.BorderWidth = 1; | |
| rowTwoCellOne.Text = message.ToString() | |
| rowTwo.Controls.Add(rowTwoCellOne) | |
| failureTable.Controls.Add(rowTwo) | |
| failureTable.BorderWidth = 2 | |
| failureTable.BorderColor = Color.Red | |
| failureTable.BackColor = System.Drawing.ColorTranslator.FromHtml("#fcc") | |
| panelParam.Controls.Add(failureTable) | |
| End Sub | |
| End Class | |
| Public Class AccessTokenResponse | |
| Public access_token As String | |
| Public refresh_token As String | |
| Public expires_in As String | |
| End Class | |
| Public Class TransactionResponse | |
| Public Property SignedDocument() As String | |
| Get | |
| Return m_SignedDocument | |
| End Get | |
| Set(value As String) | |
| m_SignedDocument = Value | |
| End Set | |
| End Property | |
| Private m_SignedDocument As String | |
| Public Property Signature() As String | |
| Get | |
| Return m_Signature | |
| End Get | |
| Set(value As String) | |
| m_Signature = Value | |
| End Set | |
| End Property | |
| Private m_Signature As String | |
| End Class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <!-- | |
| For more information on how to configure your ASP.NET application, please visit | |
| http://go.microsoft.com/fwlink/?LinkId=169433 | |
| --> | |
| <configuration> | |
| <system.web> | |
| <compilation debug="true" targetFramework="4.0"/> | |
| <customErrors mode="Off"></customErrors> | |
| </system.web> | |
| <appSettings> | |
| <!-- This is mandatory key and value should be equal | |
| to PAYMENT Service registered application 'API key' | |
| example: value="2726942c798aaaaa4bd3625d95cc7355"--> | |
| <add key="api_key" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to PAYMENT Service registered application 'Secret key' | |
| example: value="5fb012657aaa6c7d"--> | |
| <add key="secret_key" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to https://api.att.com for production environment | |
| example: value="https://api.att.com"--> | |
| <add key="FQDN" value=""></add> | |
| <!-- This is optional key and value should be equal | |
| to "PAYMENT" | |
| example: value="PAYMENT"--> | |
| <add key="scope" value=""/> | |
| <!-- This is mandatory key and valid values are "subscription" or "transaction" | |
| example: value="transaction"--> | |
| <add key="paymentType" value=""/> | |
| <!-- This is mandatory key and has to be decimal format | |
| example: value="2.1"--> | |
| <add key="Amount" value=""/> | |
| <!-- any decimal number --> | |
| <!-- This is mandatory key and has to be one of the value 1,3,4,5 | |
| example: value="3"--> | |
| <add key="Category" value=""/> | |
| <!--2 is not a valid value --> | |
| <!-- This is optional key and if you want to define, define only as MOBILE_WEB | |
| example: value="MOBILE_WEB"--> | |
| <add key ="Channel" value=""/> | |
| <!-- This is mandatory parameter and this will be your application url | |
| example: value="http://IIS_Server/vbapps/notary/app1/Default.aspx"--> | |
| <add key ="MerchantPaymentRedirectUrl" value =""/> | |
| <!-- This is optional key and if you want to define, define only as false | |
| example: value="false"--> | |
| <add key ="IsPurchaseOnNoActiveSubscription" value =""/> | |
| <!-- always false --> | |
| <!-- This is optional key and if you want to define, define only as 9999 | |
| example: value="9999"--> | |
| <add key ="SubscriptionRecurringNumber" value =""/> | |
| <!-- This is optional key and if you want to define, define only as MONTHLY | |
| example: value="MONTHLY"--> | |
| <add key ="SubscriptionRecurringPeriod" value =""/> | |
| <!-- This is optional key and if you want to define, define only as 1 | |
| example: value="1"--> | |
| <add key ="SubscriptionRecurringPeriodAmount" value =""/> | |
| </appSettings> | |
| </configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment