Pass customer email to stripe

Created on 16 July 2023, over 1 year ago
Updated 16 May 2024, 7 months ago

Hi

First of all, many thanks for this great module, the best stripe module for Drupal I've seen until now

Problem/Motivation

On my website payments can only be done by logged in users. I guess it is common for a large majority of websites to allow orders and payments only for people logged in or having at least a verified email address. When using this module as payment gateway, the user is led to the stripe checkout page, where he is asked to re-enter his email address. At this stage, he could therefore enter a different address than the one registered on the website, leading to mismatches between website records and stripe records.

Steps to reproduce

Just use the module as designed.

Proposed resolution

Pass the customer email to stripe to allow filling the customer email address on stripe's side and disable the stripe email field. Note that this could be done as well for the physical address.

User interface changes

If the requirement I describe does not colère the need of 100% of users, then passing the customer email to stripe could be done only if a checkbox is ticked in the module configuration ?

Thanks you so much in advance for helping me achieving this!

Feature request
Status

Needs review

Version

1.2

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arno2mars
  • Hi again,

    Just to inform you that after a bit of research, I have found an incredibly easy way to achieve this by simply adding the two lines in bold in /src/PluginForm/CommerceStripeCheckoutCheckoutForm.php:

    try {
          if (class_exists('\Stripe\Stripe')) {
          // Set your Stripe API keys
            \Stripe\Stripe::setApiKey($secret_key);
    
            $success_redirect_url = Url::fromRoute('commerce_stripe_checkout.payment_success', ['stsess' => $stsess], ['absolute' => true])->toString();
            $cancel_redirect_url = Url::fromRoute('commerce_stripe_checkout.payment_cancel', ['stsess' => $stsess], ['absolute' => true])->toString();
          <strong>  $email = $order->mail->value;</strong>
    
          // Create a new checkout session
            $session = \Stripe\Checkout\Session::create([
              <strong>'customer_email' => $email,</strong>
              'payment_method_types' => ['card'],
              'line_items' => $line_items_data,
              'mode' => 'payment',
              'success_url' => $success_redirect_url,
              'cancel_url' => $cancel_redirect_url,
            ]);

    Hope it helps!

  • Assigned to sujan shrestha
  • Status changed to Needs review over 1 year ago
  • 🇳🇵Nepal sujan shrestha Nepal🇳🇵, Kathmandu

    Hi @Arno2Mars,

    Thanks for the Feature request.
    I have added the 'Pass customer email to stripe' checkbox option to the configuration. If this checkbox is checked, the customer email will be passed to stripe during checkout and if the checkbox is not checked on the configuration, the user can enter a different email address on the stripe payment.

  • Thanks a lot!
    Is it possible to do the same with the shipping address?

  • 🇳🇵Nepal sujan shrestha Nepal🇳🇵, Kathmandu

    Hi @Arno2Mars,

    I'm also planning for the billing and shipping address.

  • That's great!
    By the way I have tested version 1.0.2 and it works perfectly well!
    Thanks again

  • 🇬🇧United Kingdom joehuggans Harrogate, UK

    I've opened up an issue ticket here 📌 Ability to collect billing address Active for adding the functionality to collect a billing address

Production build 0.71.5 2024