S
S
Sergey2019-09-25 14:50:29
PHP
Sergey, 2019-09-25 14:50:29

How to get data from the Yandex Checkout API array?

Hello, I create a payment with this code

use YandexCheckout\Client;

    $client = new Client();
    $client->setAuth('000000', 'test_UBynaQ4beNmiGv5Rz8CaOjn');
    $payment = $client->createPayment(
        array(
            'amount' => array(
                'value' => 500.0,
                'currency' => 'RUB',
            ),
            'confirmation' => array(
                'type' => 'redirect',
                'return_url' => 'https://www.merchant-website.com/return_url',
            ),
            'capture' => true,
            'description' => 'Заказ №1',
            'metadata' => array(
                'order_id' => '37',
            )
        ),
        uniqid('', true)
    );

When outputting print_r I get:
YandexCheckout\Request\Payments\CreatePaymentResponse Object ( [_id:YandexCheckout\Model\Payment:private] => 251d67aa-000f-5000-9000-172[_status:YandexCheckout\Model\Payment:private] => pending [_recipient:YandexCheckout\Model\Payment:private] => YandexCheckout\Model\Recipient Object ( [_accountId:YandexCheckout\Model\Recipient:private] => 000000 [_gatewayId:YandexCheckout\Model\Recipient:private] => 1627085 [unknownProperties:YandexCheckout\Common\AbstractObject:private] => Array ( ) ) [_amount:YandexCheckout\Model\Payment:private] => YandexCheckout\Model\MonetaryAmount Object ( [_value:YandexCheckout\Model\MonetaryAmount:private] => 50000 [_currency:YandexCheckout\Model\MonetaryAmount:private] => RUB [unknownProperties:YandexCheckout\Common\AbstractObject:private] => Array ( ) ) [_description:YandexCheckout\Model\Payment:private] => Заказ №1 [_paymentMethod:YandexCheckout\Model\Payment:private] => [_createdAt:YandexCheckout\Model\Payment:private] => DateTime Object ( [date] => 2019-09-25 11:47:54.736000 [timezone_type] => 2 [timezone] => Z ) [_capturedAt:YandexCheckout\Model\Payment:private] => [_confirmation:YandexCheckout\Model\Payment:private] => YandexCheckout\Model\Confirmation\ConfirmationRedirect Object ( [_enforce:YandexCheckout\Model\Confirmation\ConfirmationRedirect:private] => [_returnUrl:YandexCheckout\Model\Confirmation\ConfirmationRedirect:private] => [_confirmationUrl:YandexCheckout\Model\Confirmation\ConfirmationRedirect:private] => https://money.yandex.ru/api-pages/v2/payment-confirm/epl?orderId=251d67aa-000f-5000-9000-172 [_type:YandexCheckout\Model\Confirmation\AbstractConfirmation:private] => redirect [unknownProperties:YandexCheckout\Common\AbstractObject:private] => Array ( ) ) [_refundedAmount:YandexCheckout\Model\Payment:private] => [_paid:YandexCheckout\Model\Payment:private] => [_refundable:YandexCheckout\Model\Payment:private] => [_receiptRegistration:YandexCheckout\Model\Payment:private] => [_metadata:YandexCheckout\Model\Payment:private] => YandexCheckout\Model\Metadata Object ( [unknownProperties:YandexCheckout\Common\AbstractObject:private] => Array ( [order_id] => 37 ) ) [_expiresAt:YandexCheckout\Model\Payment:private] => [_cancellationDetails:YandexCheckout\Model\Payment:private] => [_authorizationDetails:YandexCheckout\Model\Payment:private] => [_test:YandexCheckout\Model\Payment:private] => 1 [unknownProperties:YandexCheckout\Common\AbstractObject:private] => Array ( ) )

How can I get this redirect link: https://money.yandex.ru/api-pages/v2/payment-confi... ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2019-09-25
@deepprod

$payment->getConfirmation()->getConfirmationUrl(); //Это и будет ваша ссылка

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question