diff --git a/CHANGELOG.md b/CHANGELOG.md index c9e19ca..cb39478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### v1.0.5 от 03.05.2018 +* Актуализация PHP SDK до версии 1.0.8 +* Добавлен метод "Заплатить по частям" + ### v1.0.4 от 10.04.2018 * Актуализация PHP SDK до версии 1.0.6 * Добавлена поддержка уведомлений succeeded diff --git a/README.md b/README.md index 34ca02b..39b83b6 100644 --- a/README.md +++ b/README.md @@ -37,4 +37,4 @@ * Указать наименование CMS и компонента магазина, а также их версии * Указать версию платежного модуля (доступна на странице настроек модуля) * Описать проблему или предложение -* Приложить снимок экрана (для большей информативности) +* Приложить снимок экрана (для большей информативности) \ No newline at end of file diff --git a/payment/YandexMoneyApi/YandexMoneyApi.php b/payment/YandexMoneyApi/YandexMoneyApi.php index 6df6de3..eb692d1 100644 --- a/payment/YandexMoneyApi/YandexMoneyApi.php +++ b/payment/YandexMoneyApi/YandexMoneyApi.php @@ -1,12 +1,12 @@ Заплатить этим способом не получится: сумма должна быть больше ' + . self::INSTALLMENTS_MIN_AMOUNT . ' рублей.'; + } + if ($payment_type == \YandexCheckout\Model\PaymentMethodType::ALFABANK) { if (isset($_POST['alfabak_login']) && !empty($_POST['alfabak_login'])) { $payment_type = new \YandexCheckout\Model\PaymentData\PaymentDataAlfabank(); @@ -72,7 +80,10 @@ public function checkout_form($order_id, $button_text = null) } } - if (isset($_POST['submit-button'])) { + if (isset($_POST['payment_submit'])) { + if (!empty($_POST['payment_type'])) { + $payment_type = $_POST['payment_type']; + } $apiClient = new Client(); $apiClient->setAuth($settings['yandex_api_shopid'], $settings['yandex_api_password']); $apiClient->setLogger(new YandexMoneyLogger($settings['ya_kassa_debug'])); @@ -112,16 +123,23 @@ public function checkout_form($order_id, $button_text = null) $paymentRequest = $builder->build(); $idempotencyKey = base64_encode($order->id.microtime()); - $response = $apiClient->createPayment($paymentRequest, $idempotencyKey); + try { + $response = $apiClient->createPayment($paymentRequest, $idempotencyKey); + } catch (Exception $exception) { + $logger = new YandexMoneyLogger($settings['ya_kassa_debug']); + $logger->error($exception->getMessage()); + } - if ($response) { + if (!empty($response)) { $order->payment_details = $response->getId(); $this->orders->update_order($order->id, $order); $confirmationUrl = $response->confirmation->confirmationUrl; header('Location: '.$confirmationUrl); + } else { + return 'Платеж не прошел. Попробуйте еще или выберите другой способ оплаты.'; } } else { - return $this->getForm($button_text); + return $this->getForm($button_text, $settings, $amount); } } @@ -175,14 +193,144 @@ protected function getAlfaForm($button_text, $error = false) /** * @param string $button_text + * @param array $settings + * @param float $amount * @return string */ - private function getForm($button_text) + private function getForm($button_text, $settings, $amount) { - $button = '
- -
'; + ob_start(); + ?> + +
+ + + +
+ +
+ +
+ +
+ +
+ + + +
+ + + + site + + yandex_show_pay_with_yandex_button + Отображение кнопок + + Назвать кнопку оплаты «Заплатить через Яндекс» + 1 + + + + yandex_show_installments_button + оплаты (для режима с выбором на стороне Кассы) + + Добавить кнопку «Заплатить по частям» на страницу оформления заказа + 1 + + yandex_api_paymenttype - Способ оплаты (для режима оплаты с выбором на стороне магазина) + Способ оплаты (для режима с выбором на стороне магазина) Не задан @@ -58,6 +74,10 @@ QIWI Wallet qiwi + + Заплатить по частям + installments + ya_kassa_api_send_check diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Client.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Client.php index 5e587af..df79e75 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Client.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Client.php @@ -86,7 +86,7 @@ class Client /** * Текущая версия библиотеки */ - const SDK_VERSION = '1.0.6'; + const SDK_VERSION = '1.0.8'; /** * Имя HTTP заголовка, используемого для передачи idempotence key diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/Airline.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/Airline.php new file mode 100644 index 0000000..70f5023 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/Airline.php @@ -0,0 +1,256 @@ +_bookingReference; + } + + /** + * @param string $value + */ + public function setBookingReference($value) + { + if ($value === null || $value === '') { + $this->_bookingReference = null; + } elseif (!TypeCast::canCastToString($value)) { + throw new InvalidPropertyValueTypeException('Invalid booking reference value type', 0, + 'airline.booking_reference'); + } elseif (mb_strlen((string)$value, 'utf-8') > 20) { + throw new InvalidPropertyValueException('Invalid booking reference value: "'.$value.'"', 0, + 'airline.booking_reference'); + } else { + $this->_bookingReference = (string)$value; + } + } + + /** + * @inheritdoc + */ + public function getTicketNumber() + { + return $this->_ticketNumber; + } + + /** + * @param string $value + */ + public function setTicketNumber($value) + { + if ($value === null || $value === '') { + $this->_ticketNumber = null; + } elseif (!TypeCast::canCastToString($value)) { + throw new InvalidPropertyValueTypeException('Invalid ticket number value type', 0, + 'airline.ticket_number'); + } elseif (!preg_match('/^[0-9]{1,150}$/', (string)$value)) { + throw new InvalidPropertyValueException('Invalid ticket_number value: "'.$value.'"', 0, + 'airline.ticket_number'); + } else { + $this->_ticketNumber = (string)$value; + } + } + + /** + * @inheritdoc + */ + public function getPassengers() + { + return $this->_passengers; + } + + /** + * @param array|PassengerInterface[] $value + */ + public function setPassengers($value) + { + if ($value === null || $value === '') { + throw new EmptyPropertyValueException('Empty passengers value in airline', 0, 'airline.passengers'); + } + if (!is_array($value) && !($value instanceof \Traversable)) { + throw new InvalidPropertyValueTypeException( + 'Invalid passengers value type in airline', 0, 'airline.passengers', $value + ); + } + $this->_passengers = array(); + foreach ($value as $key => $val) { + try { + $this->addPassenger($val); + } catch (InvalidPropertyValueTypeException $exception) { + throw new InvalidPropertyValueTypeException( + 'Invalid passenger value type in airline', 0, 'airline.passengers['.$key.']', $val + ); + } + } + } + + /** + * @param array|PassengerInterface $value + */ + public function addPassenger($value) + { + if ($value instanceof PassengerInterface) { + $this->_passengers[] = $value; + } elseif (is_array($value)) { + $passenger = new Passenger(); + $passenger->fromArray($value); + $this->_passengers[] = $passenger; + } else { + throw new InvalidPropertyValueTypeException( + 'Invalid passenger value type in airline', 0 + ); + } + } + + /** + * @inheritdoc + */ + public function getLegs() + { + return $this->_legs; + } + + /** + * @param array|LegInterface[] $value + */ + public function setLegs($value) + { + if ($value === null || $value === '') { + throw new EmptyPropertyValueException('Empty legs value in airline', 0, 'airline.passengers'); + } + if (!is_array($value) && !($value instanceof \Traversable)) { + throw new InvalidPropertyValueTypeException( + 'Invalid legs value type in airline', 0, 'airline.legs', $value + ); + } + $this->_legs = array(); + foreach ($value as $key => $val) { + try { + $this->addLeg($val); + } catch (InvalidPropertyValueTypeException $exception) { + throw new InvalidPropertyValueTypeException( + 'Invalid legs value type in airline', 0, 'airline.legs['.$key.']', $val + ); + } + } + } + + /** + * @param array|LegInterface $value + */ + public function addLeg($value) + { + if ($value instanceof LegInterface) { + $this->_legs[] = $value; + } elseif (is_array($value)) { + $leg = new Leg(); + $leg->fromArray($value); + $this->_legs[] = $leg; + } else { + throw new InvalidPropertyValueTypeException( + 'Invalid passenger value type in airline', 0 + ); + } + } + + /** + * Првоерка на наличие данных + * @return bool + */ + public function notEmpty() + { + return $this->_legs || $this->_passengers || $this->_ticketNumber || $this->_bookingReference; + } + + /** + * @inheritdoc + */ + public function fromArray($sourceArray) + { + if (is_array($sourceArray['passengers']) && !empty($sourceArray['passengers'])) { + $sourceArray['passengers'] = array_map(function ($passengerData) { + if (is_array($passengerData)) { + $passenger = new Passenger(); + $passenger->fromArray($passengerData); + + return $passenger; + } elseif ($passengerData instanceof PassengerInterface) { + return $passengerData; + } + }, $sourceArray['passengers']); + } + + if (is_array($sourceArray['legs']) && !empty($sourceArray['legs'])) { + $sourceArray['legs'] = array_map(function ($legData) { + if (is_array($legData)) { + $leg = new Leg(); + $leg->fromArray($legData); + + return $leg; + } elseif ($legData instanceof LegInterface) { + return $legData; + } + }, $sourceArray['legs']); + } + parent::fromArray($sourceArray); + } +} \ No newline at end of file diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/AirlineInterface.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/AirlineInterface.php new file mode 100644 index 0000000..66a645c --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/AirlineInterface.php @@ -0,0 +1,59 @@ +_departureAirport; + } + + /** + * @param string $value + */ + public function setDepartureAirport($value) + { + if (!TypeCast::canCastToString($value)) { + throw new InvalidPropertyValueTypeException('Invalid departure_airport value type', 0, + 'airline.departure_airport'); + } elseif (!preg_match('/^[A-Z]{3}$/', (string)$value)) { + throw new InvalidPropertyValueException('Invalid departure_airport value: "'.$value.'"', 0, + 'airline.departure_airport'); + } else { + $this->_departureAirport = (string)$value; + } + } + + /** + * @inheritdoc + */ + public function getDestinationAirport() + { + return $this->_destinationAirport; + } + + /** + * @param string $value + */ + public function setDestinationAirport($value) + { + if (!TypeCast::canCastToString($value)) { + throw new InvalidPropertyValueTypeException('Invalid destination_airport value type', 0, + 'airline.destination_airport'); + } elseif (!preg_match('/^[A-Z]{3}$/', (string)$value)) { + throw new InvalidPropertyValueException('Invalid destination_airport value: "'.$value.'"', 0, + 'airline.destination_airport'); + } else { + $this->_destinationAirport = (string)$value; + } + } + + /** + * @inheritdoc + */ + public function getDepartureDate() + { + return $this->_departureDate; + } + + /** + * @param \DateTime|string $value + */ + public function setDepartureDate($value) + { + if (TypeCast::canCastToDateTime($value)) { + $departureDate = TypeCast::castToDateTime($value); + if ($departureDate === null) { + throw new InvalidPropertyValueException( + 'Invalid departure_date value in airline.legs', 0, 'airline.legs' + ); + } + $this->_departureDate = $departureDate->format(self::ISO8601); + } else { + throw new InvalidPropertyValueTypeException( + 'Invalid departure_date value type in airline.legs', 0, 'airline.legs' + ); + } + } +} \ No newline at end of file diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/LegInterface.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/LegInterface.php new file mode 100644 index 0000000..b003868 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/LegInterface.php @@ -0,0 +1,45 @@ +_firstName; + } + + /** + * @param $value + */ + public function setFirstName($value) + { + if (TypeCast::canCastToString($value)) { + $length = mb_strlen((string)$value, 'utf-8'); + if ($length > 64) { + throw new InvalidPropertyValueException( + 'Invalid first_name value length in Passenger object', + 0, 'airline.passengers', $value + ); + } + $this->_firstName = (string)$value; + } else { + throw new InvalidPropertyValueTypeException( + 'Invalid first_name value type in Passenger object', 0, 'airline.passengers', $value + ); + } + } + + /** + * @inheritdoc + */ + public function getLastName() + { + return $this->_lastName; + } + + /** + * @param $value + */ + public function setLastName($value) + { + if (TypeCast::canCastToString($value)) { + $length = mb_strlen((string)$value, 'utf-8'); + if ($length > 64) { + throw new InvalidPropertyValueException( + 'Invalid last_name value length in Passenger object', + 0, 'airline.passengers', $value + ); + } + $this->_lastName = (string)$value; + } else { + throw new InvalidPropertyValueTypeException( + 'Invalid last_name value type in Passenger object', 0, 'airline.passengers', $value + ); + } + } +} \ No newline at end of file diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PassengerInterface.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PassengerInterface.php new file mode 100644 index 0000000..e1cb6cd --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PassengerInterface.php @@ -0,0 +1,41 @@ + 'PaymentDataQiwi', PaymentMethodType::WEBMONEY => 'PaymentDataWebmoney', PaymentMethodType::ALFABANK => 'PaymentDataAlfabank', + PaymentMethodType::INSTALLMENTS => 'PaymentDataInstallments', ); /** diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentData/PaymentDataInstallments.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentData/PaymentDataInstallments.php new file mode 100644 index 0000000..b60d9c1 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentData/PaymentDataInstallments.php @@ -0,0 +1,40 @@ +_setType(PaymentMethodType::INSTALLMENTS); + } +} diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodCardType.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodCardType.php index 9941fc5..0ee96f4 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodCardType.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodCardType.php @@ -32,7 +32,7 @@ class PaymentMethodCardType extends AbstractEnum { const MASTER_CARD = 'MasterCard'; const VISA = 'Visa'; - const MIR = 'Mir'; + const MIR = 'MIR'; const UNION_PAY = 'UnionPay'; const JCB = 'JCB'; const AMERICAN_EXPRESS = 'AmericanExpress'; diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodFactory.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodFactory.php index 8b509e4..07382a7 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodFactory.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodFactory.php @@ -41,6 +41,7 @@ class PaymentMethodFactory PaymentMethodType::QIWI => 'PaymentMethodQiwi', PaymentMethodType::WEBMONEY => 'PaymentMethodWebmoney', PaymentMethodType::ALFABANK => 'PaymentMethodAlfaBank', + PaymentMethodType::INSTALLMENTS => 'PaymentMethodInstallments', ); private $optionsMap = array( diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodInstallments.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodInstallments.php new file mode 100644 index 0000000..1ecf117 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethod/PaymentMethodInstallments.php @@ -0,0 +1,42 @@ +_setType(PaymentMethodType::INSTALLMENTS); + } +} diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethodType.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethodType.php index c8a452a..ab24ce0 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethodType.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Model/PaymentMethodType.php @@ -40,7 +40,8 @@ * |apple_pay|Платеж ApplePay| * |android_pay|Платеж AndroidPay| * |qiwi|Платеж из кошелька Qiwi| - * + * |installments|Заплатить по частям| + * */ class PaymentMethodType extends AbstractEnum { @@ -54,6 +55,7 @@ class PaymentMethodType extends AbstractEnum const QIWI = 'qiwi'; const WEBMONEY = 'webmoney'; const ALFABANK = 'alfabank'; + const INSTALLMENTS = 'installments'; protected static $validValues = array( self::YANDEX_MONEY => true, @@ -64,7 +66,8 @@ class PaymentMethodType extends AbstractEnum self::APPLE_PAY => false, self::ANDROID_PAY => false, self::QIWI => true, - self::ALFABANK => true, self::WEBMONEY => true, + self::ALFABANK => true, + self::INSTALLMENTS => true, ); } diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequest.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequest.php index 77df805..39e4afc 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequest.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequest.php @@ -30,6 +30,7 @@ use YandexCheckout\Common\Exceptions\InvalidPropertyValueException; use YandexCheckout\Common\Exceptions\InvalidPropertyValueTypeException; use YandexCheckout\Helpers\TypeCast; +use YandexCheckout\Model\AirlineInterface; use YandexCheckout\Model\AmountInterface; use YandexCheckout\Model\Payment; use YandexCheckout\Model\PaymentData\AbstractPaymentData; @@ -123,6 +124,8 @@ class CreatePaymentRequest extends AbstractRequest implements CreatePaymentReque */ private $_clientIp; + private $_airline; + /** * @var Metadata Метаданные привязанные к платежу */ @@ -537,6 +540,32 @@ public function setClientIp($value) } } + /** + * @return AirlineInterface + */ + public function getAirline() + { + return $this->_airline; + } + + + /** + * @param AirlineInterface $value + */ + public function setAirline(AirlineInterface $value) + { + $this->_airline = $value; + } + + /** + * Проверяет были ли установлены данные длинной записи + * @return bool + */ + function hasAirline() + { + return $this->_airline !== null; + } + /** * Возвращает данные оплаты установленные мерчантом * @return Metadata Метаданные, привязанные к платежу diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestBuilder.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestBuilder.php index e8f301b..a4e8722 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestBuilder.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestBuilder.php @@ -31,6 +31,8 @@ use YandexCheckout\Common\Exceptions\InvalidPropertyValueException; use YandexCheckout\Common\Exceptions\InvalidPropertyValueTypeException; use YandexCheckout\Common\Exceptions\InvalidRequestException; +use YandexCheckout\Model\Airline; +use YandexCheckout\Model\AirlineInterface; use YandexCheckout\Model\AmountInterface; use YandexCheckout\Model\ConfirmationAttributes\AbstractConfirmationAttributes; use YandexCheckout\Model\ConfirmationAttributes\ConfirmationAttributesFactory; @@ -82,6 +84,11 @@ class CreatePaymentRequestBuilder extends AbstractRequestBuilder */ private $confirmationFactory; + /** + * @var Airline Длинная запись + */ + private $airline; + /** * Инициализирует объект запроса, который в дальнейшем будет собираться билдером * @return CreatePaymentRequest Инстанс собираемого объекта запроса к API @@ -91,6 +98,7 @@ protected function initCurrentObject() $request = new CreatePaymentRequest(); $this->recipient = new Recipient(); + $this->airline = new Airline(); $this->receipt = new Receipt(); $this->amount = new MonetaryAmount(); @@ -192,9 +200,31 @@ public function setCurrency($value) return $this; } + /** + * @param AirlineInterface|array $value объект данных длинной записи или ассоциативный массив с данными + * + * @return CreatePaymentRequestBuilder + */ + public function setAirline($value) + { + if (is_array($value)) { + $this->airline->fromArray($value); + } elseif ($value instanceof AirlineInterface) { + $this->receipt = clone $value; + } else { + throw new InvalidPropertyValueTypeException('Invalid receipt value type', 0, 'receipt', $value); + } + + + return $this; + } + /** * Устанавливает чек + * * @param ReceiptInterface|array $value Инстанс чека или ассоциативный массив с данными чека + * + * @return $this */ public function setReceipt($value) { @@ -205,6 +235,7 @@ public function setReceipt($value) } else { throw new InvalidPropertyValueTypeException('Invalid receipt value type', 0, 'receipt', $value); } + return $this; } /** @@ -491,6 +522,9 @@ public function build(array $options = null) if ($this->receipt->notEmpty()) { $this->currentObject->setReceipt($this->receipt); } + if($this->airline->notEmpty()){ + $this->currentObject->setAirline($this->airline); + } $this->currentObject->setAmount($this->amount); return parent::build(); } diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestInterface.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestInterface.php index bddbbed..be3e54c 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestInterface.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestInterface.php @@ -26,6 +26,7 @@ namespace YandexCheckout\Request\Payments; +use YandexCheckout\Model\Airline; use YandexCheckout\Model\AmountInterface; use YandexCheckout\Model\ConfirmationAttributes\AbstractConfirmationAttributes; use YandexCheckout\Model\Metadata; @@ -198,4 +199,16 @@ function getMetadata(); * @return bool True если метаданные были установлены, false если нет */ function hasMetadata(); + + /** + * Проверяет были ли установлены данные длинной записи + * @return bool + */ + function hasAirline(); + + /** + * Возвращает данные длинной записи + * @return Airline + */ + function getAirline(); } diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestSerializer.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestSerializer.php index fcb3ca0..df07912 100644 --- a/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestSerializer.php +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/lib/Request/Payments/CreatePaymentRequestSerializer.php @@ -28,6 +28,8 @@ use YandexCheckout\Model\AmountInterface; use YandexCheckout\Model\ConfirmationType; +use YandexCheckout\Model\LegInterface; +use YandexCheckout\Model\PassengerInterface; use YandexCheckout\Model\PaymentData\AbstractPaymentData; use YandexCheckout\Model\PaymentData\PaymentDataAlfabank; use YandexCheckout\Model\PaymentData\PaymentDataBankCard; @@ -43,10 +45,10 @@ class CreatePaymentRequestSerializer { private static $propertyMap = array( - 'reference_id' => 'referenceId', - 'payment_token' => 'paymentToken', - 'payment_method_id' => 'paymentMethodId', - 'client_ip' => 'clientIp', + 'reference_id' => 'referenceId', + 'payment_token' => 'paymentToken', + 'payment_method_id' => 'paymentMethodId', + 'client_ip' => 'clientIp', ); private static $paymentDataSerializerMap = array( @@ -60,6 +62,7 @@ class CreatePaymentRequestSerializer PaymentMethodType::QIWI => 'serializePaymentDataMobilePhone', PaymentMethodType::CASH => 'serializePaymentDataMobilePhone', PaymentMethodType::MOBILE_BALANCE => 'serializePaymentDataMobilePhone', + PaymentMethodType::INSTALLMENTS => 'serializePaymentData', ); public function serialize(CreatePaymentRequestInterface $request) @@ -105,14 +108,14 @@ public function serialize(CreatePaymentRequestInterface $request) $result['recipient']['gateway_id'] = $request->getRecipient()->getGatewayId(); } if ($request->hasPaymentMethodData()) { - $method = self::$paymentDataSerializerMap[$request->getPaymentMethodData()->getType()]; + $method = self::$paymentDataSerializerMap[$request->getPaymentMethodData()->getType()]; $result['payment_method_data'] = $this->{$method}($request->getPaymentMethodData()); } if ($request->hasConfirmation()) { $result['confirmation'] = array( 'type' => $request->getConfirmation()->getType(), ); - $confirmation = $request->getConfirmation(); + $confirmation = $request->getConfirmation(); if ($confirmation->getType() === ConfirmationType::REDIRECT) { if ($confirmation->getEnforce()) { $result['confirmation']['enforce'] = $confirmation->getEnforce(); @@ -129,6 +132,36 @@ public function serialize(CreatePaymentRequestInterface $request) if ($request->hasSavePaymentMethod()) { $result['save_payment_method'] = $request->getSavePaymentMethod(); } + if ($request->hasAirline()) { + $airline = $request->getAirline(); + $result['airline'] = array(); + + $ticketNumber = $airline->getTicketNumber(); + if (!empty($ticketNumber)) { + $result['airline']['ticket_number'] = $ticketNumber; + } + $bookingReference = $airline->getBookingReference(); + if (!empty($bookingReference)) { + $result['airline']['booking_reference'] = $bookingReference; + } + + /** @var PassengerInterface $passenger */ + foreach ($airline->getPassengers() as $passenger) { + $result['airline']['passengers'][] = array( + 'first_name' => $passenger->getFirstName(), + 'last_name' => $passenger->getLastName(), + ); + } + + /** @var LegInterface $leg */ + foreach ($airline->getLegs() as $leg) { + $result['airline']['legs'][] = array( + 'departure_airport' => $leg->getDepartureAirport(), + 'destination_airport' => $leg->getDestinationAirport(), + 'departure_date' => $leg->getDepartureDate(), + ); + } + } foreach (self::$propertyMap as $name => $property) { $value = $request->{$property}; @@ -136,9 +169,10 @@ public function serialize(CreatePaymentRequestInterface $request) $result[$name] = $value; } } + return $result; } - + private function serializeAmount(AmountInterface $amount) { return array( @@ -154,13 +188,14 @@ private function serializePaymentDataBankCard(PaymentDataBankCard $paymentData) ); if ($paymentData->getCard() !== null) { $result['card'] = array( - 'cardholder' => $paymentData->getCard()->getCardholder(), - 'expiry_year' => $paymentData->getCard()->getExpiryYear(), + 'cardholder' => $paymentData->getCard()->getCardholder(), + 'expiry_year' => $paymentData->getCard()->getExpiryYear(), 'expiry_month' => $paymentData->getCard()->getExpiryMonth(), - 'number' => $paymentData->getCard()->getNumber(), - 'csc' => $paymentData->getCard()->getCsc(), + 'number' => $paymentData->getCard()->getNumber(), + 'csc' => $paymentData->getCard()->getCsc(), ); } + return $result; } @@ -169,6 +204,7 @@ private function serializePaymentDataYandexWallet(PaymentDataYandexWallet $payme $result = array( 'type' => $paymentData->getType(), ); + return $result; } @@ -180,6 +216,7 @@ private function serializePaymentDataMobile(AbstractPaymentData $paymentData) if ($paymentData->getPaymentData() !== null) { $result['payment_data'] = $paymentData->getPaymentData(); } + return $result; } @@ -191,6 +228,7 @@ private function serializePaymentDataSberbank(PaymentDataSberbank $paymentData) if ($paymentData->getPhone() !== null) { $result['phone'] = $paymentData->getPhone(); } + return $result; } @@ -202,13 +240,14 @@ private function serializePaymentDataAlfabank(PaymentDataAlfabank $paymentData) if ($paymentData->getLogin() !== null) { $result['login'] = $paymentData->getLogin(); } + return $result; } private function serializePaymentData(AbstractPaymentData $paymentData) { return array( - 'type' => $paymentData->getType(), + 'type' => $paymentData->getType(), ); } @@ -220,6 +259,7 @@ private function serializePaymentDataMobilePhone(AbstractPaymentData $paymentDat if ($paymentData->getPhone() !== null) { $result['phone'] = $paymentData->getPhone(); } + return $result; } } \ No newline at end of file diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/autoload.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/autoload.php new file mode 100644 index 0000000..606296b --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $length = $this->prefixLengthsPsr4[$first][$search]; + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/LICENSE b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_classmap.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($baseDir . '/lib'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), +); diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_real.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_real.php new file mode 100644 index 0000000..9a446a5 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit68f155e88739542eafa51e07ced35825::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_static.php b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_static.php new file mode 100644 index 0000000..1904a61 --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/autoload_static.php @@ -0,0 +1,39 @@ + + array ( + 'YandexCheckout\\' => 15, + ), + 'P' => + array ( + 'Psr\\Log\\' => 8, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'YandexCheckout\\' => + array ( + 0 => __DIR__ . '/../..' . '/lib', + ), + 'Psr\\Log\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit68f155e88739542eafa51e07ced35825::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit68f155e88739542eafa51e07ced35825::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/installed.json b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/installed.json new file mode 100644 index 0000000..2d7a51c --- /dev/null +++ b/payment/YandexMoneyApi/yandex-checkout-sdk-php/vendor/composer/installed.json @@ -0,0 +1,51 @@ +[ + { + "name": "psr/log", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-10-10T12:19:37+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ] + } +]