예제 #1
0
 /**
  * Stazeni vypisu pohybu na uctu
  *
  * Ve vypisu jsou pohyby vytvorene mezi datem dateFrom do data dateTo, vcetne techto datumu
  *
  * @param String $dateFrom - datum, od ktereho se vypis generuje
  * @param String $dateTo - datum, do ktereho se vypis generuje
  * @param float $targetGoId - identifikator prijemnce - GoId
  * @param String $currency - mena uctu, ze ktereho se vypis pohybu ziskava
  * @param string $contentType - format vypisu - podporovane typt - TYPE_CSV, TYPE_XLS, TYPE_ABO, implicitni je hodnota TYPE_CSV
  * @param string $secureKey - kryptovaci klic prideleny GoPay
  * @return string
  */
 public function getAccountStatement($dateFrom, $dateTo, $targetGoId, $currency, $secureKey, $contentType)
 {
     $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatStatementRequest($dateFrom, $dateTo, $targetGoId, $currency, $secureKey)), $secureKey);
     $filename = GopayConfig::getAccountStatementURL();
     $filename .= "?statementRequest.dateFrom=" . $dateFrom;
     $filename .= "&statementRequest.dateTo=" . $dateTo;
     $filename .= "&statementRequest.targetGoId=" . $targetGoId;
     $filename .= "&statementRequest.currency=" . $currency;
     $filename .= "&statementRequest.contentType=" . $contentType;
     $filename .= "&statementRequest.encryptedSignature=" . $encryptedSignature;
     echo $filename;
     $handle = fopen($filename, "r");
     $contents = "";
     if (!empty($handle)) {
         while (!feof($handle)) {
             $contents .= fread($handle, 8192);
         }
         fclose($handle);
     }
     return $contents;
 }
예제 #2
0
 /**
  * Pretypovani datoveho typu boolean pro webovou sluzbu
  *
  * @param boolean $boolean
  *
  * @return integer (0|1), v pripade nevalidniho zadani se vraci ""
  */
 public static function castBooleanForWS($boolean)
 {
     $boolean = GopayHelper::castString2Boolean($boolean);
     if ($boolean === FALSE) {
         return 0;
     } else {
         if ($boolean === TRUE) {
             return 1;
         } else {
             return "";
         }
     }
 }
예제 #3
0
<?php

include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/gopay.php';
require_once _PS_MODULE_DIR_ . 'gopay/gopay_tools.php';
$gopayTools = new GopayTools();
$returnedPaymentSessionId = $_GET['paymentSessionId'];
$returnedGoId = $_GET['eshopGoId'];
$returnedOrderId = $_GET['variableSymbol'];
$returnedEncryptedSignature = $_GET['encryptedSignature'];
$goId = trim(Configuration::get('GOID'));
$gopaySecret = trim(Configuration::get('GOPAY_SECRET'));
$infopageUrl = trim(Configuration::get('GOPAY_INFOPAGE_URL'));
$order = new Order($returnedOrderId);
if (isset($order->id)) {
    $amount = round($order->total_paid * 100);
    $productNameConcat = $gopayTools->concatProductsNames($order);
    if (GopayHelper::checkPaymentIdentity($returnedGoId, $returnedPaymentSessionId, $returnedOrderId, $returnedEncryptedSignature, $goId, $order->id, $gopaySecret)) {
        $result = GopaySoap::isEshopPaymentDone($returnedPaymentSessionId, $goId, $order->id, $amount, $productNameConcat, $gopaySecret);
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        exit(0);
    }
    if ($order->getCurrentState() == _PS_OS_GOPAY_ || $order->getCurrentState() == _PS_OS_OUTOFSTOCK_) {
        $gpErrors = $gopayTools->processPayment($result, $order->id);
    }
} else {
    header('HTTP/1.1 500 Internal Server Error');
    exit(0);
}
예제 #4
0
 function hookHome($params)
 {
     global $smarty;
     /* get params from URL */
     if (isset($_GET['gp_errors'])) {
         $gpErrors = $_GET['gp_errors'];
         if ($_GET['gp_errors'] == 'faultyPaymentIdentity') {
             $gpErrors = 'Nepodařilo se ověřit identitu platby.<br />Kontaktujte e-shop.';
         }
         if ($_GET['gp_errors'] == 'paymentCreationFailed') {
             $gpErrors = 'Nepodařilo se vytvořit platbu GoPay.<br />Zkontrolujte konfiguraci platebního modulu GoPay.';
         }
         if ($_GET['gp_errors'] == 'czk') {
             $gpErrors = 'E-shop nemá nastavenou českou měnu s platným ISO kódem CZK.';
         }
         if ($_GET['gp_errors'] == 'paymentNotVerified') {
             $gpErrors = 'Platba nebyla ověřena.';
         }
         if ($_GET['gp_errors'] == 'undefinedOrderFaultyState') {
             $gpErrors = 'Objednávka nebyla nalezena nebo je v chybném stavu.';
         }
         if ($_GET['gp_errors'] == 'alreadyClosed') {
             $gpErrors = 'Objednávka již byla uzavřena. Vyberte zboží znovu.';
         }
         if ($_GET['gp_errors'] == 'canceled') {
             $gpErrors = GopayHelper::getResultMessage("CANCELED");
         }
         if ($_GET['gp_errors'] == "WAITING") {
             $gpErrors = GopayHelper::getResultMessage("WAITING");
         }
         if ($_GET['gp_errors'] == "WAITING_OFFLINE") {
             $gpErrors = GopayHelper::getResultMessage("WAITING_OFFLINE");
         }
         $smarty->assign('gpErrors', $gpErrors);
     }
     if (isset($_GET['paymentState'])) {
         $paymentState = $_GET['paymentState'];
         if ($paymentState == "done") {
             $paymentState = GopayHelper::getResultMessage("PAYMENT_DONE");
         }
         $smarty->assign('paymentState', $paymentState);
     }
     return $this->display(__FILE__, 'templates/infopage.tpl');
 }
예제 #5
0
파일: pay.php 프로젝트: greench/prestashop
     $firstName = $customer->firstname;
     $lastName = $customer->lastname;
     $city = $address->city;
     $street = $address->address1;
     $postalCode = $address->postcode;
     $email = $customer->email;
     $phoneNumber = $address->phone;
     $countryId = $address->id_country;
     $country = new Country($countryId);
     $convertedCountryCode = GopayTools::getConvertedCountryCode($country->iso_code);
 }
 if (isset($order)) {
     // vytvoreni platby
     $paymentSessionId = GopaySoap::createCustomerEshopPayment($goId, $productNameConcat, $amount, $orderId, $successUrl, $failedUrl, $gopaySecret, $paymentChannels, $firstName, $lastName, $city, $street, $postalCode, $convertedCountryCode, $email, $phoneNumber);
     if ($paymentSessionId > 0) {
         $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession($goId, $paymentSessionId, $gopaySecret)), $gopaySecret);
     } else {
         $gpErrors = 'paymentCreationFailed';
     }
 } else {
     $gpErrors = 'undefinedOrderFaultyState';
 }
 if (empty($gpErrors)) {
     $redirectUrl = "{$gwUrl}?sessionInfo.paymentSessionId={$paymentSessionId}&sessionInfo.eshopGoId={$goId}&sessionInfo.encryptedSignature={$encryptedSignature}";
     if (isset($param)) {
         $redirectUrl .= "{$param}";
     }
     Tools::redirectLink($redirectUrl);
 } else {
     Tools::redirectLink("{$infopageUrl}?gp_errors={$gpErrors}");
 }
예제 #6
0
 /**
  * Kontrola provedeni platby uzivatele
  * - verifikace parametru z redirectu
  * - kontrola provedeni platby
  *
  * @param long $paymentSessionId - identifikator platby
  * @param long $eshopGoId - identifikator uzivatele - GoId
  * @param string $variableSymbol - identifikator objednavky
  * @param int $totalPriceInCents - celkova cena objednavky v halerich
  * @param string $productName - popis objednavky zobrazujici se na platebni brane
  * @param string $secret - kryptovaci heslo pridelene uzivateli
  *
  * @return $result
  *  result["code"] 		  - kod vysledku volani
  *  result["description"] - popis vysledku volani
  */
 public static function isBuyerPaymentDone($paymentSessionId, $buyerGoId, $variableSymbol, $totalPriceInCents, $productName, $secret)
 {
     $result = array();
     try {
         //inicializace WS
         ini_set("soap.wsdl_cache_enabled", "0");
         $go_client = new SoapClient(GopayConfig::ws(), array());
         //sestaveni dotazu na stav platby
         $sessionEncryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession((double) $buyerGoId, (double) $paymentSessionId, $secret)), $secret);
         $payment_session = array("buyerGoId" => (double) $buyerGoId, "paymentSessionId" => (double) $paymentSessionId, "encryptedSignature" => $sessionEncryptedSignature);
         /*
          * Kontrola stavu platby na strane GoPay prostrednictvim WS
          */
         $payment_status = $go_client->__call('paymentStatusGW2', array('paymentSessionInfo' => $payment_session));
         $result["description"] = $payment_status->resultDescription;
         $result["code"] = $payment_status->sessionState;
         /*
          * Kontrola zaplacenosti objednavky, verifikace parametru objednavky
          */
         if (!GopayHelper::checkBuyerPaymentStatus($payment_status, 'PAYMENT_DONE', (double) $buyerGoId, $variableSymbol, (int) $totalPriceInCents, $productName, $secret)) {
             /*
              * Platba neprobehla korektne
              */
             $result["code"] = GopayHelper::FAILED;
         }
     } catch (SoapFault $f) {
         /*
          * Chyba v komunikaci s GoPay serverem
          */
         $result["code"] = GopayHelper::FAILED;
         $result["description"] = GopayHelper::FAILED;
     }
     return $result;
 }
예제 #7
0
 /**
  * Sestaveni platebniho tlacitka jako odkazu
  * 
  *
  * @param float $buyerGoId - identifikace uzivatele - GoId uzivatele pridelene GoPay
  * @param int $totalPrice - cena objednavky v halerich
  * @param string $productName - nazev objednvky / zbozi
  * @param string $variableSymbol - identifikace akt. objednavky
  * @param string $successURL - URL, kam se ma prejit po uspesnem zaplaceni
  * @param string $failedURL - URL, kam se ma prejit po neuspesnem zaplaceni
  * @param string $secret - kryptovaci heslo pridelene uzivateli, urcene k podepisovani komunikace
  * @param string $iconUrl - URL ikony tlacitka - viz konstanty tridy 
  * 
  * @return HTML kod platebniho tlacitka
  */
 public static function createBuyerHref($buyerGoId, $totalPrice, $productName, $variableSymbol, $successURL, $failedURL, $secret, $iconUrl)
 {
     $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentCommand((double) $buyerGoId, $productName, (int) $totalPrice, $variableSymbol, $failedURL, $successURL, $secret)), $secret);
     $params = "";
     $params .= "paymentCommand.buyerGoId=" . $buyerGoId;
     $params .= "&paymentCommand.productName=" . urlencode($productName);
     $params .= "&paymentCommand.totalPrice=" . $totalPrice;
     $params .= "&paymentCommand.variableSymbol=" . urlencode($variableSymbol);
     $params .= "&paymentCommand.successURL=" . urlencode($successURL);
     $params .= "&paymentCommand.failedURL=" . urlencode($failedURL);
     $params .= "&paymentCommand.encryptedSignature=" . urlencode($encryptedSignature);
     $formBuffer = "";
     $formBuffer .= "<a target='_blank' href='" . GopayConfig::buyerBaseIntegrationURL() . "?" . $params . "' >";
     if (empty($iconUrl)) {
         $formBuffer .= " Zaplatit ";
     } else {
         $formBuffer .= " <img src='" . $iconUrl . "' border='0' style='border:none;'/> ";
     }
     $formBuffer .= "</a>";
     return $formBuffer;
 }
예제 #8
0
 /**
  * Castecne vraceni platby
  *
  * @param float $paymentSessionId - identifikator platby
  * @param float $amount - castka na vraceni
  * @param String $currency - mena
  * @param String $description - popis vraceni platby
  * @param float $targetGoId - identifikator prijemnce - GoId
  * @param string $secureKey - kryptovaci klic prideleny GoPay
  * @return string
  * @throws \Exception
  */
 public static function refundPaymentPartially($paymentSessionId, $amount, $currency, $description, $targetGoId, $secureKey)
 {
     try {
         //inicializace WS
         ini_set("soap.wsdl_cache_enabled", "0");
         $go_client = GopayConfig::createSoapClient();
         $sessionEncryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatRefundRequest((double) $targetGoId, (double) $paymentSessionId, $amount, $currency, $description, $secureKey)), $secureKey);
         $refundRequest = array("targetGoId" => (double) $targetGoId, "paymentSessionId" => (double) $paymentSessionId, "amount" => $amount, "currency" => $currency, "description" => $description, "encryptedSignature" => $sessionEncryptedSignature);
         $paymentResult = $go_client->__call("partiallyRefundPayment", array("refundRequest" => $refundRequest));
         if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) {
             throw new \Exception("payment not refunded [" . $paymentResult->resultDescription . "]");
         } else {
             if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) {
                 //vraceni platby bylo zarazeno ke zpracovani
                 throw new \Exception(GopayHelper::CALL_RESULT_ACCEPTED);
             }
         }
         return $paymentResult->paymentSessionId;
     } catch (\SoapFault $f) {
         /*
          * Chyba v komunikaci s GoPay serverem
          */
         throw new \Exception("SOAP error");
     }
 }