Stripe integration with 3D Secure

1k views Asked by At

I have an Express app that I had successfully tested with tokenisation of payments. As I'm in the UK and will be accepting mainly UK cards, I believe I need to implement 3D Secure handling. I'm really struggling to understand the official documentation - examples are few and far between in my opinion. From the following: https://stripe.com/docs/sources/three-d-secure

I have got Sources working instead of Card payments using tokens. This is step 1. Step 2 requires that I determine if the card supports 3D Secure. I have been doing this client side but am not sure how to handle this subsequently - I have been attempting to send the user for a card payment if 3D Secure is not required. BUT if it is required, do i need to create another Source? And do I do this server or client side? I also cannot get the return_url field to do anything - 3D Secure cards simply fail.

Are there any examples out there that would help me? I am finding the official docs simply tell you roughly what to do with not much in the way of 'how' to do things.

I should add I am using v3 with Elements, NOT Checkout.

Thanks for any help.

edit: the below server-side doesn't seem to do anything:

stripe.sources.create({
amount: 6500,
currency: 'gbp',
type: "three_d_secure",
three_d_secure: {
  card: stripeSource,
},
redirect: {
  return_url: "http://example.com"
}
  })

The documentation states "To allow your customer to verify their identity using 3D Secure, redirect them to the URL provided within theredirect[url] attribute of the Source object."

My source object doesn't contain this field?

edit: This is what I have now. The redirect works, but as soon as I authorize the payment, the card declines:

stripe.customers.create({
  email: cust_email,
  source: stripeSource
  }).then(function(customer){
  return stripe.charges.create({
    amount: fee,
    description: "Client Ref: " + clientref,
    currency: "gbp",
    customer: customer.id,
    metadata: {
      'allocation:': allocate
    },
    receipt_email: cust_email,
    source: request.query.source,
  })
}
  ).catch(err => {
    console.log(err)
  })

  stripe.sources.create({
    amount: fee,
    currency: 'gbp',
    type: "three_d_secure",
    three_d_secure: {
      card: stripeSource,
   },
redirect: {
  return_url: "http://localhost:8000/charge"
}
 }).then(function(test) {
    response.redirect(test.redirect.url)
 })
0

There are 0 answers