protected void CyberSource_Customer_Profile_Fetch() { try { /// Include the following fields in the request: /// merchantID /// merchantReferenceCode /// recurringSubscriptionInfo_frequency —set to on-demand. /// paySubscriptionCreateService_paymentRequestID —include the requestID value returned from the original transaction request. /// /// See Appendix A, "API Fields," on page 34 for detailed descriptions of the request and /// reply fields. See Appendix B, "Examples," on page 62 for a request and reply example. RequestMessage request = new RequestMessage(); request.paySubscriptionRetrieveService = new PaySubscriptionRetrieveService(); request.paySubscriptionRetrieveService.run = "true"; // Tokenization? request.merchantReferenceCode = merchantReferenceCode.Text; RecurringSubscriptionInfo SubscriptionInfo = new RecurringSubscriptionInfo(); SubscriptionInfo.subscriptionID = "4738680334246909704009"; request.recurringSubscriptionInfo = SubscriptionInfo; ReplyMessage reply = SoapClient.RunTransaction(request); string template = ghCyberSource.GetTemplate(reply.decision.ToUpper()); string content = ""; try { content = ghCyberSource.GetContent(reply); } catch { content = "error"; } txtTemplate.Text = template.ToString(); txtContent.Text = content.ToString(); txtReply.Text = reply.ToString(); lblCatch.Text += String.Format("<br />decision: {0}", reply.decision.ToUpper()); try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.reasonCode); } catch { } try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.paySubscriptionCreateReply.reasonCode); } catch { } try { lblCatch.Text += String.Format("<br />subscriptionID: {0}", reply.paySubscriptionCreateReply.subscriptionID); } catch { } try { lblCatch.Text += String.Format("<br />missingField: {0}", reply.missingField.Length); } catch { String.Format("<br />missingField: {0}", "x"); } lblCatch.Text += "<hr />"; try { lblCatch.Text += String.Format("<br />missingField: {0}", reply.missingField.Length); } catch { String.Format("<br />missingField: {0}", "x"); } } catch (Exception ex) { lblCatch.Text += String.Format("<table class='table_error'>" + "<tr><td>Error<td/><td>{0}</td></tr>" + "<tr><td>Message<td/><td>{1}</td></tr>" + "<tr><td>StackTrace<td/><td>{2}</td></tr>" + "<tr><td>Source<td/><td>{3}</td></tr>" + "<tr><td>InnerException<td/><td>{4}</td></tr>" + "<tr><td>Data<td/><td>{5}</td></tr>" + "</table>" , "Tokenization" //0 , ex.Message //1 , ex.StackTrace //2 , ex.Source //3 , ex.InnerException //4 , ex.Data //5 , ex.HelpLink , ex.TargetSite ); } }
protected void CyberSource_Customer_Transaction_Tokenization() { try { /// This will create a Transaction using Tokenization as payment RequestMessage request = new RequestMessage(); request.ccAuthService = new CCAuthService(); request.ccAuthService.run = "true"; request.ccCaptureService = new CCCaptureService(); request.ccCaptureService.run = "true"; string reconciliationID = donationid.Text.ToString(); request.ccAuthService.reconciliationID = reconciliationID; request.ccCaptureService.reconciliationID = reconciliationID; request.merchantReferenceCode = reconciliationID; RecurringSubscriptionInfo SubscriptionInfo = new RecurringSubscriptionInfo(); SubscriptionInfo.subscriptionID = subscriptionID.Text; // "4738680334246909704009"; request.recurringSubscriptionInfo = SubscriptionInfo; #region purchaseTotals PurchaseTotals purchaseTotals = new PurchaseTotals(); purchaseTotals.currency = "USD"; request.purchaseTotals = purchaseTotals; request.item = new Item[1]; Item item = new Item(); item.id = "0"; item.unitPrice = "5.25"; item.productSKU = "RD001"; item.productName = "ARC Tokenization"; request.item[0] = item; #endregion purchaseTotals #region Reply ReplyMessage reply = SoapClient.RunTransaction(request); string template = ghCyberSource.GetTemplate(reply.decision.ToUpper()); string content = ""; try { content = ghCyberSource.GetContent(reply); } catch { content = "error"; } #endregion Reply txtTemplate.Text = template.ToString(); txtContent.Text = content.ToString(); txtReply.Text = reply.ToString(); lblCatch.Text += String.Format("<br />decision: {0}", reply.decision.ToUpper()); try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.reasonCode); } catch { } try { lblCatch.Text += String.Format("<br />merchantReferenceCode: {0}", reply.merchantReferenceCode); } catch { } lblCatch.Text += "<hr />"; try { lblCatch.Text += String.Format("<br />amount: {0}", reply.ccAuthReply.amount); } catch { String.Format("<br />amount: {0}", "x"); } try { lblCatch.Text += String.Format("<br />authFactorCode: {0}", reply.ccAuthReply.authFactorCode); } catch { String.Format("<br />authFactorCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />authorizationCode: {0}", reply.ccAuthReply.authorizationCode); } catch { String.Format("<br />authorizationCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />authorizedDateTime: {0}", reply.ccAuthReply.authorizedDateTime); } catch { String.Format("<br />authorizedDateTime: {0}", "x"); } try { lblCatch.Text += String.Format("<br />avsCode: {0}", reply.ccAuthReply.avsCode); } catch { String.Format("<br />avsCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />avsCodeRaw: {0}", reply.ccAuthReply.avsCodeRaw); } catch { String.Format("<br />avsCodeRaw: {0}", "x"); } try { lblCatch.Text += String.Format("<br />cavvResponseCode: {0}", reply.ccAuthReply.cavvResponseCode); } catch { String.Format("<br />cavvResponseCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />cavvResponseCodeRaw: {0}", reply.ccAuthReply.cavvResponseCodeRaw); } catch { String.Format("<br />cavvResponseCodeRaw: {0}", "x"); } try { lblCatch.Text += String.Format("<br />cvCode: {0}", reply.ccAuthReply.cvCode); } catch { String.Format("<br />cvCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />cvCodeRaw: {0}", reply.ccAuthReply.cvCodeRaw); } catch { String.Format("<br />cvCodeRaw: {0}", "x"); } try { lblCatch.Text += String.Format("<br />merchantAdviceCode: {0}", reply.ccAuthReply.merchantAdviceCode); } catch { String.Format("<br />merchantAdviceCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />merchantAdviceCodeRaw: {0}", reply.ccAuthReply.merchantAdviceCodeRaw); } catch { String.Format("<br />merchantAdviceCodeRaw: {0}", "x"); } try { lblCatch.Text += String.Format("<br />processorResponse: {0}", reply.ccAuthReply.processorResponse); } catch { String.Format("<br />processorResponse: {0}", "x"); } try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.ccAuthReply.reasonCode); } catch { String.Format("<br />reasonCode: {0}", "x"); } try { lblCatch.Text += String.Format("<br />reconciliationID: {0}", reply.ccAuthReply.reconciliationID); } catch { String.Format("<br />reconciliationID: {0}", "x"); } lblCatch.Text += "<hr />"; try { lblCatch.Text += String.Format("<br />missingField: {0}", reply.missingField.Length); } catch { String.Format("<br />missingField: {0}", "x"); } } catch (Exception ex) { lblCatch.Text += String.Format("<table class='table_error'>" + "<tr><td>Error<td/><td>{0}</td></tr>" + "<tr><td>Message<td/><td>{1}</td></tr>" + "<tr><td>StackTrace<td/><td>{2}</td></tr>" + "<tr><td>Source<td/><td>{3}</td></tr>" + "<tr><td>InnerException<td/><td>{4}</td></tr>" + "<tr><td>Data<td/><td>{5}</td></tr>" + "</table>" , "Tokenization" //0 , ex.Message //1 , ex.StackTrace //2 , ex.Source //3 , ex.InnerException //4 , ex.Data //5 , ex.HelpLink , ex.TargetSite ); } }
protected void CyberSource_Customer_Profile_Create() { try { #region CyberSource Tokenization /// Here we create the Credit Card Tokenization - in CyberSource this is actually a Subscription ID /// We only do this for approved transactions /// Include the following fields in the request: /// merchantID /// merchantReferenceCode /// recurringSubscriptionInfo_frequency —set to on-demand. /// paySubscriptionCreateService_paymentRequestID —include the requestID value returned from the original transaction request. /// /// See Appendix A, "API Fields," on page 34 for detailed descriptions of the request and /// reply fields. See Appendix B, "Examples," on page 62 for a request and reply example. RequestMessage request = new RequestMessage(); request.paySubscriptionCreateService = new PaySubscriptionCreateService(); request.paySubscriptionCreateService.run = "true"; // Tokenization? // request.merchantID = merchantID.Text; // This is not needed since it should automatically pull it from the confg [capture in DB anyways...] RecurringSubscriptionInfo SubscriptionInfo = new RecurringSubscriptionInfo(); SubscriptionInfo.frequency = "on-demand"; request.recurringSubscriptionInfo = SubscriptionInfo; request.merchantReferenceCode = merchantReferenceCode.Text; int cbAge = 0; Int32.TryParse(age.Text, out cbAge); if (cbAge > 60) { request.paySubscriptionCreateService.paymentRequestID = paymentRequestID2.Text; } else { request.paySubscriptionCreateService.paymentRequestID = paymentRequestID.Text; } ReplyMessage reply = SoapClient.RunTransaction(request); string template = ghCyberSource.GetTemplate(reply.decision.ToUpper()); string content = ""; try { content = ghCyberSource.GetContent(reply); } catch { content = "error"; } txtTemplate.Text = template.ToString(); txtContent.Text = content.ToString(); if (content.ToString() == "Approved") { txtContent.BackColor = System.Drawing.Color.Aqua; } else { txtContent.BackColor = System.Drawing.Color.Orange; } txtReply.Text = reply.ToString(); lblCatch.Text += String.Format("<br />decision: {0}", reply.decision.ToUpper()); try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.reasonCode); } catch { } try { lblCatch.Text += String.Format("<br />reasonCode: {0}", reply.paySubscriptionCreateReply.reasonCode); } catch { } try { lblCatch.Text += String.Format("<br />subscriptionID: {0}", reply.paySubscriptionCreateReply.subscriptionID); } catch { } try { lblCatch.Text += String.Format("<br />missingField: {0}", reply.missingField.Length); } catch { String.Format("<br />missingField: {0}", "x"); } String sp_subscriptionid = reply.paySubscriptionCreateReply.subscriptionID; String sp_decision = reply.decision.ToUpper(); Int32 sp_callid = -1; Int32 sp_donationid = -1; Int32 sp_authid = -1; Int32 sp_authorid = -1; Int32 sp_reasoncode = -1; Int32 sp_status = -1; Int32 sp_actionid = -1; Int32.TryParse(callid.Text, out sp_callid); Int32.TryParse(donationid.Text, out sp_donationid); Int32.TryParse(authid.Text, out sp_authid); Int32.TryParse(authorid.Text, out sp_authorid); Int32.TryParse(reply.paySubscriptionCreateReply.reasonCode, out sp_reasoncode); sp_actionid = 10330001; // Tokenization - Actions | Create New Token if (sp_decision == "ACCEPT") { sp_status = 10340001; // Tokenization - Status | Success } else if (sp_decision == "REJECT") { sp_status = 10340002; // Tokenization - Status | Failure } else { sp_status = 10340003; // Tokenization - Status | Error } #endregion CyberSource Tokenization #region CyberSource Tokenization - Log lblTokenization.Text = "Testing..."; Int32 sp_tokenid = CyberSource_Customer_Profile_Insert(sp_subscriptionid, sp_callid, sp_donationid, sp_authid, sp_status); // Need to log it regardless // Log has the decision and reasoncode if (sp_tokenid != -1) { lblTokenization.Text = "Testing..."; CyberSource_Customer_Profile_Insert_Log(sp_tokenid, sp_authorid, sp_actionid, sp_status, sp_decision, sp_reasoncode); } #endregion CyberSource Tokenization - Log } catch (Exception ex) { lblCatch.Text += String.Format("<table class='table_error'>" + "<tr><td>Error<td/><td>{0}</td></tr>" + "<tr><td>Message<td/><td>{1}</td></tr>" + "<tr><td>StackTrace<td/><td>{2}</td></tr>" + "<tr><td>Source<td/><td>{3}</td></tr>" + "<tr><td>InnerException<td/><td>{4}</td></tr>" + "<tr><td>Data<td/><td>{5}</td></tr>" + "</table>" , "Tokenization" //0 , ex.Message //1 , ex.StackTrace //2 , ex.Source //3 , ex.InnerException //4 , ex.Data //5 , ex.HelpLink , ex.TargetSite ); } }