I have been stuck on this issue with the Pay V2 API ( https://docs.clover.com/build/developer-pay-api/)
It is giving me an encryption block is invalid error and I cannot seem to figure out why it is not working. The failure message isn't the best. I have thoroughly followed the documentation for the card encryption. I am stuck.
I did the encryption two different ways.
1) Added the prefix from the first GET request to the card number and used that to encrypt
card_num = secrets['prefix'] + card['card_number'] RSAkey = RSA.construct((int(secrets['modulus']), int(secrets['exponent']))) key = RSAkey.publickey() encrypted = key.encrypt(int(card['card_number']), card_num) card_encrypted = b64encode(str(encrypted[0]))
2) Did NOT add the prefix to the card number initially, just used the card number and prefix to encrypt.
RSAkey = RSA.construct((int(secrets['modulus']), int(secrets['exponent']))) publickey = RSAkey.publickey() encrypted = publickey.encrypt(int(card['card_number']), secrets['prefix']) card_encrypted = b64encode(str(encrypted[0]).encode()If anyone is able to assist with this, I would be grateful.
Best Regards,