I figured it out.
1.
public async Task<IActionResult> ConfirmOrder(string formData)
call POS3DConfirm with returnURL = VirtualPOS3DResponse
2.
public IActionResult POS3DConfirm(OnlinePaymentCheckoutState model)
{
return View(model);
}
results will return to this page VirtualPOS3DResponse
3.
[HttpPost]
[IgnoreAntiforgeryToken]
public async Task<IActionResult> VirtualPOS3DResponse()
{
var messages = new List<string>();
var store = Services.StoreContext.CurrentStore;
try
{
Dictionary<string, object> pairs = _httpContextAccessor.HttpContext.Request.Form.Keys.ToDictionary(k => k, v => (object)_httpContextAccessor.HttpContext.Request.Form[v]);
SaleResponse response = VPOSClient.Sale3DResponse(new Sale3DResponseRequest
{
responseArray = pairs
}, await GetBankInfo(store.Id));
if (response.statu == CP.VPOS.Enums.SaleResponseStatu.Success)
{
return RedirectToAction(nameof(OnlinePaymentController.POS3DConfirmCompleted), "OnlinePayment");
}
else
{
Logger.Error(response.message);
NotifyError(response.message);
return RedirectToAction(nameof(CheckoutController.PaymentMethod), "Checkout" );
}
}
catch (Exception ex)
{
Logger.Error(ex.Message);
NotifyError(ex.Message);
return RedirectToAction(nameof(CheckoutController.PaymentMethod), "Checkout" );
}
}
Sessions cannot be read in this method. Need the Completed method
4.
public IActionResult POS3DConfirmCompleted(OnlinePaymentCheckoutState model)
{
return RedirectToAction(nameof(CheckoutController.Confirm), "Checkout", model);
}