Пример #1
0
 /**
  * Check and create payment
  *
  * @param  Payment
  * @param  string|null
  * @return int
  * @throws \InvalidArgumentException on undefined channel or provided ReturnedPayment
  * @throws GopayFatalException on maldefined parameters
  * @throws GopayException on failed communication with WS
  */
 protected function createPaymentInternal(Payment $payment, $channel)
 {
     if ($payment instanceof ReturnedPayment) {
         throw new \InvalidArgumentException("Cannot use instance of 'ReturnedPayment'! This payment has been already used for paying");
     }
     if (!isset($this->channels[$channel]) && $channel !== self::METHOD_USER_SELECT) {
         throw new \InvalidArgumentException("Payment channel '{$channel}' is not supported");
     }
     try {
         $customer = $payment->getCustomer();
         $paymentSessionId = $this->soap->createPayment($this->gopayId, $payment->getProductName(), $payment->getSumInCents(), $payment->getCurrency(), $payment->getVariable(), $this->successUrl, $this->failureUrl, array_keys($this->channels), $channel, $this->gopaySecretKey, $customer->firstName, $customer->lastName, $customer->city, $customer->street, $customer->postalCode, $customer->countryCode, $customer->email, $customer->phoneNumber, NULL, NULL, NULL, NULL, $this->lang);
         return $paymentSessionId;
     } catch (\Exception $e) {
         throw new GopayException($e->getMessage(), 0, $e);
     }
 }
Пример #2
0
 /**
  * Vytvoreni standardni platby
  *
  * @param long 	 $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 - $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 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);
 }
Пример #3
0
 /**
  * Receives status of payment from Gopay WS
  *
  * @return array
  */
 public function getStatus()
 {
     if ($this->result !== NULL) {
         return $this->result;
     }
     return $this->result = GopaySoap::isPaymentDone((double) $this->valuesToBeVerified['paymentSessionId'], (double) $this->gopayId, $this->getVariable(), (int) $this->getSumInCents(), $this->getCurrency(), $this->getProductName(), $this->gopaySecretKey);
 }
Пример #4
0
 /**
  * Executes payment via redirecting to GoPay payment gate
  *
  * @param  Payment
  * @param  string|null
  * @param  callback
  * @return RedirectResponse
  * @throws \InvalidArgumentException on undefined channel or provided ReturnedPayment
  * @throws GopayFatalException on maldefined parameters
  * @throws GopayException on failed communication with WS
  */
 public function recurrentPay(Payment $payment, $channel, $callback)
 {
     if ($payment instanceof ReturnedPayment) {
         throw new \InvalidArgumentException("Cannot use instance of 'ReturnedPayment'! This payment has been already used for paying");
     }
     if (!isset($this->channels[$channel]) && $channel !== self::METHOD_USER_SELECT) {
         throw new \InvalidArgumentException("Payment channel '{$channel}' is not supported");
     }
     try {
         $customer = $payment->getCustomer();
         $paymentSessionId = $this->soap->createRecurrentPayment($this->gopayId, $payment->getProductName(), $payment->getSumInCents(), $payment->getCurrency(), $payment->getVariable(), $this->successUrl, $this->failureUrl, $this->recurrenceDateTo, $this->recurrenceCycle, $this->recurrencePeriod, array_keys($this->channels), $channel, $this->gopaySecretKey, $customer->firstName, $customer->lastName, $customer->city, $customer->street, $customer->postalCode, $customer->countryCode, $customer->email, $customer->phoneNumber, NULL, NULL, NULL, NULL, $this->lang);
     } catch (\Exception $e) {
         throw new GopayException($e->getMessage(), 0, $e);
     }
     $url = GopayConfig::fullIntegrationURL() . "?sessionInfo.targetGoId=" . $this->gopayId . "&sessionInfo.paymentSessionId=" . $paymentSessionId . "&sessionInfo.encryptedSignature=" . $this->createSignature($paymentSessionId);
     Nette\Utils\Callback::invokeArgs($callback, array($paymentSessionId));
     return new RedirectResponse($url);
 }
Пример #5
0
 /**
  * Loads all gopay channels
  *
  * @throws GopayException on failed communication with WS
  */
 private function loadGopayChannels()
 {
     if ($this->fetchedChannels) {
         return;
     }
     $this->fetchedChannels = TRUE;
     $methodList = GopaySoap::paymentMethodList();
     if ($methodList === NULL) {
         throw new GopayFatalException('Loading of native Gopay payment channels failed due to communication with WS.');
     }
     foreach ($methodList as $method) {
         $this->addRawChannel($method, FALSE);
     }
 }