/// <summary> /// This method invokes GetNotaryResponse() method of RequestFactory by passing payload string. /// and displays the notarized payload in the text box. /// </summary> private void ExecuteSignedPayload() { try { this.Initialize(); string payLoadString = requestText.Text; NotaryResponse notaryResponse = this.requestFactory.GetNotaryResponse(payLoadString); if (null != notaryResponse) { SignedPayLoadTextBox.Text = notaryResponse.SignedDocument; SignatureTextBox.Text = notaryResponse.Signature; } } catch (ArgumentException ae) { this.DrawPanelForFailure(notaryPanel, ae.Message); } catch (InvalidResponseException ie) { this.DrawPanelForFailure(notaryPanel, ie.Body); } catch (Exception ex) { this.DrawPanelForFailure(notaryPanel, ex.Message); } }
/// <summary> /// Event to create a new payment transaction /// </summary> /// <param name="sender">Sender Information</param> /// <param name="e">List of Arguments</param> protected void NewTransactionButton_Click(object sender, EventArgs e) { try { this.transactionTime = DateTime.UtcNow; this.transactionTimeString = string.Format("{0:dddMMMddyyyyHHmmss}", this.transactionTime); if (Radio_TransactionProductType.SelectedIndex == 0) { this.amount = Convert.ToDouble(this.MinTransactionAmount); } else if (Radio_TransactionProductType.SelectedIndex == 1) { this.amount = Convert.ToDouble(this.MaxTransactionAmount); } Session["tranType"] = Radio_TransactionProductType.SelectedIndex.ToString(); this.description = "TrDesc" + this.transactionTimeString; this.merchantTransactionId = "TrId" + this.transactionTimeString; Session["merTranId"] = this.merchantTransactionId.ToString(); this.merchantProductId = "ProdId" + this.transactionTimeString; this.merchantApplicationId = "MerAppId" + this.transactionTimeString; //// Get payment payload notarized. NotaryResponse notaryResponse = this.requestFactory.GetNotarizedForNewTransaction(this.amount, PaymentCategories.ApplicationGames, this.description, this.merchantTransactionId, this.merchantProductId, this.merchantRedirectURI); //// Get the TransactionRedirectUrl which points to AT&T platform transaction endpoint string newTransactionRedirectUrl = this.requestFactory.GetNewTransactionRedirect(notaryResponse); Response.Redirect(newTransactionRedirectUrl); } catch (Exception ex) { this.DrawPanelForFailure(newTransactionPanel, ex.Message); } }
/// <summary> /// This function making http post request to get signedData, signedPayload, signedSignature /// </summary> public void SubmitToNotary(string sendingData, string appKey, string secretKey) { APIRequest apiRequest = new APIRequest("SignedPayload"); apiRequest.addHeaders("client_id", appKey); apiRequest.addHeaders("client_secret", secretKey); apiRequest.requireAccessToken = false; apiRequest.setBinaryData(sendingData); apiRequest.contentType = "application/json"; apiRequest.accept = "application/json"; if (apiService.post(apiRequest)) { string responseData = apiService.apiResponse.getResponseData(); var notaryResponse = new NotaryResponse(); var notaryObj = notaryResponse.deserializeNotaryResponse(responseData); signedPayload = notaryObj.SignedDocument; signedSignature = notaryObj.Signature; } else { throw new Exception(apiService.errorResponse); } }
/// <summary> /// This method get called on new transaction or new subscription payload notarization. /// </summary> private void ExecuteSignedPayloadFromRequest() { try { string payLoadString = requestText.Text; NotaryResponse notaryResponse = this.requestFactory.GetNotaryResponse(payLoadString); if (null != notaryResponse) { Response.Redirect(this.goBackURL + "?ret_signed_payload=" + notaryResponse.SignedDocument + "&ret_signature=" + notaryResponse.Signature); } } catch (ArgumentException ae) { this.DrawPanelForFailure(notaryPanel, ae.Message); } catch (InvalidResponseException ie) { this.DrawPanelForFailure(notaryPanel, ie.Body); } catch (Exception ex) { this.DrawPanelForFailure(notaryPanel, ex.Message); } }