/**
* Check and create recurrent payment
*
* @param RecurrentPayment $payment
* @param string $channel
* @return int
* @throws InvalidArgumentException on undefined channel or provided ReturnedPayment
* @throws GopayFatalException on maldefined parameters
* @throws GopayException on failed communication with WS
*/
protected function buildRecurrentPayment(RecurrentPayment $payment, $channel)
{
$channels = $this->getPaymentChannels($channel);
try {
$customer = $payment->getCustomer();
$paymentSessionId = $this->gopay->soap->createRecurrentPayment($this->gopay->config->getGopayId(), $payment->getProductName(), $payment->getSumInCents(), $payment->getCurrency(), $payment->getVariable(), $this->successUrl, $this->failureUrl, $payment->getRecurrenceDateTo(), $payment->getRecurrenceCycle(), $payment->getRecurrencePeriod(), $channels, $channel, $this->gopay->config->getGopaySecretKey(), $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);
}
}