Esempio n. 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;
 }
Esempio n. 2
0
 /**
  * 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 array $defaultPaymentChannel - vychozi platebni metoda
  * @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 string $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 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
  * @param string $p2 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
  * @param string $p3 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
  * @param string $p4 - volitelne parametry, ketre budou po navratu z platebni brany predany e-shopu
  *
  * @param string $lang - jazyk platebni brany
  *
  * @return string 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((double) $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;
     $output = "";
     $output .= "<a target='_blank' href='" . GopayConfig::baseIntegrationURL() . "?" . $params . "'>";
     $output .= " Zaplatit ";
     $output .= "</a>";
     return $output;
 }
Esempio n. 3
0
     $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}");
 }
Esempio n. 4
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;
 }
Esempio n. 5
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;
 }
Esempio n. 6
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");
     }
 }