Advertisement
phpist

Untitled

Feb 27th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Api\v1;
  4.  
  5. use Illuminate\Http\Request;
  6. use YandexCheckout\Client;
  7. use YandexCheckout\Model\Payment;
  8. use App\Http\Controllers\Controller;
  9.  
  10. class PaymentController extends Controller
  11. {
  12. public function index(Request $reques)
  13. {
  14. try {
  15. $client = new Client();
  16. $client->setAuth('586253', 'test_UpTQTiA-frwOoqgf7Rrw3waKtDFgGPc8AIDCaChbrEs');
  17. $payment = $client->createPayment(
  18. array(
  19. 'amount' => array(
  20. 'value' => 100.0,
  21. 'currency' => 'RUB',
  22. ),
  23. 'confirmation' => array(
  24. 'type' => 'redirect',
  25. 'return_url' => 'http://bossphp.x:8080/#/',
  26. ),
  27. 'capture' => true,
  28. 'description' => 'Заказ №1',
  29. 'metadata' => array(
  30. 'order_id' => '37',
  31. )
  32. ),
  33. uniqid('', true)
  34. );
  35. // $payment = json_encode($payment);
  36. $payment = new Payment;
  37. $payment->status = $request->status;
  38. $payment->paid = $request->paid;
  39. $payment->value = $request->value;
  40. $payment->currency = $request->currency;
  41. $payment->type = $request->type;
  42. $payment->confirmation_url = $request->confirmation_url;
  43. $payment->description = $request->description;
  44. $payment->metadata = $request->metadata;
  45. $payment->account_id = $request->account_id;
  46. $payment->gateway_id = $request->gateway_id;
  47. $payment->refundable = $request->refundable;
  48. $payment->order_id = $request->order_id;
  49. $payment->save();
  50.  
  51.  
  52. // var_dump($payment);
  53. // dd($payment);
  54. } catch (\Exception $exception) {
  55.  
  56. // $payment->status = Payment::STATUS['error'];
  57. // $payment->details = $exception->getMessage();
  58.  
  59. return [
  60. 'status' => 'error',
  61. 'message' => $exception->getMessage(),
  62. ];
  63. }
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement