Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abdullahessam/45c85626d015b609d28288780221cd50 to your computer and use it in GitHub Desktop.
Save abdullahessam/45c85626d015b609d28288780221cd50 to your computer and use it in GitHub Desktop.
digital signature for BAB integration
first create sign function and pass the private key and the passphrase if needed
public function sign(string $data): string
{
$privateKey = openssl_pkey_get_private($the_private_key_file,$passphrase_if_needed);
if (!$privateKey) {
throw new Exception("Failed to load private key : " . openssl_error_string());
}
// sign data using the private key with SHA256 algorithm
$encryptedData = "";
openssl_sign($data, $encryptedData, $privateKey, "sha256WithRSAEncryption");
// Return the signed data
return base64_encode($encryptedData);
}
$path = "/v1/transfer/local";
$timestamp='';
$client_secret=config('payment.BAB.client_secret');
$encoded_payload=json_encode($payload);
$data="{$client_secret},{$timestamp},{$path},,{$encoded_payload}";
return sign($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment