question

tvang avatar image
tvang asked David Marginian answered

TOKENIZATION SERVICE API

I am trying to create a card token following the documentation but keep getting the 400 error when calling the API.


  1. export default async (req, res) => {
  2. try {
  3. const response = await fetch("https://token.clover.com/v1/tokens", {
  4. method: "POST,
  5. headers: {
  6. Accept: "application/json",
  7. apiKey: process.env.CLOVER_PUBLIC,
  8. "Content-Type": "application/json",
  9. },
  10. body: {
  11. card: {
  12. number: "411111111111",
  13. exp_month: "07",
  14. exp_year: "2023",
  15. cvv: "123",
  16. },
  17. },
  18. });
  19. const data = await response.json(
  20. } catch (err) {
  21. console.log(err);
  22. }
  23. };

that is the code I'm using to call on my server side, if this does not work the documentation says i can also use an 'alternate_tender' as a source of payment. What can be considered an 'alternate_tender'?

API Token
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

·
David Marginian avatar image
David Marginian answered

Your body contains invalid JSON, you need to remove the "," after the cvv. Do you have PCI DSS certification? If not you should not be obtaining the token via API:

https://docs.clover.com/docs/ecommerce-generating-a-card-token#api-only-integrations

https://docs.clover.com/docs/ecommerce-integration-type

  1. For using the API only integration in production, you must have (or use a service that has) a PCI DSS certification.


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

HTML Editor


Add some details...
Characters : 0
Tab to the formatting toolbar with Alt/Option + F10. If inside toolbar, press ESC to return to editor. 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