Page 1 of 3
Stripe V3 SCA
Posted: Sat Mar 13, 2021 9:03 pm
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?
Re: Stripe V3 SCA
Posted: Sat Mar 13, 2021 9:17 pm
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
Re: Stripe V3 SCA
Posted: Sat Mar 13, 2021 9:22 pm
by raiwa
I’ll check tomorrow
Re: Stripe V3 SCA
Posted: Sun Mar 14, 2021 8:07 am
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'])),
Re: Stripe V3 SCA
Posted: Sun Mar 14, 2021 9:04 am
by zeeshop
Thanks very much
@raiwa
These changes fixed the issue

Re: Stripe V3 SCA
Posted: Sun Mar 14, 2021 9:25 am
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) ?? ''),
Re: Stripe V3 SCA
Posted: Sun Mar 14, 2021 9:43 am
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.
Re: Stripe V3 SCA
Posted: Mon Mar 15, 2021 11:57 am
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!
Re: Stripe V3 SCA
Posted: Mon Mar 15, 2021 12:06 pm
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.
Re: Stripe V3 SCA
Posted: Mon Mar 15, 2021 3:27 pm
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.