<?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); }
$customerData = trim(Configuration::get('GOPAY_CUSTOMER_DATA')); if ($customerData == '1') { $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 {
public function hookPayment($params) { if (!$this->active) { return; } if (!$this->checkCurrency()) { return; } if (!$this->checkModuleCurrency()) { return $this->display(__FILE__, 'templates/gopay_check_config.tpl'); } global $smarty, $cookie; $param = ''; $payUrl = 'modules/gopay/pay.php'; $payMode = trim(Configuration::get('GOPAY_PAY_MODE')); // předvybraná platební metoda $preconfMethod = trim(Configuration::get('GOPAY_PRECONF_METHOD')); $paymentMethodList = GopaySoap::paymentMethodList(); $paymentMethods = array(); for ($i = 0; $i < count($paymentMethodList); $i++) { if ($preconfMethod == $paymentMethodList[$i]->code) { $param = "&paymentChannel=" . $paymentMethodList[$i]->code; } if (Configuration::get($paymentMethodList[$i]->code) == "1") { $paymentMethods[] = array('title' => $paymentMethodList[$i]->paymentMethod, 'logo' => $paymentMethodList[$i]->logo, 'code' => $paymentMethodList[$i]->code); } } $smarty->assign(array('payUrl' => $payUrl, 'cartId' => intval($params['cart']->id), 'param' => $param, 'paymentMethods' => $paymentMethods)); // singlechoice mode if ($payMode == 'single') { return $this->display(__FILE__, 'templates/gopay_single.tpl'); } else { return $this->display(__FILE__, 'templates/gopay_multi.tpl'); } }
/** * Vytvoreni standardni platby * * @param string $targetGoId - identifikator prijemce - GoId * @param string $productName - popis objednavky zobrazujici se na platebni brane * @param int $totalPriceInCents - celkova cena objednavky v halerich * @param string $currency - mena, ve ktere platba probiha * @param string $orderNumber - identifikator objednavky * @param string $successURL - URL stranky, kam je zakaznik presmerovan po uspesnem zaplaceni * @param string $failedURL - URL stranky, kam je zakaznik presmerovan po zruseni platby / neuspesnem zaplaceni * @param string $paymentChannels - pole platebnich kanalu, ktere se zobrazi na platebni brane * @param string $defaultPaymentChannel - platebni kanal, ktery se zobrazi (predvybere) na platebni brane po presmerovani * @param string $secureKey - kryptovaci klic prideleny prijemci * * Informace o zakaznikovi * @param string $firstName - Jmeno zakaznika * @param string $lastName - Prijmeni * * Adresa * @param string $city - Mesto * @param string $street - Ulice * @param string $postalCode - PSC * @param string $countryCode - Kod zeme. Validni kody jsou uvedeny ve tride CountryCode * @param string $email - Email zakaznika * @param string $phoneNumber - Tel. cislo * * @param string $p1 - volitelne parametry (max. 128 znaku). * @param string $p2 - volitelne parametry (max. 128 znaku). * @param string $p3 - volitelne parametry (max. 128 znaku). * @param string $p4 - volitelne parametry (max. 128 znaku). * * @param string $lang - jazyk plat. brany * Parametry jsou vraceny v nezmenene podobe jako soucast volani dotazu na stav platby $paymentStatus (viz metoda isPaymentDone) * * @return string paymentSessionId */ public static function createPayment($targetGoId, $productName, $totalPriceInCents, $currency, $orderNumber, $successURL, $failedURL, $paymentChannels, $defaultPaymentChannel, $secureKey, $firstName, $lastName, $city, $street, $postalCode, $countryCode, $email, $phoneNumber, $p1, $p2, $p3, $p4, $lang) { return GopaySoap::createBasePayment($targetGoId, $productName, $totalPriceInCents, $currency, $orderNumber, $successURL, $failedURL, FALSE, FALSE, NULL, NULL, NULL, $paymentChannels, $defaultPaymentChannel, $secureKey, $firstName, $lastName, $city, $street, $postalCode, $countryCode, $email, $phoneNumber, $p1, $p2, $p3, $p4, $lang); }