#stereozwo

1 messages · Page 1 of 1 (latest)

gleaming estuaryBOT
plain plume
#

Can you share an example setup intent? I'm not sure I fully understand what you're trying to do here.

surreal lodge
#

Okay, wait, I will copy short one of my script

#

$('#register-form').on('beforeSubmit', function (event) {

event.preventDefault();
stripe.confirmSetup({
  elements,
  confirmParams: {
    return_url: window.location.href,
  },
   redirect: "if_required",
}).then(function(result) {
  
  if (result.error) {
    // Display error.message in my UI.
   return false;
  } else {
    // The SetupIntent was successful!
    stripeIntentHandler(result.setupIntent);
  }
});

return false;

});

function stripeIntentHandler(setupIntent) {
// Insert the setupIntent into the form so it gets submitted to the server
var form = document.getElementById('register-form');
$('#registerform-payment_method').val(setupIntent.payment_method);
form.submit();
}

#

This is my js

#

On before submit in case of paymentw with card, the setupInent is insert in hidden field and the form submit in stripeIntentHandler()

#

after submit I save my customer to db

#

but in case of paypal, the stripe js redirects my customer direkt to paypal and the information in the checkout form (email, password) is lost, when paypal redirect back to my site

#

The checkout works very well with a credit card and I would like to add paypal. Does the type of checkout have to be fundamentally changed for this?

#

I hope I was able to explain it in a way that was understandable.

plain plume
#

Gotcha - yes you're going to need to make changes to handle payment methods that require redirects

#

That's what the return_url is for, that's where your customer will be redirected to after the redirect flow is done

#

and that will include some details about the intent (setup intent ID, eg) then you can look up the payment method from there

#

But the way you're doing things now won't work with redirect methods

surreal lodge
#

My idea was to save the customer before redirecting to paypal. Is there a way to know that the customer has selected PayPal before being redirected? You know what I mean?

#

In my UI and checkout, the customer enters all their information on one page. The Stripe payment element is also integrated into this form. Everything happens on one page so far.

#

The 3DS dialog also works very well here, as it is opened in a modal.

plain plume
surreal lodge
#

This is a very good approach that could help me!

#

I am trying to find a solution with this and adjust the checkout.