I am trying to integrate by embedding the iframe . The communicator page sends response to the events. When I click on the Pay button, the button is stuck showing "processing.." This happens when the showreceipt is set to "false", but when I set it to true, the payment is processed and shows the receipt page.
After clicking Pay button I want it to be forwarded back to our site to display custom receipt after payment processing that is the reason for setting showreceipt to "false".
Does somebody have any thoughts or suggestions for this issue?
07-30-2019 09:46 PM
07-31-2019 09:34 AM
public class HomeController : Controller
{
IHostingEnvironment _env;
IConfiguration _config;
public HomeController(IHostingEnvironment env, IConfiguration config)
{
_env = env;
_config = config;
}
public IActionResult Index()
{
customerAddressType BillTo = new customerAddressType
{
address = "120 Sceneic Drive",
city = "Twinsburg ",
state = "OH",
zip = "14326",
firstName = "Sam",
lastName = "Donald",
country = "USA",
phoneNumber = "4454546589",
};
int CreditCardTransactionID = 121212;
decimal Amount = 100;
int OrderID = 1234567;
string IPAddress = "127.0.0.1";
int CustomerID = 5129999;
transactionTypeEnum transtype = transactionTypeEnum.authCaptureTransaction;
merchantAuthenticationType mat = new merchantAuthenticationType
{
name = _config.GetValue<string>("Authorize.Net:TransactionKey"),
ItemElementName = ItemChoiceType.transactionKey,
Item = _config.GetValue<string>("Authorize.Net:Password"),
};
string CancelURL;
string ReturnURL;
string URL;
string CommunicatorURL;
string PaymentPageURL;
string ShowReceipt = "false";
string HostURL = _config.GetValue<string>("RootURL");
switch ((_env.EnvironmentName ?? "").Trim().ToUpper())
{
case "DEVELOPMENT":
string NGrokPath = $"{HostURL}/Home";
CommunicatorURL = $"{NGrokPath}/Communicator";
CancelURL = $"{NGrokPath}/Cancel";
ReturnURL = $"{NGrokPath}/Returning";
PaymentPageURL = $"{NGrokPath}/";
URL = $"{NGrokPath}";
break;
case "STAGING":
case "PRODUCTION":
CommunicatorURL = $"{HostURL}/Home/Communicator";
CancelURL = $"{HostURL}/Home/Cancel";
ReturnURL = $"{HostURL}/Home/Returning";
PaymentPageURL = $"{HostURL}/";
ShowReceipt = "true";
break;
default:
return Error();
}
HostedPayment hp = new HostedPayment(mat, AuthorizeNet.Environment.SANDBOX);
HostedToken ht = hp.AttemptTransaction(CreditCardTransactionID, Amount, OrderID, IPAddress, CustomerID, null, false, transtype, BillTo, ReturnURL, CancelURL, CommunicatorURL, PaymentPageURL, ShowReceipt);
return View(ht);
}
public IActionResult Cancel()
{
return Content("Cancelled");
}
public IActionResult Returning()
{
return Content("Done!");
}
public IActionResult Communicator()
{
return View();
}
[Route("/Home/Empty1")]
[Route("/Home/Home/Empty1")]
public IActionResult Empty1()
{
return View();
}
[HttpPost]
public IActionResult WebHook()
{
string s = "";
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
s = reader.ReadToEnd();
}
System.Diagnostics.Debug.WriteLine("##### " + s);
return Ok();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
I used the suggestion in this link for now as a workaround. Also I want the json result to be pushed to webhook, if you could share any thoughts about that that would be helpful.
Thanks
Chitti
08-01-2019 07:27 AM - edited 08-01-2019 07:28 AM
08-02-2019 02:41 PM - edited 08-02-2019 02:43 PM
@Renaissance Sorry for the delay in responding. The Cancel button works, If I give CancelUrl it redirects to that Url. I use ngrok tunnel for testing as I cannot use the local host. The issue now is pushing the json data to our server for validation. Not sure how to do that in Asp.net MVC.
08-05-2019 02:18 PM
Did you ever work this out? I am now having the same issue on an integration I am working on. Very odd.
09-17-2019 01:44 PM
09-17-2019 05:58 PM