<?php

require_once '../include/Helpers.php';
require_once '../include/Config.php';
require_once '../backend/Client.php';
$logOutput = 'Log will be displayed here.';
if (isset($_GET["uxBtnCheck"]) && $_GET["uxBtnCheck"] != "") {
    $merchantId = $_GET["uxMerchantId"];
    $captureId = $_GET["uxCaptureId"];
    $client = new Client();
    $responseObject = $client->getCapture($captureId, $environment, $secretKey);
    $logOutput = print_r($responseObject, true);
    /*
      if (is_object($responseObject) && !empty($responseObject->body->transaction) && $responseObject->body->transaction->merchantOrderId == $merchantOrderId) {
    if ($_GET["uxMode"] == "Window") {
      $standAloneSnippet = 'window.open("' . $responseObject->body->links[1]->href . '");';
    } else if ($_GET["uxMode"] == "Iframe") {
      $iframeSnippet = '<iframe src="' . $responseObject->body->links[1]->href .
      '" id="ww-kassan-iframe" name="ww-kassan-iframe" class="loaded" frameborder="0" scrolling="no" style="width: 100%; min-height:' . 
      $_GET["iframeheight"] . 'px; -webkit-transition: min-height 0.15s; transition: min-height 0.15s;"></iframe>';
    }
    
    //print '<br><a target="_blank" href="' . $responseObject->body->links[1]->href . '">Stand alone</a>';
    //print '<br><a target="_blank" href="iframe.php?iframeurl=' . $responseObject -> body -> links[1] -> href . '&width=' . $_GET["iframewidth"] . '&height=' . $_GET["iframeheight"] . '">Iframe</a>';
    
    $logOutput = print_r($responseObject->body, true);
      } else {
    $logOutput = print_r($responseObject, true);
    
    print "<br><br>ERROR!<br><br>";
    print "<pre>";