Created
June 13, 2023 14:27
-
-
Save abdullahessam/45c85626d015b609d28288780221cd50 to your computer and use it in GitHub Desktop.
digital signature for BAB integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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