Exemplo n.º 1
0
 /**
  * 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((double) $targetGoId, (double) $paymentSessionId, $secureKey));
         $sessionEncryptedSignature = GopayHelper::encrypt($hash, $secureKey);
         $paymentSession = array("targetGoId" => (double) $targetGoId, "paymentSessionId" => (double) $paymentSessionId, "encryptedSignature" => $sessionEncryptedSignature);
         $paymentResult = $go_client->__call('voidRecurrentPayment', array('sessionInfo' => $paymentSession));
         $returnHash = GopayHelper::decrypt($paymentResult->encryptedSignature, $secureKey);
         if ($hash != $returnHash) {
             throw new Exception("Encrypted signature differ");
         }
         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);
             }
         }
     } catch (SoapFault $f) {
         /*
          * Chyba v komunikaci s GoPay serverem
          */
         throw new Exception("SOAP error");
     }
 }
Exemplo n.º 2
0
 /**
  * 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((double) $paymentSessionId, $paymentResult, $secureKey));
     $decryptedHash = GopayHelper::decrypt($returnedEncryptedSignature, $secureKey);
     if ($decryptedHash != $hashedSignature) {
         throw new Exception("PaymentResult invalid signature");
     }
 }