[#1230] Signature is not set error

Migrated from Redmine #1230 | Author: Tudor Cotop
Status: Feedback | Priority: High, I’m very impatient | Created: 2024-05-07


I have been trying to build a custom payment processor, following the steps described here: sbpay-sdk/example/custom_payment_processor/config.php at main · dimkasb/sbpay-sdk · GitHub. I’ve done what I think should be done, but when calling this line here: $client->payments()->validateCustomPaymentProcessorRequest($_POST);, I get the error “Signaturs is not set”.

That makes me believe that maybe the way I’ve configured the client is not correct. According to the documentation, I need these four values:

const SBPAY_TOKEN = ‘xxxxx’;
// Your SBPay secret
const SBPAY_SECRET = ‘xxxxx’;
// Your SBPay merchant
const SBPAY_MERCHANT = ‘xxxxx’;
// SBPay host
const SBPAY_HOST = ‘https://app.sbpay.me/’;

For the TOKEN, I’ve used the API key, and for the secret I’ve used the API secret. I’ve left the HOST the same as in the demo, and for merchant, I’ve used londontest (my URL is: https://londontest.simplybook.it/).

Can you check that I’m using the correct values?

Dmytro Bondarev wrote:

Hi, could you please clarify if you use simplybook keys or sbpay?
You should get it from sbpay, please make admin user in sbpay and you will be able to obtain a pay keys.

Tudor Cotop wrote:

Dmytro Bondarev wrote:

Hi, could you please clarify if you use simplybook keys or sbpay?
You should get it from sbpay, please make admin user in sbpay and you will be able to obtain a pay keys.

Hi Dmytro,

Thanks for getting back to me on this one. Could you help me figure out how I can create an admin user in sbpay?

Thanks,
Tudor

Dmytro Bondarev wrote:

Hi, just login to sbpay from simplybook and then go to Users section in sbpay and create new user.

Tudor Cotop wrote:

Hey Dmytro,

I’ve created an SBPay account, and I’ve changed the values for SBPAY_TOKEN and SBPAY_SECRET to match the ones I have in SBPay (authentication token and secret key). I’ve used “londontest” as the merchant id, and ‘https://londontest.sbpay.me/’ as the SBAY_HOST, and I still get a signature error

Dmytro Bondarev wrote:

Hi, the host must be https://app.sbpay.me/

Tudor Cotop wrote:

Still the same error. Is the merchant id correct?

Dmytro Bondarev wrote:

Yes, correct.
Please provide code if you use SDK or HTTP requests if you use API.

Tudor Cotop wrote:

This is the code I’m using:

$client = new \SBPay\SBPayClient(
$data->sbpay_token, $data->sbpay_secret,
$data->sbpay_merchant, ‘https://app.sbpay.me/
);

try {
// Validate request that comes from SBPay
$client->payments()->validateCustomPaymentProcessorRequest($_POST);
} catch (\SBPay\Exceptions\Exception $e) {
// handle exception. Just show error message for demo purposes
die($e->getMessage());
}

It should be the same as the example provided on GitHub. The $data is something I read from the DB, and it’s populated correctly.

Dmytro Bondarev wrote:

Hi, please provide $_POST data.

Tudor Cotop wrote:

For whatever reason the POST that is being sent is redirected to a GET on my end. That’s definitely an issue so I’ll need to look into it.

But if I just run the example on your Github, it doesn’t work, because of this error. Is that the intended behaviour? To get the Signature not set error, when there’s no POST data?

Dmytro Bondarev wrote:

Yes, if you don’t have data in POST (or request is not POST) then you will receive this error.

Tudor Cotop wrote:

All good now, and working as expected. Thanks for the help.