Hi Team,
We are trying to use Spreedly to store the card information in their vault and process the payment with public key from GET /v2/merchant/{mId}/pay/key as mentioned in the docs -
https://docs.clover.com/clover-platform/docs/developer-pay-api.
However, the requests are failing in Spreedly for the cardEncrypted field. Below are the steps I'm using in java.
1. Generate RSA public key using base 10 mod and exponent.
2. Take byte array from key
3. Encode with base 64
4. Add header and footer as BEGIN and END certificate
I'm referring to spreedly format using the link -
https://docs.spreedly.com/reference/api/v1/?json#replace and their blog for clover integration
https://www.spreedly.com/blog/building-a-clover-application-with-spreedly
and eventually the mocked json payload for POST /v2/merchant/{mId}/pay api looks like this:
"{\"orderId\":\"afdsfas\",\"expMonth\":\"{
{ credit_card_month }}\",\"amount\":4798,\"currency\":\"USD\",\"expYear\":\"{
{ credit_card_year }}\",\"first6\":\"{
{#truncate}}6,{
{ credit_card_number }}{
{/truncate}}\",\"cardEncrypted\":\"{
{#base64}}{
{#rsa}}-----BEGIN CERTIFICATE-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmGgJuJyR5WYe4p7U0Km2nHCYy5Vapo6s\r\nCdreAt6Rv0DnfBNnFXwC8I1OyB5sbEPlo83dOLfJzrKMWgyFz\/K\/aS4a\/5FK29wRGpumKe9LsC8A\r\nFHg\/mBuD+ksMhwB9rjibFMNC8I47d9S6xBzwhYEb2in33DD+K8krjku4hyY4OKRXsqDC47Cur3X5\r\nu8MY\/hw0b2x\/9wkLWCH+ANQizTn\/sgEarPGbOgTX4AdEL2voCZ8r0kmYPresFqtybOMb1BiYn5AL\r\nUqMtrVKZalBzrHJjE9yeQ\/9QUkIJHuaqFdHrdPxWsmHelUYFgVpvShukuewmEFc3fQGSJ3OdraKY\r\nOiiKrQIDAQAB\r\n-----END CERTIFICATE-----,oaep,null{
{ credit_card_number }}{
{/rsa}}{
{/base64}}\",\"last4\":\"'{
{#last}}4,{
{ credit_card_number }}{
{/last}}\",\"cvv\":\"{
{ credit_card_verification_value }}\"}"
Can someone please help me understand what am I doing wrong and why is it failing in Spreedly request validation. If I just remove the cardEncrypted field then Spreedly accepts the request.