Files
yookassa-sdk-php/docs/classes/YooKassa-Request-PaymentMethods-CreatePaymentMethodRequestBuilder.md
Евгений Ю. Лозный 260d13f890 Добавлен прием платежей через Alfa Pay. Добавлен новый тип ошибки RuleViolationError
Добавлены нулевые привязки по СБП
Добавлена причина отмены возвратов `payment_expired`
2026-06-29 17:46:40 +03:00

12 KiB

YooKassa API SDK

Class: \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestBuilder

Namespace: \YooKassa\Request\PaymentMethods


Summary:

Класс, представляющий модель CreatePaymentMethodRequestBuilder.

Description:

Класс билдера объекта запроса на создание платежа, передаваемого в методы клиента API.


Examples

Пример использования билдера

try {
    $paymentMethodBuilder = \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequest::builder();
    $paymentMethodBuilder
        ->setType(\YooKassa\Model\SavePaymentMethod\SavePaymentMethodType::BANK_CARD)
        ->setCard(new \YooKassa\Request\PaymentMethods\PaymentMethodCard([
            'number' => '4100000000000002',
            'expiry_year' => '2025',
            'expiry_month' => '12',
            'cardholder' => 'Ivan Ivanov',
            'csc' => '123',
        ]))
    ;

    // Создаем объект запроса
    $request = $paymentMethodBuilder->build();

    $idempotenceKey = uniqid('', true);
    $response = $client->createPaymentMethod($request, $idempotenceKey);
} catch (Exception $e) {
    $response = $e;
}

var_dump($response);


Constants

  • No constants found

Properties

Visibility Name Flag Summary
protected $currentObject Собираемый объект запроса.

Methods

Visibility Name Flag Summary
public __construct() Конструктор, инициализирует пустой запрос, который в будущем начнём собирать.
public build() Строит и возвращает объект запроса для отправки в API ЮKassa.
public setCard() Устанавливает card.
public setClientIp() Устанавливает client_ip.
public setConfirmation() Устанавливает confirmation.
public setHolder() Устанавливает holder.
public setOptions() Устанавливает свойства запроса из массива.
public setType() Устанавливает type.
protected initCurrentObject() Инициализирует объект запроса, который в дальнейшем будет собираться билдером

Details


Tags

Tag Version Description
category Class
author cms@yoomoney.ru

Properties

protected $currentObject : ?\YooKassa\Common\AbstractRequestInterface


Summary

Собираемый объект запроса.

Type: AbstractRequestInterface

Details:


Methods

public __construct() : mixed

public __construct() : mixed

Summary

Конструктор, инициализирует пустой запрос, который в будущем начнём собирать.

Details:

Returns: mixed -

public build() : \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestInterface|\YooKassa\Common\AbstractRequestInterface

public build(null|array $options = null) : \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestInterface|\YooKassa\Common\AbstractRequestInterface

Summary

Строит и возвращает объект запроса для отправки в API ЮKassa.

Details:

Parameters:
Type Name Description
null OR array options Массив параметров для установки в объект запроса

Returns: \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestInterface|\YooKassa\Common\AbstractRequestInterface - Инстанс объекта запроса

public setCard() : self

public setCard(\YooKassa\Request\PaymentMethods\PaymentMethodCard|array|null $value = null) : self

Summary

Устанавливает card.

Details:

Parameters:
Type Name Description
\YooKassa\Request\PaymentMethods\PaymentMethodCard OR array OR null value Данные для проверки и сохранения банковской карты.

Returns: self -

public setClientIp() : self

public setClientIp(string|null $value = null) : self

Summary

Устанавливает client_ip.

Details:

Parameters:
Type Name Description
string OR null value IPv4 или IPv6-адрес пользователя. Если не указан, используется IP-адрес TCP-подключения.

Returns: self -

public setConfirmation() : self

public setConfirmation(\YooKassa\Request\PaymentMethods\ConfirmationData\AbstractConfirmation|array|null $value = null) : self

Summary

Устанавливает confirmation.

Details:

Parameters:
Type Name Description
\YooKassa\Request\PaymentMethods\ConfirmationData\AbstractConfirmation OR array OR null value Данные, необходимые для инициирования сценария подтверждения привязки.

Returns: self -

public setHolder() : self

public setHolder(\YooKassa\Request\PaymentMethods\PaymentMethodHolder|array|null $value = null) : self

Summary

Устанавливает holder.

Details:

Parameters:
Type Name Description
\YooKassa\Request\PaymentMethods\PaymentMethodHolder OR array OR null value Данные магазина, для которого сохраняется способ оплаты.

Returns: self -

public setOptions() : \YooKassa\Common\AbstractRequestBuilder

public setOptions(iterable|null $options) : \YooKassa\Common\AbstractRequestBuilder

Summary

Устанавливает свойства запроса из массива.

Details:

Parameters:
Type Name Description
iterable OR null options Массив свойств запроса
Throws:
Type Description
\InvalidArgumentException Выбрасывается если аргумент не массив и не итерируемый объект
\YooKassa\Common\Exceptions\InvalidPropertyException Выбрасывается если не удалось установить один из параметров, переданных в массиве настроек

Returns: \YooKassa\Common\AbstractRequestBuilder - Инстанс текущего билдера запросов

public setType() : self

public setType(string|null $value = null) : self

Summary

Устанавливает type.

Details:

Parameters:
Type Name Description
string OR null value Код способа оплаты. Возможное значение: ~bank_card — банковская карта.

Returns: self -

protected initCurrentObject() : \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequest

protected initCurrentObject() : \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequest

Summary

Инициализирует объект запроса, который в дальнейшем будет собираться билдером

Details:

Returns: \YooKassa\Request\PaymentMethods\CreatePaymentMethodRequest - Инстанс собираемого объекта запроса к API


Top Namespaces


Reports


This document was automatically generated from source code comments on 2026-06-29 using phpDocumentor

© 2026 YooMoney