P
P
PRIZRAKeee2020-11-23 13:56:22
PHP
PRIZRAKeee, 2020-11-23 13:56:22

How to encrypt client card data for Tinkoff acquiring?

Hello. I have a task to make a payment for services on the site using the Tinkoff API. I had difficulties at the stage of encrypting customer card data. PHP programming language.
The Tinkoff website says that card data is encrypted with the X509 RSA 2048 public key (Requests tab https://oplata.tinkoff.ru/develop/api/payments/fin... ). It also says here that the bank issues a public key when registering the terminal.
5fbb91b5e5f4b235091902.png
Googling how this is all done, I came across an article on Habré ( https://habr.com/en/post/255799/ ). The article provides the following code, which is clear to me and everything would be fine, but I do not have a public key.

<?php
$pub = <<<SOMEDATA777
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALqbHeRLCyOdykC5SDLqI49ArYGYG1mq
aH9/GnWjGavZM02fos4lc2w6tCchcUBNtJvGqKwhC5JEnx3RYoSX2ucCAwEAAQ==
-----END PUBLIC KEY-----
SOMEDATA777;
$data = "PHP is my secret love.";
$pk  = openssl_get_publickey($pub);
openssl_public_encrypt($data, $encrypted, $pk);
echo chunk_split(base64_encode($encrypted));
?>

I was given the following data from Tinkoff: terminal (17 characters) and password (16 characters). But the public key was not issued. I contacted Tinkoff support and they told me that the terminal they gave me was enough. I'm a little confused, because I don't understand how I can encrypt the client's card data. Can you please tell me if I need to somehow generate the public key myself or do some other steps? Previously, I did not have to set up Internet acquiring, so there were difficulties and there was no one else to turn to for help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan_Google, 2020-11-23
@PRIZRAKeeee

No, generating the key yourself is not an option
, the whole point is that if you have a public key, that is, you have
a private public key, and only the bank has a private key and no one except the bank can decrypt the data encrypted with the public key. So swear at those. support.

M
menartIsH, 2020-12-03
@menartIsH

Why accept Card data on your website? There, on the Tinkoff website, data is entered, and when the payment is made, it pulls the webhook

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question