- Issue created by @rszrama
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
vmarchuk β made their first commit to this issueβs fork.
- Merge request !8Issue #3398517: Allow the locale to be altered when API requests are made. β (Merged) created by Unnamed author
- Status changed to Needs review
about 1 year ago 3:28pm 27 November 2023 - 89eef4db committed on 2.0.x
Issue #3398517: Allow the locale to be altered when API requests are...
- 89eef4db committed on 2.0.x
- Status changed to Fixed
about 1 year ago 8:10am 5 December 2023 - Status changed to Needs work
about 1 year ago 4:33pm 11 December 2023 - πΊπΈUnited States rszrama
I think the getter was previously correct to return exactly what was in the configuration. That is indeed the default.
The altering of the locale should happen at the point the JavaScript setting for the Affirm locale is being set. I see you opted for the event based approach, which is fine vs. an alter, though I think an alter would've been sufficient. Let's move that event dispatch to
commerce_affirm_preprocess()
andcommerce_affirm_page_attachments()
instead, though. - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
@rszrama
We also need to alter the settings in RedirectForm::buildConfigurationForm() so we need to use the event dispatcher in 3 places, but the idea was to use it in one place (as long as possible).
Perhaps it would be better:- Use hook_js_settings_alter() and add an event dispatcher there. But here we can't pass the payment gateway settings to the event.
- Define a new method in the Redirect payment gateway getLocale() and add an event dispatcher there.
What do you think?
- πΊπΈUnited States rszrama
@vmarchuk, I like your second option: if we'll always have the payment gateway object in the context where we're determining the locale, let's add
getLocale()
with the event dispatcher. This will preserve the idea that the gateway configuration stores the default and then it can optionally be overridden at the point of display. - Merge request !10Issue #3398517: Allow the locale to be altered when API requests are made. β (Merged) created by Unnamed author
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
@rszrama
MR is ready https://git.drupalcode.org/project/commerce_affirm/-/merge_requests/10
Feel free to merge it and tag a new release. - πΊπΈUnited States rszrama
Sorry to send it back, but in order to be consistent with the Affirm API, we need to revise this MR one last time:
- Use
$locale
instead of$default_locale
as the variable name ingetLocale()
. - Rename the alteration event to
AffirmEvents::AFFIRM_LOCALE
. - Use
Locale
instead ofDefaultLocale
as the property name in the JS settings array.
Basically, "default locale" is a concept specific to our local payment gateway configuration. When we prepare the parameter to send it to Affirm, we should just be using "locale".
- Use
- Status changed to Needs review
about 1 year ago 9:41am 14 December 2023 - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
@rszrama
I updated MR https://git.drupalcode.org/project/commerce_affirm/-/merge_requests/10/d...
I also renamed the event to AFFIRM_LOCALE_PRESEND to make it clearer what it does + added related changes to the AffirmLocalePreSendEvent - πΊπΈUnited States rszrama
Ahh, I see. I understand the intent behind the name, but I'm going to change it back to keep it in line with our various alter events in Commerce Core, e.g.,
OrderEvents::ORDER_LABEL
replacing ahook_commerce_order_label_alter()
. Merging now and will roll that release! -
rszrama β
committed 20e80e70 on 2.0.x authored by
vmarchuk β
Issue #3398517 by vmarchuk, rszrama: Allow the locale to be altered when...
-
rszrama β
committed 20e80e70 on 2.0.x authored by
vmarchuk β
-
rszrama β
committed 051d4c04 on 2.0.x
Issue #3398517 follow-up by rszrama: rename the Affirm locale altering...
-
rszrama β
committed 051d4c04 on 2.0.x
- Status changed to Fixed
about 1 year ago 9:19pm 14 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.