Skip to content

Conversation

@TatianaFomina
Copy link
Contributor

@TatianaFomina TatianaFomina commented Aug 9, 2025

Helps fix probrem when user tries to pay but he is not authenticated

works with codex-team/hawk.api.nodejs#520

Comment on lines 56 to 60
const { data, errors } = await api.call(QUERY_COMPOSE_PAYMENT, {
input: { workspaceId, tariffPlanId, shouldSaveCard },
});

return data.composePayment as BeforePaymentPayload;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphQL can return data correctly along with errors.

Its better to return both data and errors in this method. And handle them in ancestor-level. See FETCH_CURRENT_USER and FETCH_INITIAL_DATA as examples

const key = 'errors.' + (e as Error).message;
const message = this.$te(key) ? this.$t(key) as string : this.$t('billing.notifications.error');
console.log('this.$te(key)', key, this.$te(key));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('this.$te(key)', key, this.$te(key));

});
} catch (e) {
const key = 'errors.' + (e as Error).message;
const message = this.$te(key) ? this.$t(key) as string : this.$t('billing.notifications.error');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe authorization errors should be handled in a central place.

@TatianaFomina TatianaFomina merged commit 6d54187 into master Aug 10, 2025
2 checks passed
@TatianaFomina TatianaFomina deleted the fix/check-auto-before-compose-payment branch August 10, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants