Как я могу получить следующее представление для загрузки после того, как мой контроллер получает и обрабатывает перенаправление? - PullRequest
0 голосов
/ 21 мая 2019

Я создаю сайт электронной коммерции, который использует Hosted Payment из Vantiv Express Interface.Экран ввода карты Vantiv загружается в iframe и корректно отправляется на проверку.

Контроллер, прикрепленный к URL-адресу возврата, который я предоставляю во время транзакции, получает перенаправление, обрабатывает его и пересылает в представление, которое должен увидеть клиент.Следующее представление, показывающее окончательное подтверждение заказа клиенту, не загружается.

Я пробовал это на localhost и на моем dev-сервере с одинаковыми результатами.Я также пытался перехватить любой редирект с использованием javascript, но ничего не зарегистрировано.

Мои методы Controller

@GetMapping("/checkout/payment/confirm")
public ModelAndView confirmCardData(ModelMap model,
    @RequestParam("HostedPaymentStatus") String paymentStatus,
    @RequestParam("TransactionSetupID") String TransactionSetupID,
    @RequestParam("TransactionID") String TransactionID,
    @RequestParam("ExpressResponseCode") String ExpressResponseCode,
    @RequestParam("ExpressResponseMessage") String ExpressResponseMessage,
    @RequestParam("AVSResponseCode") String AVSResponseCode,
    @RequestParam("CVVResponseCode") String CVVResponseCode,
    @RequestParam("ApprovalNumber") String ApprovalNumber,
    @RequestParam("LastFour") String LastFour,
    @RequestParam(name = "ValidationCode", required = false) String ValidationCode,
    @RequestParam(name = "CardLogo", required = false) String CardLogo,
    @RequestParam(name = "ApprovedAmount", required = false) String ApprovedAmount,
    @RequestParam(name = "ServicesID", required = false) String ServicesID,
    @RequestParam(name = "PaymentAccountID", required = false) String PaymentAccountID,
    @RequestParam(name = "CommercialCard", required = false) String CommercialCard,
    @RequestParam(name = "ResponseCode", required = false) String ResponseCode,
    @RequestParam(name = "TipAmount", required = false) String TipAmount,
    @RequestParam(name = "BillingAddress1", required = false) String BillingAddress1,
    @RequestParam(name = "BillingZipCode", required = false) String BillingZipCode,
    @RequestParam(name ="Bin", required = false) String Bin,
    @RequestParam(name = "Entry", required = false) String Entry,

    HttpServletRequest request,
    HttpServletResponse response) {
  CartData cart = cartService.getCart(customer, request, response);
  model.addAttribute("billingAddress", new BillingAddress(cart.getAddressData()));
  model.addAttribute("cart", cart);
  model.addAttribute("cartItemCount", cart.getItems().size());
  model.addAttribute("guest", false);
  model.addAttribute("address", false);
  model.addAttribute("shipMethods", false);
  model.addAttribute("payment", true);
  model.addAttribute("confirmCard", true);
  return new ModelAndView("forward:/checkout/ready", model);
}

@GetMapping("/checkout/ready")
public String getCheckoutWithCardData(Model model,
  @ModelAttribute("customer") Customer customer,
  HttpServletRequest request,
  HttpServletResponse response) {
    CartData cart = cartService.getCart(customer, request, response);
    cart.calculateTotal();
    model.addAttribute("cart", cart);
  return "checkout/checkout";
}  

HTML-код, в котором находится iframe

<div class="col-7">
  <div class="h6">Select Payment Method:</div>
  <form id="paymentMethod" th:object="${billingAddress}">
    <div class="custom-control custom-radio">
      <input type="radio" id="bid" required name="paymentMethod" class="custom-control-input payment-method">
      <label class="custom-control-label" for="bid">Submit as Bid Only</label>
    </div>
    <div class="custom-control custom-radio">
      <input type="radio" id="billAccount" name="paymentMethod" class="custom-control-input payment-method">
      <label class="custom-control-label" for="billAccount">Bill to Account</label>
    </div>
    <div class="custom-control custom-radio">
        <input type="radio" id="creditCard" name="paymentMethod" class="custom-control-input payment-method">
        <label class="custom-control-label" for="creditCard">Credit Cart</label>
      </div>
    <div id="billingAddressDetails" class="mt-2 d-none">
      <div class="form-check">
        <input class="form-check-input" name="useSameAddress" type="checkbox" value="" id="useSameAddress" th:checked="${cart.addressData.shippingMatchesBilling}">
        <label class="form-check-label" for="useSameAddress">
          Use Shipping Address
        </label>
      </div>
      <div class="form-group col-6 no-pad mt-2">
        <label>Name on Card</label>
        <input  type="text" class="form-control" id="cardHolder" th:field="*{billingName}" name="cardHolder" required placeholder="Name on Card">
      </div>
      <div id="billingAddress" class="mt-2 d-none">
        <div class="form-group">
          <label for="address">Address</label>
          <input type="text" class="form-control" id="cardAddress" th:field="*{billingAddress1}" name="address" placeholder="1234 Main St">
        </div>
        <div class="form-row">
          <div class="form-group col-md-6">
            <label for="city">City</label>
            <input type="text" class="form-control" id="cardCity" th:field="*{billingCity}" name="city" required>
          </div>
          <div class="form-group col-md-4">
            <label for="state">State</label>
            <select id="cardState" class="form-control" name="state" required th:field="*{billingState}">

            </select>
          </div>
          <div class="form-group col-md-2">
            <label for="zip">Zip</label>
            <input type="text" class="form-control" id="cardZip" th:field="*{billingZipcode}" name="zip" required>
            <input type="hidden" name="billingEmail" th:field="*{billingEmail}">
            <input type="hidden" name="billingPhone" th:field="*{billingPhone}">

          </div>
        </div>
      </div>
      <div class="form-row">
        <button type="submit" id="enterCard" class="btn btn-success btn-block w-75">Enter Credit Card</button>
      </div>
    </div>
  </form>
  <div id="cardInput" class="d-none">
    <iframe src="" class="w-100" ></iframe>
  </div>
</div>

iframeдолжен вернуть перенаправление, обработаться связанным контроллером и перейти к следующему представлению.IDE не показывает ошибок в консоли, но консоль браузера показывает ошибку

Load denied by X-Frame-Options: http://localhost:8082/checkout/payment/confirm?HostedPaymentStatus=Complete&TranDT=2019-05-20%2020:12:38 does not permit framing

или

Refused to display 'http://localhost:8082/checkout/payment/confirm?HostedPaymentStatus=Complete&TranDT=2019-05-20%2020:36:51' in a frame because it set 'X-Frame-Options' to 'deny'.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...