Good afternoon Habra community!
I faced liqpay payment system. In principle, the system creates a very pleasant first impression.
But when I tried to integrate it on the site, I ran into several shortcomings and problems.
I would like to share their description and decision with you.
Support Forum
Very funny picture - skim over the forum, looking for answers to my questions about the API and integration. The vast majority of answers from liqpay: “a letter with a solution to your problem has been sent to the mail” ...
Is this, sorry, for such a forum? Communication through private? Why is it needed then, if to get an answer, I still need to write a letter to support?
Solutions, I'm sorry I did not find. I think that the support service still understands that it is easier to give a public answer than to answer privately to anyone who has a problem.
Formulations
The second surprise for me was not the exact wording of the terms.
For example, on the page chosen by me "API for accepting payments in favor of the merchant":
Merchant password (merchant_sig) is a unique merchant record, which is issued during registration of your store in our system.
You can view your merchant_id (merchant's number) and merchant_sig (merchant's {password} signature) in the Store Settings section after authorization.
Quote from "Installation Instructions Liq & Buy 1.2"
It turns out that during registration, the merchant is given two signatures, and none of them are called merchant_sig ...
One is titled “Signature for the send money API LiqPay operation”, the other “Signature for other operations.”
So, for receiving payments by means of API via the Internet, not the one with the words “API LiqPay” is suitable, but the one that is used for other operations.
')
PHP version and sha1
I did not find (or simply did not see) information about the PHP version in the integration recommendations. As it turned out, such a system requirement liqpay still exposes.
Code examples:
PHP: $ sign = base64_encode (sha1 ($ merc_sign. $ Xml. $ Merc_sign, 1));
Perl: $ sign = encode_base64 (sha1 ($ merc_sign. $ Xml. $ Merc_sign));
Quote from "Installation Instructions Liq & Buy 1.2 :: Creating a signature signature"
I support a number of projects in PHP version 4, so I wrote the first test for her. The interpreter gave me an error of inconsistency in the number of parameters for the function Sha1. As a normal developer, I refer to the documentation and see that the second, optional parameter was introduced only in version 5.0.0
Decision:
- Simple: upgrade to PHP 5
- Difficult (:)): Read carefully the documentation and understand the difference in the work of a function with and without a parameter.
Without the sha1 parameter, gives the hash as a 40-bit hexadecimal number.
With the parameter - a hash, in the form of a binary string of 20 characters.
Accordingly, do you need to convert a 40-bit hexadecimal number to a binary string? consisting of 20 characters.
As it turned out, this is done quite simply - the
Pack function will do it for you :)
Total
PHP5:sha1($str,true) = PHP4:pack( "H40", sha1($str) )
Voila :)
If it is interesting and there are more situations - I will surely accomplish my goal :)