diff --git a/composer.json b/composer.json
index 2af2b77..893d197 100644
--- a/composer.json
+++ b/composer.json
@@ -24,8 +24,7 @@
],
"require": {
"php": ">=5.3.2",
- "ext-soap": "*",
- "ext-mcrypt": "*",
+ "markette/gopay-api": "~2.5.0",
"nette/utils": "~2.2",
"nette/forms": "~2.2",
"nette/application": "~2.2"
diff --git a/src/Gopay/Api/CountryCode.php b/src/Gopay/Api/CountryCode.php
deleted file mode 100644
index a783b07..0000000
--- a/src/Gopay/Api/CountryCode.php
+++ /dev/null
@@ -1,259 +0,0 @@
-Děkujeme Vám za využití našich služeb.";
- const CANCELED_MESSAGE = "Platba byla zrušena.
Opakujte platbu znovu, prosím.";
- const AUTHORIZED_MESSAGE = "Platba byla autorizována, čeká se na dokončení. O provedení platby Vás budeme budeme neprodleně informovat pomocí emailu s potvrzením platby.";
- const REFUNDED_MESSAGE = "Platba byla vrácena.";
- const PAYMENT_METHOD_CHOSEN_ONLINE_MESSAGE = "Platba zatím nebyla provedena. O provedení platby Vás budeme neprodleně informovat pomocí emailu s potvrzením platby. Pokud neobdržíte do následujícího pracovního dne potvrzovací email o platbě, kontaktujte podporu GoPay na emailu podpora@gopay.cz.";
- const PAYMENT_METHOD_CHOSEN_OFFLINE_MESSAGE = "Platba zatím nebyla provedena. Na platební bráně GoPay jste získali platební údaje a na Váš email Vám byly zaslány informace k provedení platby. O provedení platby Vás budeme budeme neprodleně informovat pomocí emailu s potvrzením platby.";
- const PAYMENT_METHOD_CHOSEN_MESSAGE = "Platba zatím nebyla provedena. O provedení platby Vás budeme neprodleně informovat pomocí emailu s potvrzením platby.";
- const FAILED_MESSAGE = "V průběhu platby nastala chyba. Kontaktujte podporu GoPay na emailu podpora@gopay.cz.";
-
-
- /**
- * Ziskani korektniho hlaseni o stavu platby - po volani (GopaySoap::isPaymentDone)
- *
- * @param String $sessionState - stav platby. Hodnoty viz konstanty GopayHelper
- * @param String $sessionSubState - detailnejsi popis stavu platby
- *
- * @return String retezec popisujici stav platby
- */
- public static function getResultMessage($sessionState, $sessionSubState) {
-
- $result = "";
-
- if ($sessionState == GopayHelper::PAID) {
- $result = GopayHelper::PAID_MESSAGE;
-
- } else if ($sessionState == GopayHelper::CANCELED
- || $sessionState == GopayHelper::TIMEOUTED
- || $sessionState == GopayHelper::CREATED) {
- $result = GopayHelper::CANCELED_MESSAGE;
-
- } else if ($sessionState == GopayHelper::AUTHORIZED) {
- $result = GopayHelper::AUTHORIZED_MESSAGE;
-
- } else if ($sessionState == GopayHelper::REFUNDED) {
- $result = GopayHelper::REFUNDED_MESSAGE;
-
- } else if ($sessionState == GopayHelper::PAYMENT_METHOD_CHOSEN) {
- if (! empty($sessionSubState) && $sessionSubState == 101) {
- $result = GopayHelper::PAYMENT_METHOD_CHOSEN_ONLINE_MESSAGE;
-
- } else if (! empty($sessionSubState) && $sessionSubState == 102) {
- $result = GopayHelper::PAYMENT_METHOD_CHOSEN_OFFLINE_MESSAGE;
-
- } else {
- $result = GopayHelper::PAYMENT_METHOD_CHOSEN_MESSAGE;
-
- }
-
- } else {
- $result = GopayHelper::FAILED_MESSAGE;
- }
-
- return $result;
- }
-
- /**
- * Sestaveni retezce pro podpis platebniho prikazu.
- *
- * @param float $goId - identifikator prijemce prideleny GoPay
- * @param string $productName - popis objednavky zobrazujici se na platebni brane
- * @param float $totalPriceInCents - celkova cena objednavky v halerich
- * @param string $currency - identifikator meny platby
- * @param string $orderNumber - identifikator objednavky u prijemce
- * @param string $failedURL - URL stranky, kam je zakaznik presmerovan po zruseni platby / neuspesnem zaplaceni
- * @param string $successURL - URL stranky, kam je zakaznik presmerovan po uspesnem zaplaceni
- * @param int $preAuthorization - jedna-li se o predautorizovanou platbu true => 1, false => 0, null=>""
- * @param int $recurrentPayment - jedna-li se o opakovanou platbu true => 1, false => 0, null=>""
- * @param date $recurrenceDateTo - do kdy se ma opakovana platba provadet
- * @param string $recurrenceCycle - frekvence opakovane platby - mesic/tyden/den
- * @param int $recurrencePeriod - pocet jednotek opakovani ($recurrencePeriod=3 ~ opakování jednou za tři jednotky (mesic/tyden/den))
- * @param string $paymentChannels - platebni kanaly
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatPaymentCommand($goId,
- $productName,
- $totalPriceInCents,
- $currency,
- $orderNumber,
- $failedURL,
- $successURL,
- $preAuthorization,
- $recurrentPayment,
- $recurrenceDateTo,
- $recurrenceCycle,
- $recurrencePeriod,
- $paymentChannels,
- $secureKey) {
-
- $preAuthorization = GopayHelper::castBooleanForWS($preAuthorization);
- $recurrentPayment = GopayHelper::castBooleanForWS($recurrentPayment);
-
- return $goId . "|" . trim($productName) . "|" . $totalPriceInCents . "|" . trim($currency) . "|" . trim($orderNumber) . "|" . trim($failedURL) . "|" . trim($successURL) . "|" . $preAuthorization . "|" . $recurrentPayment . "|" . trim($recurrenceDateTo)."|".trim($recurrenceCycle) . "|" . trim($recurrencePeriod) . "|" . trim($paymentChannels) . "|" . $secureKey;
- }
-
- /**
- * Sestaveni retezce pro podpis vysledku stavu platby.
- *
- * @param float $goId - identifikator prijemce prideleny GoPay
- * @param string $productName - popis objednavky zobrazujici se na platebni brane
- * @param float $totalPriceInCents - celkova cena objednavky v halerich
- * @param string $currency - identifikator meny platby
- * @param string $orderNumber - identifikator objednavky u prijemce
- * @param float $parentPaymentSessionId - id puvodni platby pri opakovane platbe
- * @param int $preAuthorization - jedna-li se o predautorizovanou platbu true => 1, false => 0, null=>""
- * @param int $recurrentPayment - jedna-li se o opakovanou platbu true => 1, false => 0, null=>""
- * @param string $result - vysledek volani (CALL_COMPLETED / CALL_FAILED)
- * @param string $sessionState - stav platby - viz GopayHelper
- * @param string $sessionSubState - podstav platby - detailnejsi popis stavu platby
- * @param string $paymentChannel - pouzita platebni metoda
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatPaymentStatus($goId,
- $productName,
- $totalPriceInCents,
- $currency,
- $orderNumber,
- $recurrentPayment,
- $parentPaymentSessionId,
- $preAuthorization,
- $result,
- $sessionState,
- $sessionSubState,
- $paymentChannel,
- $secureKey) {
-
- $preAuthorization = GopayHelper::castBooleanForWS($preAuthorization);
- $recurrentPayment = GopayHelper::castBooleanForWS($recurrentPayment);
-
- return $goId . "|" . trim($productName) . "|" . $totalPriceInCents . "|" . $currency . "|" . trim($orderNumber) . "|" . $recurrentPayment . "|" . $parentPaymentSessionId . "|" . $preAuthorization . "|" . $result . "|" . $sessionState . "|" . $sessionSubState . "|" . $paymentChannel . "|" . $secureKey;
- }
-
-
- /**
- * Sestaveni retezce pro podpis platební session pro přesměrování na platební bránu GoPay
- * nebo volání GoPay služby stav platby
- *
- * @param float $goId - identifikator prijemce prideleny GoPay
- * @param float $paymentSessionId - identifikator platby na GoPay
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatPaymentSession($goId, $paymentSessionId, $secureKey) {
-
- return $goId . "|" . $paymentSessionId . "|" . $secureKey;
- }
-
- /**
- * Sestaveni retezce pro podpis parametru platby (paymentIdentity)
- *
- * @param float $goId - identifikator prijemce prideleny GoPay
- * @param float $paymentSessionId - identifikator platby na GoPay
- * @param float $parentPaymentSessionId - id puvodni platby pri opakovane platbe
- * @param string $orderNumber - identifikator platby u prijemce
- * @param string $secureKey - kryptovaci heslo pridelene prijemci, urcene k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatPaymentIdentity($goId,
- $paymentSessionId,
- $parentPaymentSessionId,
- $orderNumber,
- $secureKey) {
-
- if ($parentPaymentSessionId == null) {
- $parentPaymentSessionId = "";
- }
-
- return $goId . "|" . $paymentSessionId . "|" . $parentPaymentSessionId . "|" . trim($orderNumber) . "|" . $secureKey;
- }
-
- /**
- * Sestaveni retezce pro podpis.
- *
- * @param float $paymentSessionId - identifikator platby na GoPay
- * @param string $result - vysledek volani
- * @param string $secureKey - kryptovaci klic prideleny uzivateli, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatPaymentResult($paymentSessionId, $result, $secureKey) {
-
- return $paymentSessionId . "|" . trim($result) . "|" . $secureKey;
- }
-
-
- /**
- * Sestaveni retezce pro stazeni vypisu plateb uzivatele
- *
- * @param date $dateFrom - datum (vcetne), od ktereho se generuje vypis
- * @param date $dateTo - datum (vcetne), do ktereho se generuje vypis
- * @param float $targetGoId - identifikator uzivatele prideleny GoPay
- * @param string $currency - mena uctu, ze ktereho se vypis pohybu ziskava
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatStatementRequest($dateFrom,
- $dateTo,
- $targetGoId,
- $currency,
- $secureKey) {
-
- return $dateFrom . "|" . $dateTo . "|" . $targetGoId . "|" . $currency . "|" . $secureKey;
- }
-
- /**
- * Sestaveni retezce pro podpis pozadavku opakovane platby.
- *
- * @param float $parentPaymentSessionId - id puvodni platby pri opakovane platbe
- * @param float $targetGoId - identifikator prijemce prideleny GoPay
- * @param string $orderNumber - identifikator platby u prijemce
- * @param float $totalPriceInCents - celkova cena objednavky v halerich
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatRecurrenceRequest($parentPaymentSessionId,
- $orderNumber,
- $totalPriceInCents,
- $targetGoId,
- $secureKey) {
-
- return $parentPaymentSessionId . "|" . $targetGoId . "|" . $orderNumber . "|" . $totalPriceInCents . "|" . $secureKey;
- }
-
- /**
- * Sestaveni retezce pro podpis pozadavku refundace platby.
- *
- * @param float $targetGoId - identifikator prijemce prideleny GoPay
- * @param float $paymentSessionId - identifikator platby na GoPay
- * @param string $amount - castka na vraceni
- * @param string $currency - identifikator meny platby
- * @param string $description - popis refundace
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return retezec pro podpis
- */
- public static function concatRefundRequest($targetGoId,
- $paymentSessionId,
- $amount,
- $currency,
- $description,
- $secureKey) {
-
- return $targetGoId . "|" . $paymentSessionId . "|" . $amount . "|" . $currency . "|" . $description . "|" . $secureKey;
- }
-
- /**
- * Sifrovani dat 3DES
- *
- * @param string $data - retezec, ktery se sifruje
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return sifrovany obsah v HEX forme
- */
- public static function encrypt($data, $secureKey) {
- $td = mcrypt_module_open (MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
- $mcrypt_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
- mcrypt_generic_init ($td, substr($secureKey, 0, mcrypt_enc_get_key_size($td)), $mcrypt_iv);
- $encrypted_data = mcrypt_generic ($td, $data);
- mcrypt_generic_deinit ($td);
- mcrypt_module_close ($td);
-
- return bin2hex($encrypted_data);
- }
-
- /**
- * desifrovani
- *
- * @param string $data - zasifrovana data
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- * @return desifrovany retezec
- */
- public static function decrypt($data, $secureKey) {
- $td = mcrypt_module_open (MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
- $mcrypt_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
- mcrypt_generic_init ($td, substr($secureKey, 0, mcrypt_enc_get_key_size($td)), $mcrypt_iv);
-
- $decrypted_data = mdecrypt_generic($td, GopayHelper::convert($data));
- mcrypt_generic_deinit ($td);
- mcrypt_module_close ($td);
-
- return Trim($decrypted_data);
-
- }
-
- /**
- * hash SHA1 dat
- *
- * @param string $data - data k hashovani
- * @return otisk dat SHA1
- */
- public static function hash($data) {
- if (function_exists("sha1")==true) {
- $hash = sha1($data, true);
-
- } else {
- $hash = mhash(MHASH_SHA1,$data);
- }
-
- return bin2hex($hash);
- }
-
- /**
- * konverze z HEX -> string
- *
- * @param string $hexString - data k konverzi
- * @return konverze z HEX -> string
- */
- public static function convert($hexString) {
-
- $hexLength = strlen($hexString);
-
- // vstup musi byt HEX
- if ($hexLength % 2 != 0 || preg_match("/[^0-9a-fA-F]/", $hexString)) return FALSE;
-
- $binString = "";
- for ($x = 0; $x < $hexLength/2; $x++) {
- $binString .= chr(hexdec(substr($hexString, 2 * $x, 2)));
-
- }
-
- return $binString;
- }
-
- /**
- * Kontrola stavu platby proti internim udajum objednavky - verifikace podpisu.
- *
- * @param mixed $paymentStatus - vysledek volani paymentStatus
- * @param string $sessionState - ocekavany stav paymentSession (WAITING, PAYMENT_DONE)
- * @param float $goId - identifikator prijemce prideleny GoPay
- * @param string $orderNumber - identifikace akt. objednavky u prijemce
- * @param float $totalPriceInCents - cena objednavky v halerich
- * @param string $currency - identifikator meny platby
- * @param string $productName - nazev objednavky / zbozi
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- *
- * @throw Exception
- */
- public static function checkPaymentStatus($paymentStatus,
- $sessionState,
- $goId,
- $orderNumber,
- $totalPriceInCents,
- $currency,
- $productName,
- $secureKey) {
-
- if (! empty($paymentStatus)) {
-
- if ( $paymentStatus->result != GopayHelper::CALL_COMPLETED) {
- throw new Exception("PS invalid call state state");
- }
-
- if ( $paymentStatus->sessionState != $sessionState) {
- throw new Exception("PS invalid session state");
- }
-
- if (trim($paymentStatus->orderNumber) != trim($orderNumber)) {
- throw new Exception("PS invalid VS");
- }
-
- if (trim($paymentStatus->productName) != trim($productName)) {
- throw new Exception("PS invalid PN");
- }
-
- if ($paymentStatus->targetGoId != $goId) {
- throw new Exception("PS invalid GoID");
- }
-
- if ($paymentStatus->totalPrice != $totalPriceInCents) {
- throw new Exception("PS invalid price");
- }
-
- if ($paymentStatus->currency != $currency) {
- throw new Exception("PS invalid currency");
- }
-
- } else {
- throw new Exception("None payment status");
- }
- /*
- * Kontrola podpisu objednavky
- */
- $hashedSignature = GopayHelper::hash(
- GopayHelper::concatPaymentStatus(
- $paymentStatus->targetGoId,
- $paymentStatus->productName,
- $paymentStatus->totalPrice,
- $paymentStatus->currency,
- $paymentStatus->orderNumber,
- $paymentStatus->recurrentPayment,
- $paymentStatus->parentPaymentSessionId,
- $paymentStatus->preAuthorization,
- $paymentStatus->result,
- $paymentStatus->sessionState,
- $paymentStatus->sessionSubState,
- $paymentStatus->paymentChannel,
- $secureKey)
- );
-
- $decryptedHash = GopayHelper::decrypt($paymentStatus->encryptedSignature, $secureKey);
-
- if ($decryptedHash != $hashedSignature) {
- throw new Exception("PS invalid signature");
- }
- }
-
- /**
- * Kontrola parametru predavanych ve zpetnem volani po potvrzeni/zruseni platby - verifikace podpisu.
- *
- * @param float $returnedGoId - goId vracene v redirectu
- * @param float $returnedPaymentSessionId - paymentSessionId vracene v redirectu
- * @param float $returnedParentPaymentSessionId - id puvodni platby pri opakovane platbe
- * @param string $returnedOrderNumber - identifikace objednavky vracena v redirectu - identifikator platby na eshopu
- * @param string $returnedEncryptedSignature - kontrolni podpis vraceny v redirectu
- * @param float $targetGoId - identifikace prijemce - GoId pridelene GoPay
- * @param string $orderNumber - identifikace akt. objednavky
- * @param string $secureKey - kryptovaci klic prideleny eshopu / uzivateli, urceny k podepisovani komunikace
- *
- * @throw Exception
- */
- public static function checkPaymentIdentity($returnedGoId,
- $returnedPaymentSessionId,
- $returnedParentPaymentSessionId,
- $returnedOrderNumber,
- $returnedEncryptedSignature,
- $targetGoId,
- $orderNumber,
- $secureKey) {
-
- if (trim($returnedOrderNumber) != trim($orderNumber)) {
- throw new Exception("PI invalid VS");
- }
-
- if ($returnedGoId != $targetGoId) {
- throw new Exception("PI invalid GoID");
- }
-
- $hashedSignature=GopayHelper::hash(
- GopayHelper::concatPaymentIdentity(
- (float)$returnedGoId,
- (float)$returnedPaymentSessionId,
- (float)$returnedParentPaymentSessionId,
- $returnedOrderNumber,
- $secureKey));
-
- $decryptedHash = GopayHelper::decrypt($returnedEncryptedSignature, $secureKey);
-
- if ($decryptedHash != $hashedSignature) {
- throw new Exception("PS invalid signature");
- }
- }
-
- /**
- * Kontrola parametru predavanych ve zpetnem volani po potvrzeni/zruseni platby - verifikace podpisu.
- *
- * @param float $returnedPaymentSessionId - paymentSessionId vracene v redirectu
- * @param string $returnedEncryptedSignature - kontrolni podpis vraceny v redirectu
- * @param float $paymentResult - vysledek volani
- * @param float $paymentSessionId - identifikator platby na GoPay
- * @param string $secureKey - kryptovaci klic prideleny eshopu / uzivateli, urceny k podepisovani komunikace
- *
- * @throw Exception
- */
- public static function checkPaymentResult($returnedPaymentSessionId,
- $returnedEncryptedSignature,
- $paymentResult,
- $paymentSessionId,
- $secureKey) {
-
- if ($returnedPaymentSessionId != $paymentSessionId) {
- throw new Exception("PaymentResult invalid PSID");
- }
-
- $hashedSignature = GopayHelper::hash(
- GopayHelper::concatPaymentResult(
- (float)$paymentSessionId,
- $paymentResult,
- $secureKey));
-
- $decryptedHash = GopayHelper::decrypt($returnedEncryptedSignature, $secureKey);
-
- if ($decryptedHash != $hashedSignature) {
- throw new Exception("PaymentResult invalid signature");
- }
- }
-
- /**
- * Sestaveni formulare platebniho tlacitka pro jednoduchou integraci
- *
- *
- * @param float $targetGoId - identifikace prijemce - GoId pridelene GoPay
- * @param string $productName - nazev objednavky / zbozi
- * @param int $totalPrice - cena objednavky v halerich
- * @param string $currency - identifikator meny
- * @param string $orderNumber - identifikace objednavky u prijemce
- * @param string $successURL - URL, kam se ma prejit po uspesnem zaplaceni
- * @param string $failedURL - URL, kam se ma prejit po neuspesnem zaplaceni
- * @param array $paymentChannels - pole plat. metod, ktere se zobrazi na brane
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- *
- * @param boolean $preAuthorization - jedna-li se o predautorizovanou platbu
- * @param boolean $recurrentPayment - jedna-li se o opakovanou platbu
- * @param date $recurrenceDateTo - do kdy se ma opakovana platba provadet
- * @param string $recurrenceCycle - frekvence opakovresultane platby - mesic/tyden/den
- * @param int $recurrencePeriod - pocet plateb v cyklu $recurrenceCycle - kolikrat v mesici/... se opakovana platba provede
- *
- * 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 - $p4 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
- *
- * @param string $lang - jazyk platebni brany
- *
- * @return HTML kod platebniho formulare
- */
- public static function createPaymentForm($targetGoId,
- $productName,
- $totalPrice,
- $currency,
- $orderNumber,
- $successURL,
- $failedURL,
- $preAuthorization,
- $recurrentPayment,
- $recurrenceDateTo,
- $recurrenceCycle,
- $recurrencePeriod,
- $paymentChannels,
- $defaultPaymentChannel,
- $secureKey,
- $firstName,
- $lastName,
- $city,
- $street,
- $postalCode,
- $countryCode,
- $email,
- $phoneNumber,
- $p1,
- $p2,
- $p3,
- $p4,
- $lang) {
-
- $paymentChannelsString = (!empty($paymentChannels)) ? join($paymentChannels, ",") : "";
-
- $encryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatPaymentCommand((float)$targetGoId,
- $productName,
- (int)$totalPrice,
- $currency,
- $orderNumber,
- $failedURL,
- $successURL,
- $preAuthorization,
- $recurrentPayment,
- $recurrenceDateTo,
- $recurrenceCycle,
- $recurrencePeriod,
- $paymentChannelsString,
- $secureKey)),
- $secureKey);
-
- $ouput = "";
- $ouput .= "
\n";
-
- return $ouput;
- }
-
-
- /**
- * Sestaveni platebniho tlacitka formou odkazu pro jednoduchou integraci
- *
- * @param float $targetGoId - identifikace prijemce - GoId pridelene GoPay
- * @param string $productName - nazev objednavky / zbozi
- * @param int $totalPrice - cena objednavky v halerich
- * @param string $currency - identifikator meny
- * @param string $orderNumber - identifikace objednavky u prijemce
- * @param string $successURL - URL, kam se ma prejit po uspesnem zaplaceni
- * @param string $failedURL - URL, kam se ma prejit po neuspesnem zaplaceni
- * @param array $paymentChannels - pole plat. metod, ktere se zobrazi na brane
- * @param string $secureKey - kryptovaci klic prideleny prijemci, urceny k podepisovani komunikace
- *
- * @param boolean $preAuthorization - jedna-li se o predautorizovanou platbu
- * @param boolean $recurrentPayment - jedna-li se o opakovanou platbu
- * @param date $recurrenceDateTo - do kdy se ma opakovana platba provadet
- * @param string $recurrenceCycle - frekvence opakovresultane platby - mesic/tyden/den
- * @param int $recurrencePeriod - pocet plateb v cyklu $recurrenceCycle - kolikrat v mesici/... se opakovana platba provede
- *
- * 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 - $p4 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
- *
- * @param string $lang - jazyk platebni brany
- *
- * @return HTML kod platebniho tlacitka
- */
- public static function createPaymentHref($targetGoId,
- $productName,
- $totalPrice,
- $currency,
- $orderNumber,
- $successURL,
- $failedURL,
- $preAuthorization,
- $recurrentPayment,
- $recurrenceDateTo,
- $recurrenceCycle,
- $recurrencePeriod,
- $paymentChannels,
- $defaultPaymentChannel,
- $secureKey,
- $firstName,
- $lastName,
- $city,
- $street,
- $postalCode,
- $countryCode,
- $email,
- $phoneNumber,
- $p1,
- $p2,
- $p3,
- $p4,
- $lang) {
-
- $paymentChannelsString = (!empty($paymentChannels)) ? join($paymentChannels, ",") : "";
-
- $encryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatPaymentCommand((float)$targetGoId,
- $productName,
- (int)$totalPrice,
- $currency,
- $orderNumber,
- $failedURL,
- $successURL,
- $preAuthorization,
- $recurrentPayment,
- $recurrenceDateTo,
- $recurrenceCycle,
- $recurrencePeriod,
- $paymentChannelsString,
- $secureKey)),
- $secureKey);
-
- $params = "";
- $params .= "paymentCommand.targetGoId=" . $targetGoId;
- $params .= "&paymentCommand.productName=" . urlencode($productName);
- $params .= "&paymentCommand.totalPrice=" . $totalPrice;
- $params .= "&paymentCommand.currency=" . $currency;
- $params .= "&paymentCommand.orderNumber=" . urlencode($orderNumber);
- $params .= "&paymentCommand.successURL=" . urlencode($successURL);
- $params .= "&paymentCommand.failedURL=" . urlencode($failedURL);
- $params .= "&paymentCommand.paymentChannels=" . urlencode($paymentChannelsString);
- $params .= "&paymentCommand.defaultPaymentChannel=" . urlencode($defaultPaymentChannel);
- $params .= "&paymentCommand.encryptedSignature=" . urlencode($encryptedSignature);
- $params .= "&paymentCommand.preAuthorization=" . GopayHelper::castBoolean2String($preAuthorization);
- $params .= "&paymentCommand.recurrentPayment=" . GopayHelper::castBoolean2String($recurrentPayment);
- $params .= "&paymentCommand.recurrenceDateTo=" . urlencode($recurrenceDateTo);
- $params .= "&paymentCommand.recurrenceCycle=" . urlencode($recurrenceCycle);
- $params .= "&paymentCommand.recurrencePeriod=" . $recurrencePeriod;
- $params .= "&paymentCommand.customerData.firstName=" . urlencode($firstName);
- $params .= "&paymentCommand.customerData.lastName=" . urlencode($lastName);
- $params .= "&paymentCommand.customerData.city=" . urlencode($city);
- $params .= "&paymentCommand.customerData.street=" . urlencode($street);
- $params .= "&paymentCommand.customerData.postalCode=" . urlencode($postalCode);
- $params .= "&paymentCommand.customerData.countryCode=" . urlencode($countryCode);
- $params .= "&paymentCommand.customerData.email=" . urlencode($email);
- $params .= "&paymentCommand.customerData.phoneNumber=" . urlencode($phoneNumber);
- $params .= "&paymentCommand.p1=" . urlencode($p1);
- $params .= "&paymentCommand.p2=" . urlencode($p2);
- $params .= "&paymentCommand.p3=" . urlencode($p3);
- $params .= "&paymentCommand.p4=" . urlencode($p4);
- $params .= "&paymentCommand.lang=" . $lang;
-
- $ouput = "";
- $ouput .= "";
- $ouput .= " Zaplatit ";
- $ouput .= "";
-
- return $ouput;
- }
-
- /**
- * pomocne funkce pro praci s booleanem
- */
-
- /**
- * 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 "";
- }
- }
-
- /**
- * Pretypovani datoveho typu String na boolean
- *
- * @param String $input
- *
- * @return boolean (TRUE|FALSE) v pripade spravne nastaveneho $input, jinak puvodni $input
- */
- public static function castString2Boolean($input) {
- if (is_string($input)) {
-
- if (strtolower($input) == "true") {
- return TRUE;
-
- } else if (strtolower($input) == "false") {
- return FALSE;
-
- }
- }
-
- return $input;
- }
-
- /**
- * Pretypovani datoveho typu boolean na String
- * pouziti ve platebnim tlacitku weboveho formulare ci odkazu
- *
- * @param boolean $boolean
- *
- * @return String ("true"|"false"), v pripade nevalidniho vstupu se vraci puvodni vstupni parametr
- */
- public function castBoolean2String($boolean) {
- if (is_bool($boolean)) {
-
- return ($boolean) ? "true" : "false";
- }
-
- return $boolean;
- }
-
-}
diff --git a/src/Gopay/Api/GopayHttp.php b/src/Gopay/Api/GopayHttp.php
deleted file mode 100644
index bd31ded..0000000
--- a/src/Gopay/Api/GopayHttp.php
+++ /dev/null
@@ -1,57 +0,0 @@
- $firstName,
- "lastName" => $lastName,
- "city" => $city,
- "street" => $street,
- "postalCode" => $postalCode,
- "countryCode" => $countryCode,
- "email" => $email,
- "phoneNumber" => $phoneNumber);
-
- $paymentCommand = array(
- "targetGoId" => (float)$targetGoId,
- "productName" => trim($productName),
- "totalPrice" => (int)$totalPriceInCents,
- "currency" => trim($currency),
- "orderNumber" => trim($orderNumber),
- "failedURL" => trim($failedURL),
- "successURL" => trim($successURL),
- "preAuthorization" => GopayHelper::castString2Boolean($preAuthorization),
- "recurrentPayment" => GopayHelper::castString2Boolean($recurrentPayment),
- "recurrenceDateTo" => $recurrenceDateTo,
- "recurrenceCycle" => trim($recurrenceCycle),
- "recurrencePeriod" => $recurrencePeriod,
- "paymentChannels" => $paymentChannelsString,
- "defaultPaymentChannel" => $defaultPaymentChannel,
- "encryptedSignature" => $encryptedSignature,
- "customerData" => $customerData,
- "p1" => $p1,
- "p2" => $p2,
- "p3" => $p3,
- "p4" => $p4,
- "lang" => $lang);
-
- /*
- * Vytvareni platby na strane GoPay prostrednictvim WS
- */
- $paymentStatus = $go_client->__call('createPayment', array('paymentCommand'=>$paymentCommand));
-
- /*
- * Kontrola stavu platby - musi byt ve stavu CREATED, kontrola parametru platby
- */
- if ($paymentStatus->result == GopayHelper::CALL_COMPLETED
- && $paymentStatus->sessionState == GopayHelper::CREATED
- && $paymentStatus->paymentSessionId > 0) {
-
- return $paymentStatus->paymentSessionId;
-
- } else {
- throw new Exception("Create payment failed: " . $paymentStatus->resultDescription);
-
- }
-
- } catch (SoapFault $f) {
- /*
- * Chyba pri komunikaci s WS
- */
- throw new Exception("Communication with WS failed");
- }
- }
-
-
- /**
- * Kontrola stavu platby eshopu
- * - verifikace parametru z redirectu
- * - kontrola stavu platby
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $orderNumber - identifikator objednavky
- * @param int $totalPriceInCents - celkova cena objednavky v halerich
- * @param string $currency - mena, ve ktere platba probiha
- * @param string $productName - popis objednavky zobrazujici se na platebni brane
- * @param string $secureKey - kryptovaci klic pridelene GoPay
- *
- * @return $result
- * $result["paymentSessionId"] - paymentSessionId platby
- * $result["parentPaymentSessionId"] = paymentSessionId rodicovske platby, pokud je platba opakovana
- * $result["targetGoId"] - GoID eshopu
- * $result["productName"] - popis objednavkz
- * $result["orderNumber"] -cislo objednavky
- * $result["totalPrice"] - celkova cena v halerich
- * $result["currency"] - mena platby
- * $result["sessionState"] - stav platby
- * $result["sessionSubState"] - podprobnejsi popis stavu platby
- * $result["sessionSubStateDesc"] - textový popis doplňující informace.
- * $result["result"] CALL_COMPLETED – volání WS proběhlo bezchybně, CALL_FAILED – volání WS proběhlo s chybou (např.neodpovídající podpis).
- * $result["resultDescription"] - Popis chybové situace při CALL_FAILED.
- * $result["preAuthorization"] - Informuje zda byla platba zalozena jako predautorizovana
- * $result["recurrentPayment"] - Informuje zda byla platba zalozena jako opakovana
- * $result["paymentChannel"] - vybrana platebni metoda
- * $result["encryptedSignature"] - podpis platebniho prikazu
- * $result["p1"] - volitelny parametr P1;
- * $result["p2"] - volitelny parametr P2;
- * $result["p3"] - volitelny parametr P3;
- * $result["p4"] - volitelny parametr P4;
- */
- public static function isPaymentDone($paymentSessionId,
- $targetGoId,
- $orderNumber,
- $totalPriceInCents,
- $currency,
- $productName,
- $secureKey) {
-
- 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((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey)),
- $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- /*
- * Kontrola stavu platby na strane GoPay prostrednictvim WS
- */
- $paymentStatus = $go_client->__call('paymentStatus', array('paymentSessionInfo'=>$paymentSession));
-
- $result = array();
-
- $result["paymentSessionId"] = $paymentStatus->paymentSessionId;
- $result["parentPaymentSessionId"] = $paymentStatus->parentPaymentSessionId;
- $result["targetGoId"] = $paymentStatus->targetGoId;
- $result["productName"] = $paymentStatus->productName;
- $result["orderNumber"] = $paymentStatus->orderNumber;
- $result["totalPrice"] = $paymentStatus->totalPrice;
- $result["currency"] = $paymentStatus->currency;
- $result["sessionState"] = $paymentStatus->sessionState;
- $result["sessionSubState"] = $paymentStatus->sessionSubState;
- $result["sessionSubStateDesc"] = $paymentStatus->sessionSubStateDesc;
- $result["result"] = $paymentStatus->result;
- $result["resultDescription"] = $paymentStatus->resultDescription;
- $result["preAuthorization"] = $paymentStatus->preAuthorization;
- $result["recurrentPayment"] = $paymentStatus->recurrentPayment;
- $result["paymentChannel"] = $paymentStatus->paymentChannel;
- $result["encryptedSignature"] = $paymentStatus->encryptedSignature;
- $result["p1"] = $paymentStatus->p1;
- $result["p2"] = $paymentStatus->p2;
- $result["p3"] = $paymentStatus->p3;
- $result["p4"] = $paymentStatus->p4;
-
- /*
- * Kontrola zaplacenosti objednavky, verifikace parametru objednavky
- */
-
- if ( $paymentStatus->result != GopayHelper::CALL_COMPLETED) {
- throw new Exception("Payment Status Call failed: " . $paymentStatus->resultDescription);
- }
-
- if ($result["sessionState"] != GopayHelper::PAYMENT_METHOD_CHOSEN
- && $result["sessionState"] != GopayHelper::CREATED
- && $result["sessionState"] != GopayHelper::PAID
- && $result["sessionState"] != GopayHelper::AUTHORIZED
- && $result["sessionState"] != GopayHelper::CANCELED
- && $result["sessionState"] != GopayHelper::TIMEOUTED
- && $result["sessionState"] != GopayHelper::REFUNDED
- && $result["sessionState"] != GopayHelper::PARTIALLY_REFUNDED) {
-
- throw new Exception("Bad Payment Session State: " . $result["sessionState"]);
- }
-
- GopayHelper::checkPaymentStatus(
- $paymentStatus,
- $result["sessionState"],
- (float)$targetGoId,
- $orderNumber,
- (int)$totalPriceInCents,
- $currency,
- $productName,
- $secureKey);
-
- return $result;
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- throw new Exception("Communication with WS failed");
- }
- }
-
- /**
- * Seznam vsech aktivnich platebnich metod
- */
- public static function paymentMethodList() {
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $paymentMethodsWS = $go_client->__call("paymentMethodList", array());
-
- $paymentMethods = new PaymentMethods();
- $paymentMethods->adapt($paymentMethodsWS);
-
- return $paymentMethods->paymentMethods;
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- return null;
-
- }
- }
-
- /**
- * Kontrola stavu platby eshopu
- * - verifikace parametru z redirectu
- * - kontrola stavu platby
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $orderNumber - identifikator objednavky
- * @param int $totalPriceInCents - celkova cena objednavky v halerich
- * @param string $currency - mena, ve ktere platba probiha
- * @param string $productName - popis objednavky zobrazujici se na platebni brane
- * @param string $secureKey - kryptovaci klic pridelene GoPay
- *
- * @return $result
- * $result["paymentSessionId"] - paymentSessionId platby
- * $result["parentPaymentSessionId"] = paymentSessionId rodicovske platby, pokud je platba opakovana
- * $result["targetGoId"] - GoID eshopu
- * $result["productName"] - popis objednavkz
- * $result["orderNumber"] -cislo objednavky
- * $result["totalPrice"] - celkova cena v halerich
- * $result["currency"] - mena platby
- * $result["sessionState"] - stav platby
- * $result["sessionSubState"] - podprobnejsi popis stavu platby
- * $result["sessionSubStateDesc"] - textový popis doplňující informace.
- * $result["result"] CALL_COMPLETED – volání WS proběhlo bezchybně, CALL_FAILED – volání WS proběhlo s chybou (např.neodpovídající podpis).
- * $result["resultDescription"] - Popis chybové situace při CALL_FAILED.
- * $result["preAuthorization"] - Informuje zda byla platba zalozena jako predautorizovana
- * $result["recurrentPayment"] - Informuje zda byla platba zalozena jako opakovana
- * $result["paymentChannel"] - vybrana platebni metoda
- * $result["encryptedSignature"] - podpis platebniho prikazu
- * $result["p1"] - volitelny parametr P1;
- * $result["p2"] - volitelny parametr P2;
- * $result["p3"] - volitelny parametr P3;
- * $result["p4"] - volitelny parametr P4;
- * $result["paymentInstCountryCode"] - country code vydavatele platebni karty
- * $result["firstName"] - jmeno zakaznika
- * $result["lastName"] - prijmeni zakaznika
- * $result["city"] - mesto zakaznika
- * $result["street"] - ulice zakaznika
- * $result["postalCode"] - postovni smerovaci cislo zakaznika
- * $result["countryCode"] - zeme zakaznika
- * $result["email"] - email zakaznika
- * $result["phoneNumber"] - telefoni cislo zakaznika
- */
- public static function isPaymentDoneWCust($paymentSessionId,
- $targetGoId,
- $orderNumber,
- $totalPriceInCents,
- $currency,
- $productName,
- $secureKey) {
-
- 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((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey)),
- $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- /*
- * Kontrola stavu platby na strane GoPay prostrednictvim WS
- */
- $paymentStatus = $go_client->__call('paymentStatusWCust', array('paymentSessionInfo'=>$paymentSession));
-
- $result = array();
- $result["paymentSessionId"] = $paymentStatus->paymentSessionId;
- $result["parentPaymentSessionId"] = $paymentStatus->parentPaymentSessionId;
- $result["targetGoId"] = $paymentStatus->targetGoId;
- $result["productName"] = $paymentStatus->productName;
- $result["orderNumber"] = $paymentStatus->orderNumber;
- $result["totalPrice"] = $paymentStatus->totalPrice;
- $result["currency"] = $paymentStatus->currency;
- $result["sessionState"] = $paymentStatus->sessionState;
- $result["sessionSubState"] = $paymentStatus->sessionSubState;
- $result["sessionSubStateDesc"] = $paymentStatus->sessionSubStateDesc;
- $result["result"] = $paymentStatus->result;
- $result["resultDescription"] = $paymentStatus->resultDescription;
- $result["preAuthorization"] = $paymentStatus->preAuthorization;
- $result["recurrentPayment"] = $paymentStatus->recurrentPayment;
- $result["paymentChannel"] = $paymentStatus->paymentChannel;
- $result["encryptedSignature"] = $paymentStatus->encryptedSignature;
- $result["p1"] = $paymentStatus->p1;
- $result["p2"] = $paymentStatus->p2;
- $result["p3"] = $paymentStatus->p3;
- $result["p4"] = $paymentStatus->p4;
- $result["paymentInstCountryCode"] = $paymentStatus->paymentInstCountryCode;
- $result["firstName"] = $paymentStatus->customerData->firstName;
- $result["lastName"] = $paymentStatus->customerData->lastName;
- $result["city"] = $paymentStatus->customerData->city;
- $result["street"] = $paymentStatus->customerData->street;
- $result["postalCode"] = $paymentStatus->customerData->postalCode;
- $result["countryCode"] = $paymentStatus->customerData->countryCode;
- $result["email"] = $paymentStatus->customerData->email;
- $result["phoneNumber"] = $paymentStatus->customerData->phoneNumber;
-
- /*
- * Kontrola zaplacenosti objednavky, verifikace parametru objednavky
- */
-
- if ( $paymentStatus->result != GopayHelper::CALL_COMPLETED) {
- throw new Exception("Payment Status Call failed: " . $paymentStatus->resultDescription);
- }
-
- if ($result["sessionState"] != GopayHelper::PAYMENT_METHOD_CHOSEN
- && $result["sessionState"] != GopayHelper::CREATED
- && $result["sessionState"] != GopayHelper::PAID
- && $result["sessionState"] != GopayHelper::AUTHORIZED
- && $result["sessionState"] != GopayHelper::CANCELED
- && $result["sessionState"] != GopayHelper::TIMEOUTED
- && $result["sessionState"] != GopayHelper::REFUNDED
- && $result["sessionState"] != GopayHelper::PARTIALLY_REFUNDED) {
-
- throw new Exception("Bad Payment Session State: " . $result["sessionState"]);
- }
-
- GopayHelper::checkPaymentStatus(
- $paymentStatus,
- $result["sessionState"],
- (float)$targetGoId,
- $orderNumber,
- (int)$totalPriceInCents,
- $currency,
- $productName,
- $secureKey);
-
- return $result;
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- throw new Exception("Communication with WS failed");
- }
- }
-
- /**
- * Zruseni predautorizovani plateb
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $secureKey - kryptovaci klic prideleny GoPay
- */
- public function voidAuthorization($paymentSessionId,
- $targetGoId,
- $secureKey) {
-
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $sessionEncryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatPaymentSession((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey)),
- $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- $paymentResult = $go_client->__call('voidAuthorization', array('sessionInfo'=>$paymentSession));
-
- if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) {
- throw new Exception("voided autorization failed [" . $paymentResult->resultDescription . "]");
-
- } else if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) {
- //zruseni predautorizace platby bylo zarazeno ke zpracovani
-
- throw new Exception(GopayHelper::CALL_RESULT_ACCEPTED);
- }
-
- //Overeni podpisu
- GopayHelper::checkPaymentResult($paymentResult->paymentSessionId,
- $paymentResult->encryptedSignature,
- $paymentResult->result,
- $paymentSessionId,
- $secureKey);
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- throw new Exception("SOAP error");
- }
-
- }
-
- /**
- * Zruseni opakovani plateb
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $secureKey - kryptovaci klic prideleny GoPay
- */
- public function voidRecurrentPayment($paymentSessionId,
- $targetGoId,
- $secureKey) {
-
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $hash = GopayHelper::hash(
- GopayHelper::concatPaymentSession((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey));
-
- $sessionEncryptedSignature = GopayHelper::encrypt($hash, $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- $paymentResult = $go_client->__call('voidRecurrentPayment', array('sessionInfo'=>$paymentSession));
-
- if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) {
- throw new Exception("void recurrency failed [" . $paymentResult->resultDescription . "]");
-
- } else if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) {
- //zruseni opakovani platby bylo zarazeno ke zpracovani
-
- throw new Exception(GopayHelper::CALL_RESULT_ACCEPTED);
-
- }
-
- //Overeni podpisu
- GopayHelper::checkPaymentResult($paymentResult->paymentSessionId,
- $paymentResult->encryptedSignature,
- $paymentResult->result,
- $paymentSessionId,
- $secureKey);
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- throw new Exception("SOAP error");
- }
-
- }
-
- /**
- * Založení opakovane platby
- *
- * @param float $parentPaymentSessionId - identifikator rodicovske platby
- * @param int $recurrentPaymentOrderNumber - identifikator objednavky
- * @param int $recurrentPaymentTotalPriceInCents - castka
- * @param string $recurrentPaymentCurrency - mena (CZK)
- * @param string $recurrentPaymentProductName - popis objednavky
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $secureKey - kryptovaci klic prideleny GoPay
- */
- public function performRecurrence($parentPaymentSessionId,
- $recurrentPaymentOrderNumber,
- $recurrentPaymentTotalPriceInCents,
- $recurrentPaymentCurrency,
- $recurrentPaymentProductName,
- $targetGoId,
- $secureKey) {
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $encryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatRecurrenceRequest(
- (float)$parentPaymentSessionId,
- (int)$recurrentPaymentOrderNumber,
- (int)$recurrentPaymentTotalPriceInCents,
- (float)$targetGoId,
- $secureKey)),
- $secureKey);
-
- $recurrenceRequest = array(
- "parentPaymentSessionId" => (float)$parentPaymentSessionId,
- "orderNumber" => (int)$recurrentPaymentOrderNumber,
- "totalPrice" => (int)$recurrentPaymentTotalPriceInCents,
- "targetGoId" => (float)$targetGoId,
- "encryptedSignature" => $encryptedSignature);
-
- $status = $go_client->__call('createRecurrentPayment', array('recurrenceRequest' => $recurrenceRequest));
-
- if ($status->result == GopayHelper::CALL_COMPLETED) {
-
- GopayHelper::checkPaymentStatus($status,
- GopayHelper::CREATED,
- (float)$targetGoId,
- (int)$recurrentPaymentOrderNumber,
- (int)$recurrentPaymentTotalPriceInCents,
- $recurrentPaymentCurrency,
- $recurrentPaymentProductName,
- $secureKey);
-
- return $status->paymentSessionId;
-
- } else {
- throw new Exception("Bad payment status");
-
- }
-
- } catch (SoapFault $f) {
- /*
- * Chyba v komunikaci s GoPay serverem
- */
- throw new Exception("SOAP error");
- }
-
- }
-
- /**
- * Dokončení platby
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $secureKey - kryptovaci klic prideleny GoPay
- */
- public function capturePayment($paymentSessionId,
- $targetGoId,
- $secureKey) {
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $sessionEncryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatPaymentSession((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey)),
- $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- $paymentResult = $go_client->__call('capturePayment', array('sessionInfo'=>$paymentSession));
-
-
- if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) {
- throw new Exception("payment not captured [" . $paymentResult->resultDescription . "]");
-
- } else if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) {
- // dokonceni 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");
- }
- }
-
- /**
- * Vraceni platby
- *
- * @param float $paymentSessionId - identifikator platby
- * @param float $targetGoId - identifikator prijemnce - GoId
- * @param string $secureKey - kryptovaci klic prideleny GoPay
- */
- public function refundPayment($paymentSessionId,
- $targetGoId,
- $secureKey) {
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $sessionEncryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatPaymentSession((float)$targetGoId,
- (float)$paymentSessionId,
- $secureKey)),
- $secureKey);
-
- $paymentSession = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$paymentSessionId,
- "encryptedSignature" => $sessionEncryptedSignature);
-
- $paymentResult = $go_client->__call('refundPayment', array('sessionInfo'=>$paymentSession));
-
- 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");
- }
- }
-
- /**
- * 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
- */
- public function refundPaymentPartially($paymentSessionId,
- $amount,
- $currency,
- $description,
- $targetGoId,
- $secureKey) {
- try {
-
- //inicializace WS
- ini_set("soap.wsdl_cache_enabled","0");
- $go_client = new SoapClient(GopayConfig::ws(), array());
-
- $sessionEncryptedSignature = GopayHelper::encrypt(
- GopayHelper::hash(
- GopayHelper::concatRefundRequest((float)$targetGoId,
- (float)$paymentSessionId,
- $amount,
- $currency,
- $description,
- $secureKey)),
- $secureKey);
-
- $refundRequest = array(
- "targetGoId" => (float)$targetGoId,
- "paymentSessionId" => (float)$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");
- }
- }
-
-}
diff --git a/src/Gopay/Api/PaymentMethodElement.php b/src/Gopay/Api/PaymentMethodElement.php
deleted file mode 100644
index 46c4c0d..0000000
--- a/src/Gopay/Api/PaymentMethodElement.php
+++ /dev/null
@@ -1,23 +0,0 @@
-code = $code;
- $this->paymentMethodName = $paymentMethodName;
- $this->description = $description;
- $this->logo = $logo;
- $this->offline = $offline;
- }
-
-}
diff --git a/src/Gopay/Api/PaymentMethods.php b/src/Gopay/Api/PaymentMethods.php
deleted file mode 100644
index c37d684..0000000
--- a/src/Gopay/Api/PaymentMethods.php
+++ /dev/null
@@ -1,27 +0,0 @@
-paymentMethods[] = new PaymentMethodElement(
- $method->code,
- $method->paymentMethod,
- $method->description,
- $method->logo,
- $method->offline
- );
- }
- }
-
-}