Exemplo n.º 1
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
  */
 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((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");
     }
 }
Exemplo n.º 2
0
 /**
  * Creates encrypted signature for given given payment session id
  *
  * @param int $paymentSessionId
  * @return string
  */
 protected function createSignature($paymentSessionId)
 {
     return GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession($this->gopay->config->getGopayId(), (double) $paymentSessionId, $this->gopay->config->getGopaySecretKey())), $this->gopay->config->getGopaySecretKey());
 }
Exemplo n.º 3
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 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((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;
     $ouput = "";
     $ouput .= "<a target='_blank' href='" . GopayConfig::baseIntegrationURL() . "?" . $params . "'>";
     $ouput .= " Zaplatit ";
     $ouput .= "</a>";
     return $ouput;
 }
Exemplo n.º 4
0
 /**
  * Creates encrypted signature for given given payment session id
  *
  * @param  int
  * @return string
  */
 private function createSignature($paymentSessionId)
 {
     return GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentSession((double) $this->gopayId, (double) $paymentSessionId, $this->gopaySecretKey)), $this->gopaySecretKey);
 }