Add type of user as form data to be received on wc process payment request

This commit is contained in:
Emili Castells Guasch 2024-05-01 17:01:15 +02:00
parent c80f58abcf
commit 8a9dd52bd0
2 changed files with 13 additions and 7 deletions

View file

@ -646,7 +646,7 @@ class AxoManager {
return {
fields: fields,
styles: this.remove_keys_with_empty_string(this.axoConfig.style_options)
styles: this.delete_keys_with_empty_string(this.axoConfig.style_options)
}
}
@ -697,6 +697,9 @@ class AxoManager {
formData.set(key, data[key]);
});
// Set type of user (Ryan) to be received on WC gateway process payment request.
formData.set('fastlane_member', true);
fetch(wc_checkout_params.checkout_url, { // TODO: maybe create a new endpoint to process_payment.
method: "POST",
body: formData
@ -747,13 +750,13 @@ class AxoManager {
return this.axoConfig?.widgets?.email === 'use_widget';
}
remove_keys_with_empty_string = (obj) => {
delete_keys_with_empty_string = (obj) => {
for(let key of Object.keys(obj)){
if (obj[key] === ''){
delete obj[key];
}
else if (typeof obj[key] === 'object'){
obj[key] = this.remove_keys_with_empty_string(obj[key]);
obj[key] = this.delete_keys_with_empty_string(obj[key]);
if (Object.keys(obj[key]).length === 0 ) delete obj[key];
}
}