-
Notifications
You must be signed in to change notification settings - Fork 1
fix(payments): Rewrite composePayment with graphql #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/api/billing/index.ts
Outdated
| const { data, errors } = await api.call(QUERY_COMPOSE_PAYMENT, { | ||
| input: { workspaceId, tariffPlanId, shouldSaveCard }, | ||
| }); | ||
|
|
||
| return data.composePayment as BeforePaymentPayload; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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'); |
There was a problem hiding this comment.
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.
Helps fix probrem when user tries to pay but he is not authenticated
works with codex-team/hawk.api.nodejs#520