D
D
derijopil2019-04-30 14:08:55
PHP
derijopil, 2019-04-30 14:08:55

How to get JSON in Yandex.Checkout?

We read the Yandex cash register documentation .


Send a request to Yandex.Checkout and pass in the data for creating a payment, authentication data (shop ID and secret key), and idempotency key (any random value will do).

use YandexCheckout\Client;

    $client = new Client();
    $client->setAuth('<Идентификатор магазина>', '<Секретный ключ>');
    $payment = $client->createPayment(
        array(
            'amount' => array(
                'value' => 100.0,
                'currency' => 'RUB',
            ),
            'confirmation' => array(
                'type' => 'redirect',
                'return_url' => 'https://www.merchant-website.com/return_url',
            ),
            'capture' => true,
            'description' => 'Заказ №1',
        ),
        uniqid('', true)
    );

OK, it's all done.
Further in the documentation it is written that the data will be received in the form of JSON.
{
  "id": "23d93cac-000f-5000-8000-126628f15141",
  "status": "pending",
  "paid": false,
  "amount": {
    "value": "100.00",
    "currency": "RUB"
  },
  "confirmation": {
    "type": "redirect",
    "confirmation_url": "https://money.yandex.ru/api-pages/v2/payment-confirm/epl?orderId=23d93cac-000f-5000-8000-126628f15141"
  },
  "created_at": "2019-01-22T14:30:45.129Z",
  "description": "Заказ №1",
  "metadata": {},
  "recipient": {
    "account_id": "100001",
    "gateway_id": "1000001"
  },
  "test": false
}

But at the same time, it is not written how exactly this data should be obtained.
Tried to get this JSON in this way:
print_r(json_encode($payment), true);
Doesn't work.
Tried it like that too
print_r(json_encode($payment,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));

does not work.
Which tambourine should be tapped to get this JSON?

Answer the question

In order to leave comments, you need to log in

9 answer(s)
D
derijopil, 2019-04-30
@derijopil

In short, the problem is solved. It turns out that's how it was possible to get the parameter I needed. But in the documentation about this, of course, not a word was written.

print_r($payment['confirmation']['confirmation_url']);

K
Konata Izumi, 2019-04-30
@Konata69lol

print_r(json_encode($payment), true);

Why are you encoding the received response in json?
The answer most likely comes in the form of a json string and you needjson_decode

S
sts, 2019-04-30
@stunoff

$Kassa->getPaymentInfo($Order->getPaymentId());

H
HamSter, 2017-03-31
@HamSter007

As a standard, on any site you can see the implementation.
Wrapper or link, inside an image:
Next, pseudo-elements are used:

a { display: block; position: relative; }

a:after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5);  opacity: 0; }

a:before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: url(icon-path); opacity: 0; }

a:hover:before,
a:hover:after { opacity: 1; }

The second option (more suitable if ext. also has a description text):
<a href="#" class="img__link"> 
  <img src="path" />
  <span class="img__mask"><i class="img__icon"></i></span>
</a>

Styles are about the same:
a { display: block; position: relative; }

.mask { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5);  opacity: 0; }

a:hover:after {
  opacity: 1;
}

P
Peter, 2017-03-31
@petermzg

Display on top of a black filled div and make it semi-transparent.

N
Negwereth, 2017-03-31
@Negwereth

CSS filters:
https://paulund.co.uk/css-filter
caniuse.com/#feat=css-filters

N
Nevada18, 2017-03-31
@Nevada18

hang hover on the img wrapper, make the icon visible: visible on hover.

.img_wrapper:hover {
  ...
  background: rgba(0,0,0,0.5) //прозрачность сами выставите
}

img_wrapper:hover .icon {
 visibility: visible
}

something like this

V
Vlad Feninets, 2017-03-31
@fnnzzz

<div class="block">
  ...
</div>

.block {
  position: relative;
}
.block::before {
  content: normal;
}

.block::after{
  content: normal;
}

.block:hover::before {
  content: ''
}

.block:hover::after {
  content: ''
}

.block::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  heigth: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.block::after {
  position: absolute;
  background: url('icon.png');
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

S
Sergey Leshchenko, 2017-03-31
@zellenka

For a quick one like this https://jsbin.com/pokunufiho/edit?html,css,output
But the icon will also be transparent. To eliminate this, you need to make a picture of the desired transparency and add a background to the block. By default, the hiding block is display: none, and to appear we write this .img-block:hover .hover-block{
display: block;
}
Well, add time to make it smooth.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question