I
I
igordata12020-02-27 21:30:20
Laravel
igordata1, 2020-02-27 21:30:20

How to insert data into the database that came from Yandex checkout in Jason format?

{
    "id": "111111111111111111111111111111111",
    "status": "pending",
    "recipient": {
        "account_id": "1",
        "gateway_id": "0"
    },
    "amount": {
        "value": "100.00",
        "currency": "RUB"
    },
    "description": "Заказ №1",
    "created_at": "2020-02-26T18:15:07+00:00",
    "confirmation": {
        "enforce": false,
        "confirmation_url": "[url]https://money.yandex.ru/[/url]",
        "type": "redirect"
    },
    "paid": false,
    "refundable": false,
    "metadata": {
        "order_id": "37"
    },
    "test": true
}


<?php

namespace App\Http\Controllers\Api\v1;

use Illuminate\Http\Request;
use YandexCheckout\Client;
use YandexCheckout\Model\Payment;
use App\Http\Controllers\Controller;

class PaymentController extends Controller
{
    public function index()
    {
        try {
            $client = new Client();
            $client->setAuth('__', '__');
            $payment = $client->createPayment(
                array(
                    'amount' => array(
                        'value' => 100.0,
                        'currency' => 'RUB',
                    ),
                    'confirmation' => array(
                        'type' => 'redirect',
                        'return_url' => '[url]http://p.x:8080/#/[/url]',
                    ),
                    'capture' => true,
                    'description' => 'Заказ №1',
                    'metadata' => array(
                        'order_id' => '37',
                    )
                ),
                uniqid('', true)
            );
            return $payment;
//            var_dump($payment);
//            dd($payment);
        } catch (\Exception $exception) {



            return [
                'status' => 'error',
                'message' => $exception->getMessage(),
            ];
        }
    }


json_decode I understand, but how to insert them into a table in the database

uniqid('', true)
            );
            $payment = new PaymentController($payment);
            $payment1->status = 'status';
            $this->paid = 'paid';
            $this->value = 'value';
            $this->currency = 'currency';
            $this->type = 'type';
            $this->confirmation_url = 'confirmation_url';
            $this->description = 'description';
            $this->metadata = 'metadata';
            $this->account_id = 'account_id';
            $this->gateway_id = 'gateway_id';
            $this->refundable = 'refundable';
            $this->order_id = 'order_id';
            $this->save();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question