Ejemplo n.º 1
0
 /**
  * @param  Service
  * @param  stdClass
  * @param  array
  * @param  array
  */
 public function __construct(array $values, $gopayId, $gopaySecretKey, array $valuesToBeVerified = array())
 {
     parent::__construct($values);
     $this->gopayId = (double) $gopayId;
     $this->gopaySecretKey = (string) $gopaySecretKey;
     $this->valuesToBeVerified = $valuesToBeVerified;
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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);
     }
 }