Esempio n. 1
0
 public function extendedCheckout(PaymentObjectInterface $paymentObj, $getUrlOnly = false)
 {
     $obj = new \stdClass();
     \Order\Order::getInstance()->validateOrder($paymentObj);
     // Must be in specific order for checksum ---------
     $obj->MerchantID = $this->getMerchantID();
     $obj->Timestamp = $this->getTimeStamp();
     $obj->Amount = $paymentObj->getAmount();
     $obj->Country = $paymentObj->getCountry();
     $obj->Currency = $paymentObj->getCurrency();
     $obj->Description = $paymentObj->getDescription();
     $obj->EndUserIP = $this->getIP();
     $obj->Issuer = $paymentObj->getIssuer();
     $obj->Language = $paymentObj->getLanguage();
     $obj->OrderID = $paymentObj->getOrderID();
     $obj->PaymentMethod = $paymentObj->getPaymentMethod();
     $obj->Reference = $paymentObj->getReference();
     $obj->URLCompleted = $this->getSuccessURL();
     $obj->URLError = $this->getErrorURL();
     $obj->XML = Order::getInstance()->createXML();
     // ------------------------------------------------
     $obj->Checksum = $this->generateChecksum($obj, $this->getSecretCode());
     $result = $this->client->CheckoutExtended(array('request' => $obj));
     /* store the checksum momentarily */
     $checksum = $result->CheckoutExtendedResult->Checksum;
     /* Replace the checksum in the data with secretCode to generate a new checksum */
     $result->CheckoutExtendedResult->Checksum = $this->getSecretCode();
     /* Verify response data */
     if ($checksum != $this->generateChecksum($result->CheckoutExtendedResult)) {
         throw new \Exception("Data could not be verified");
     }
     /* Return mister checksum */
     $result->CheckoutExtendedResult->Checksum = $checksum;
     /* Return just the payment URL if required */
     if ($getUrlOnly) {
         return $result->CheckoutExtendedResult->PaymentScreenURL;
     }
     $transactionObj = new TransactionObject();
     $transactionObj->setData($result->CheckoutExtendedResult);
     /* Default return all data */
     return $transactionObj;
 }
Esempio n. 2
0
File: index.php Progetto: Roma48/hw4
<?php

require_once __DIR__ . '/../../config/autoload.php';
use Entity\EntityManager;
use Order\Order;
session_start();
if (isset($_GET['card']) && isset($_GET['confirm']) && $_GET['confirm'] == true && isset($_SESSION['add-to-card'])) {
    foreach ($_SESSION['add-to-card'] as $product_id) {
        $order = new Order();
        $order->setUserId($_SESSION['user']);
        $order->setProductId($product_id);
        $add_order = new EntityManager();
        $add_order->insert($order);
    }
    unset($_SESSION['add-to-card']);
}
?>

<html>
<head>
    <title>Shop</title>

    <link rel="stylesheet" href="../css/style.css">

    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">