I've been trying to get a payment integration working using PHP. I've gotten all the Oauth stuff and access tokens working up to the point where I need to get a card token. I'm using openSSL and I've gotten phpseclib 3.0 working and I'm using the TA_PUBLIC_KEY_DEV key from the CDN. From what I've seen in the community here, the prefix is supposed to be 00000000 so I'm using that. Here's the code for where I generate the public key and encrypt the PAN:
$ta_public_key = bin2hex(base64_decode($TA_PUBLIC_KEYS['TA_PUBLIC_KEY_DEV'])); $modulus = substr($ta_public_key, 0, 512); $exponent = substr($ta_public_key, -5); $prefix = "00000000"; $rsa = PublicKeyLoader::load([ 'e' => new BigInteger($exponent, 256), 'n' => new BigInteger($modulus, 256) ]); openssl_public_encrypt($prefix.$cardnumber, $encrypted, "$rsa", OPENSSL_PKCS1_OAEP_PADDING);
The $rsa key seems to be a valid key, and the value at $encrypted looks good as far as I can tell, but I'm getting a 500 Internal Server Error when I try to POST it over to v1/tokens
From what I've read, a 500 error likely means that it was somehow not encrypted properly, but I can't figure out what I could be doing wrong. Is there some specific type of RSA encryption that needs to be specified in some way for openssl_public_encrypt? Am I grabbing the modulus and exponent properly and passing it to PublicKeyLoader properly?
The page at https://docs.clover.com/docs/ecommerce-generating-a-card-token mentions that you need to send a transarmor_key_id along with the post, with no explanation of what a transarmor_key_id is or where to find one. And that variable name is not even mentioned in the API reference page at https://docs.clover.com/reference/createtoken and I seem to be able to put the post through without that variable (it's a 500 error, but I'm not sure if the lack of a transarmor_key_id has anything to do with it) Do I need that? And if so, how do I get it?