Search code examples
node.jspugstripe-paymentsfoxycart

FoxyCart credit card payment testing


Currently, I want to use FoxyCart to handle the shopping cart and checkout process of my website. The payment gateway behind is Stripe. I am actually using the card numbers for testing provided by stripe for the checkout.

This is what I filled in: enter image description here

I am trying to make things work, however.....

This message comes out when I completed the checkout form and click the checkout button:

Error: Your payment was declined for the following reason: Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing.

Stripe told me that they declined my request: enter image description here

I don't quite understand how do checkout testing using the test tokens which was the method they suggested. Is there any can help me? I just want to make it work. Please feel free to give me other solution if you have one.

These are what I have done so far:

Checkout.pug

extends ../../layouts/layout-checkout

block content
  // link example
  a(href='https://playground.foxycart.com/cart?name=Cool%20Example&price=10&color=red&code=sku123') Add a red Cool Example
  // form example
  form(action='https://whre-playground2.foxycart.com/cart', method='post', accept-charset='utf-8')
    input(type='hidden', name='name', value='Cool Example')
    input(type='hidden', name='price', value='10')
    input(type='hidden', name='code', value='sku123')
    label.label_left Size
    select(name='size')
      option(value='small') Small
      option(value='medium') Medium
      option(value='large') Large
    input.submit(type='submit', value='Add a Cool Example')

doctype html

layout-checkout.pug

html(lang="en")
  head
    //include ../scripts/meta/HeadTags.pug
    block title
    link(rel='stylesheet', href='/dist/css/whre.css')/
    include ../scripts/meta/GAnalytics.pug


  body


    block content

    script(src='/dist/js/bundle.min.js')
    script(data-cfasync='false', src='https://cdn.foxycart.com/playground/loader.js', async='', defer='')
    include ../scripts/Hotjar.pug
    block extraScripts

checkout.js

var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
    res.render('pages/main/Checkout');
});

module.exports = router;

Solution

  • This error message happens when you send card details directly in the API server-side, instead of tokenizing. This usually has some PCI compliance implications so Stripe blocks it by default.

    Usually, you need to change your integration to properly tokenize client-side with Elements or Checkout.

    In your case though you don't control the code or integration since you are using a third-party platform called FoxyCart. They are the ones who should either start tokenizing client-side, or use Stripe Connect to make API requests on your behalf instead.

    I would recommend talking to them (FoxyCart) about this issue so that they can upgrade their integration.