gopay-inline icon indicating copy to clipboard operation
gopay-inline copied to clipboard

How to create signature?

Open jAKErCZ opened this issue 3 years ago • 2 comments

Hi, according to the gopay documentation, it goes this way.

$encryptedSignature = GopayHelper::encrypt(
                      GopayHelper::hash(
                      GopayHelper::concatPaymentCommand($targetGoId,
                                                        $paymentSessionId,
                                                        $secureKey)
                                                     ), $secureKey);	

But the data that my response returns is

'id' => 3156614799
'order_number' => 'INF252'
'state' => 'CREATED'
'amount' => 605
'currency' => 'CZK'
'payer' => stdClass
'target' => stdClass
'recurrence' => stdClass
'additional_params' => array
'lang' => 'cs'
'gw_url' => 'https://gw.sandbox.gopay.com/gw/v3/4e26c514484f8c7fd08f45177aa503c4'

So what is the procedure for creating a signature? Because I didn't find any solution anywhere.

Thx

jAKErCZ avatar Oct 13 '21 15:10 jAKErCZ

Well, I don't know. I need more info. Do you know @PavelJurasek?

f3l1x avatar Nov 02 '21 16:11 f3l1x

According to the information, something like this works.

  $paymentSessionId = trim($response->data['gw_url'], 'https://gw.sandbox.gopay.com/gw/v3');
                $encryptedSignature = GopayHelper::encrypt(
                    GopayHelper::hash(
                        $response->data['id'] . '|' . $paymentSessionId . '|' . GoPayService::settings()['secretKey']
                    ), GoPayService::settings()['secretKey']);

But I don't know if it's a good solution but it works.

jAKErCZ avatar Nov 10 '21 10:11 jAKErCZ