V
V
Vlad Volodko2018-02-06 17:03:47
PHP
Vlad Volodko, 2018-02-06 17:03:47

How to make a subscription on the site through liqpay?

Hello. It is necessary to implement a paid subscription on the site for a month or two, or for the user to indicate the period himself. Liqpay was chosen to implement this case. But I ran into the problem that I can not get a callback from liqpay about a payment that was just made.
So far, I have written such a code for sending data to liqpay.

$private_key = "многоразныхбукв";
$public_key = "многоцыфрибуква";
$json_string = json_encode(
  array(
  "version" => "3",
  "public_key" => $public_key, 
  "amount" => "1", 
  "currency" => "UAH",
  "description" => "Назначение платежа", 
  "type" => "subscribe",
  "resp_format" => "json",
  "order_id" => date("d/m/Y-H:i:s"),
  "server_url" => route("projects"),
  "result_url" => route("projects"),
  "sandbox" => "1"
  )
);
$data = base64_encode( $json_string );
 
$signature = base64_encode( sha1($private_key . $data . $private_key, 1 ));

<form id="liqpay" method="POST" action="https://www.liqpay.com/api/checkout" accept-charset="utf-8">
  <input type="hidden" name="data" value="{{ $data }}" />
  <input type="hidden" name="signature" value="{{ $signature }}" />
  <input type="submit">
</form>

How can I get information about it? How to process response in laravel? What is the best way to organize a database to store information about user subscriptions?
I've always had problems with api

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-02-06
@QcfgAlexandr

Try to initially create a payment in your database, and only after that send a request to liqpay.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question