Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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(Request $reques)
- {
- try {
- $client = new Client();
- $client->setAuth('586253', 'test_UpTQTiA-frwOoqgf7Rrw3waKtDFgGPc8AIDCaChbrEs');
- $payment = $client->createPayment(
- array(
- 'amount' => array(
- 'value' => 100.0,
- 'currency' => 'RUB',
- ),
- 'confirmation' => array(
- 'type' => 'redirect',
- 'return_url' => 'http://bossphp.x:8080/#/',
- ),
- 'capture' => true,
- 'description' => 'Заказ №1',
- 'metadata' => array(
- 'order_id' => '37',
- )
- ),
- uniqid('', true)
- );
- // $payment = json_encode($payment);
- $payment = new Payment;
- $payment->status = $request->status;
- $payment->paid = $request->paid;
- $payment->value = $request->value;
- $payment->currency = $request->currency;
- $payment->type = $request->type;
- $payment->confirmation_url = $request->confirmation_url;
- $payment->description = $request->description;
- $payment->metadata = $request->metadata;
- $payment->account_id = $request->account_id;
- $payment->gateway_id = $request->gateway_id;
- $payment->refundable = $request->refundable;
- $payment->order_id = $request->order_id;
- $payment->save();
- // var_dump($payment);
- // dd($payment);
- } catch (\Exception $exception) {
- // $payment->status = Payment::STATUS['error'];
- // $payment->details = $exception->getMessage();
- return [
- 'status' => 'error',
- 'message' => $exception->getMessage(),
- ];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement