Stripe V3 SCA

Ask the community for help and support.
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Has thanked: 38 times
Been thanked: 102 times

Stripe V3 SCA

Post by raiwa »

I am noticing that if customer dont fill State/ Province, Stripe does not show credit card data field on checkout page.
- so the stripe module can be selected on the checkout payment page, but it doesn’t show the card input field on checkout confirmation?
- do you have a zone assigned in the module?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
zeeshop
Posts: 78
Joined: Sun Jan 10, 2021 11:30 pm
Has thanked: 15 times
Been thanked: 2 times

Re: Stripe V3 SCA

Post by zeeshop »

Thanks @raiwa
raiwa wrote: Sat Mar 13, 2021 9:03 pm - so the stripe module can be selected on the checkout payment page, but it doesn’t show the card input field on checkout confirmation?
That's Correct, but only when State/ Province field in address field is left blank
raiwa wrote: Sat Mar 13, 2021 9:03 pm - do you have a zone assigned in the module?
Payment Zone is set to None, as shown in attached image.
Capture.PNG
Thanks
You do not have the required permissions to view the files attached to this post.
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Has thanked: 38 times
Been thanked: 102 times

Re: Stripe V3 SCA

Post by raiwa »

I’ll check tomorrow
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Has thanked: 38 times
Been thanked: 102 times

Re: Stripe V3 SCA

Post by raiwa »

Hi,
I checked and even the error is produced in the stripe module, the reason is in the customer data state module.
If no state is enterd, it should be set to '' (empty string) instead of null.
In: includes/modules/customer_data/cd_state.php
change lines 69-77 to:

Code: Select all

        case 'state':
          if (!isset($customer_details[$field])) {
            $customer_details[$field] = $customer_details['state']
              ?? $customer_details['entry_state'] ?? '';
          }

          if (!$customer_details[$field]) {
            $customer_details[$field] = tep_get_zone_name($GLOBALS['customer_data']->get('country_id', $customer_details), $this->get('zone_id', $customer_details), '');
          }
Note: null replaced by '' in line 72 and 76

@ecartz ?

Error message is:
Fatal error: Uncaught TypeError: Argument 1 passed to Text::output() must be of the type string, null given, called in C:\xampp_7.4.11\htdocs\***********\includes\functions\general.php on line 55 and defined in C:\xampp_7.4.11\htdocs\***********\includes\system\versioned\1.0.7.other\1.0.7.12\text.php:40 Stack trace: #0 C:\xampp_7.4.11\htdocs\***********\includes\functions\general.php(55): Text::output(NULL, false) #1 C:\xampp_7.4.11\htdocs\***********\includes\modules\payment\stripe_sca.php(183): tep_output_string(NULL) #2 C:\xampp_7.4.11\htdocs\***********\includes\system\versioned\1.0.7.3\payment.php(166): stripe_sca->confirmation() #3 C:\xampp_7.4.11\htdocs\***********\templates\default\includes\pages\checkout_confirmation.php(123): payment->confirmation() #4 C:\xampp_7.4.11\htdocs\***********\checkout_confirmation.php(25): require('C:\\xampp_7.4.11...') #5 {main} thrown in C:\xampp_7.4.11\htdocs\***********\includes\system\versioned\1.0.7.other\1.0.7.12\text.php on line 40
The code in the stripe module producing the error is:

Code: Select all

          'address_state' => tep_output_string(tep_get_zone_name($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state'])),
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
zeeshop
Posts: 78
Joined: Sun Jan 10, 2021 11:30 pm
Has thanked: 15 times
Been thanked: 2 times

Re: Stripe V3 SCA

Post by zeeshop »

Thanks very much @raiwa

These changes fixed the issue :)
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Stripe V3 SCA

Post by ecartz »

Wouldn't it make more sense to change

Code: Select all

          'address_state' => tep_output_string(tep_get_zone_name($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state'])),
to

Code: Select all

          'address_state' => tep_output_string(tep_get_zone_name($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state'] ?? '')),
Then subsequent core changes won't overwrite you.

Or even

Code: Select all

          'address_state' => tep_output_string($GLOBALS['customer_data']->get('state', $order->billing) ?? ''),
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Has thanked: 38 times
Been thanked: 102 times

Re: Stripe V3 SCA

Post by raiwa »

It would solve it, but I thought the root of the problem is in the customer data module. Empty state should produce empty string, not null. Otherwise the same issue may appear in other places.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Has thanked: 38 times
Been thanked: 102 times

Re: Stripe V3 SCA

Post by raiwa »

Matt @ecartz ,

O.K. I applied your suggestion with the following additional changes:

Code: Select all

        $address = [
          'address_line1' => $GLOBALS['customer_data']->get('street_address', $order->billing) ?? '',
          'address_city' => $GLOBALS['customer_data']->get('city', $order->billing) ?? '',
          'address_zip' => $GLOBALS['customer_data']->get('postcode', $order->billing) ?? '',
          'address_state' => $GLOBALS['customer_data']->get('state', $order->billing) ?? '',
          'address_country' => $GLOBALS['customer_data']->get('country_iso_code_2', $order->billing) ?? '',
        ];

        foreach ($address as $k => $v) {
            $content .= '<input type="hidden" id="' . Text::output($k) . '" value="' . Text::output($v) . '" />';
        }
1. I replaced "tep_output_string" by "Text::output"
2. I catched all customer data with empty string if null. In the extreme case, if a shop for example only sells downloadable products, they may just use customer name and e-mail.
3. I removed tep_output_string/Text::output in the array built, its already used in the output loop and $address is not used elsewhere.

Or maybe I should keep "tep_output_string" for backwards compatibility and avoid an additional version?

Does it look O.K. to you?
Thank you!
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Stripe V3 SCA

Post by ecartz »

This looks OK. It might have been easier to have done one of the two changes in

Code: Select all

        foreach (array_filter($address) as $k => $v) {
            $content .= '<input type="hidden" id="' . Text::output($k) . '" value="' . Text::output($v ?? '') . '" />';
        }
and left the ?? '' off the individual ones. Those two changes are redundant. The ?? '' will never trigger if the array_filter is used. And of course, there's no particular reason to change it now. You've already done the work that it would save. And it's possible that Stripe needs those keys to be there even if blank, which would mean that you couldn't use the array_filter.
randers
VIP Member
VIP Member
Posts: 31
Joined: Mon Oct 26, 2020 8:22 pm

Re: Stripe V3 SCA

Post by randers »

Hi

If Enable State module is set to "False" in Customer_data Stipe Payment modul is not shown on the checkout payment page.
Locked