M
M
MrChen2016-09-29 19:37:17
ROBOKASSA
MrChen, 2016-09-29 19:37:17

How to use idma/robokassa library in laravel?

Hello! Many who use laravel to work with Robokassa advised this library: https://github.com/idma/robokassa
I'm a little confused about how to use this library. Let's say the readme file on Github provides this example:

$payment = new \Idma\Robokassa\Payment(
    'john_doe', 'password1', 'password2', true
);

$payment
    ->setInvoiceId($order->id)
    ->setSum($order->amount)
    ->setDescription('Payment for some goods');

// redirect to payment url
$user->redirect($payment->getPaymentUrl());

In this example, as far as I understand, first we indicate personal data: a nickname and two passwords. Further, when creating a URL, do not understand where the $order variable came from. And then the most incomprehensible:
1) I don’t understand how this code shows a redirect.
2) I replaced the line $user->redirect($payment->getPaymentUrl());with return Redirect::to($payment->getPaymentUrl());, but when redirecting, it redirects me to the main page of the robokassa with the specified parameters in the URL, but nothing happens.
Help me please.
PS The store is identified and everything should work. Also, do you need to create a separate table for payments?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2016-09-29
@Adamos

don't understand where the $order variable came from

from your store. For a payment request, you need a unique order id, its amount and its name (in the example, it is just text, but it makes sense to replace it with a real name, since the user on the Robokassa website will be asked to pay for this).
Without these parameters, Robokassa, of course, will not offer you anything. What to pay for?
Again, a question for your store. You must store orders so that when Robokassa confirms your payment, check the amount to see if the user forged it on the way. In the same table, you can also store information about the payment for this order.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question