question

sureshgupta avatar image
sureshgupta asked sureshgupta answered

Spreedly integration with payment api

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.
PaymentsPaymentConnectorTaxes
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
sureshgupta avatar image
sureshgupta answered
Hi @Neil, I've seen in other posts that you could successfully integrated with Spreedly. It would be great help if you can help me understand what's wrong above or if you can just share the details on how have you generated pem file to be sent to Spreedly ?
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community